├── asar_modules ├── node_modules │ ├── .bin │ │ └── asar │ ├── concat-map │ │ ├── .travis.yml │ │ ├── example │ │ │ └── map.js │ │ ├── index.js │ │ ├── LICENSE │ │ ├── package.json │ │ ├── test │ │ │ └── map.js │ │ └── README.markdown │ ├── balanced-match │ │ ├── .github │ │ │ └── FUNDING.yml │ │ ├── LICENSE.md │ │ ├── package.json │ │ ├── index.js │ │ └── README.md │ ├── inherits │ │ ├── inherits.js │ │ ├── package.json │ │ ├── LICENSE │ │ ├── inherits_browser.js │ │ └── README.md │ ├── fs.realpath │ │ ├── package.json │ │ ├── README.md │ │ ├── index.js │ │ ├── LICENSE │ │ └── old.js │ ├── path-is-absolute │ │ ├── index.js │ │ ├── package.json │ │ ├── license │ │ └── readme.md │ ├── once │ │ ├── package.json │ │ ├── LICENSE │ │ ├── once.js │ │ └── README.md │ ├── @electron │ │ └── asar │ │ │ ├── lib │ │ │ ├── wrapped-fs.js │ │ │ ├── crawlfs.js │ │ │ ├── integrity.js │ │ │ ├── disk.js │ │ │ ├── filesystem.js │ │ │ ├── index.d.ts │ │ │ ├── pickle.js │ │ │ └── asar.js │ │ │ ├── LICENSE.md │ │ │ ├── package.json │ │ │ ├── bin │ │ │ └── asar.js │ │ │ └── README.md │ ├── wrappy │ │ ├── package.json │ │ ├── LICENSE │ │ ├── README.md │ │ └── wrappy.js │ ├── inflight │ │ ├── package.json │ │ ├── LICENSE │ │ ├── README.md │ │ └── inflight.js │ ├── minimatch │ │ ├── LICENSE │ │ ├── package.json │ │ └── README.md │ ├── glob │ │ ├── LICENSE │ │ ├── package.json │ │ └── common.js │ ├── brace-expansion │ │ ├── LICENSE │ │ ├── package.json │ │ ├── README.md │ │ └── index.js │ ├── commander │ │ ├── LICENSE │ │ ├── package.json │ │ └── typings │ │ │ └── index.d.ts │ └── .package-lock.json ├── package.json └── package-lock.json ├── convert_utf2gbk.sh ├── inject_gbk.bat ├── img ├── LICENSE.png ├── image-202405070106.png ├── image-20230611002616301.png └── image-20230611002645270.png ├── license-gen ├── Cargo.toml ├── src │ └── main.rs └── Cargo.lock ├── Cargo.toml ├── license_code ├── .gitignore ├── issue_template.md ├── LICENSE ├── NodeInject_README.md ├── .github └── workflows │ └── build.yml ├── src ├── main.rs ├── hook.js └── hooklog.js ├── inject.py ├── inject_utf.bat ├── inject.sh ├── Cargo.lock └── README.md /asar_modules/node_modules/.bin/asar: -------------------------------------------------------------------------------- 1 | ../@electron/asar/bin/asar.js -------------------------------------------------------------------------------- /convert_utf2gbk.sh: -------------------------------------------------------------------------------- 1 | iconv -f utf-8 -t gbk inject_utf.bat >inject_gbk.bat 2 | -------------------------------------------------------------------------------- /inject_gbk.bat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hazukieq/Yporaject/HEAD/inject_gbk.bat -------------------------------------------------------------------------------- /img/LICENSE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hazukieq/Yporaject/HEAD/img/LICENSE.png -------------------------------------------------------------------------------- /asar_modules/node_modules/concat-map/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 0.4 4 | - 0.6 5 | -------------------------------------------------------------------------------- /asar_modules/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "@electron/asar": "^3.2.9" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /img/image-202405070106.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hazukieq/Yporaject/HEAD/img/image-202405070106.png -------------------------------------------------------------------------------- /img/image-20230611002616301.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hazukieq/Yporaject/HEAD/img/image-20230611002616301.png -------------------------------------------------------------------------------- /img/image-20230611002645270.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hazukieq/Yporaject/HEAD/img/image-20230611002645270.png -------------------------------------------------------------------------------- /asar_modules/node_modules/balanced-match/.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | tidelift: "npm/balanced-match" 2 | patreon: juliangruber 3 | -------------------------------------------------------------------------------- /asar_modules/node_modules/concat-map/example/map.js: -------------------------------------------------------------------------------- 1 | var concatMap = require('../'); 2 | var xs = [ 1, 2, 3, 4, 5, 6 ]; 3 | var ys = concatMap(xs, function (x) { 4 | return x % 2 ? [ x - 0.1, x, x + 0.1 ] : []; 5 | }); 6 | console.dir(ys); 7 | -------------------------------------------------------------------------------- /license-gen/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "license-gen" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | random-string = "1.0" -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "node_inject" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | 7 | [dependencies] 8 | rasar = {git = 'https://github.com/Zerthox/rasar.git'} 9 | random-string = "1.0.0" 10 | 11 | [features] 12 | no_embed = [] 13 | default = [] 14 | -------------------------------------------------------------------------------- /license_code: -------------------------------------------------------------------------------- 1 | # JUST FOR LEARNING PURPOSES, DON'T USE THIS TO CRACK SOFTWARE. 2 | # 只是出于学习目的,请勿将其用于破解软件,否则后果自负。用户行为均与本项目作者无关! 3 | 4 | D9KYN9-MCCL2F-59LFPC-NK2CPX 5 | LSGDW2-6M43UN-KHKH2A-D6FDJF 6 | XPMZGS-3AQRBD-EZKE9K-UPFRL5 7 | SNCA7S-3CYDVX-V6YVDD-UF6NXA 8 | 59WW3J-Z8X3NH-76WACJ-VBNANW 9 | -------------------------------------------------------------------------------- /asar_modules/node_modules/inherits/inherits.js: -------------------------------------------------------------------------------- 1 | try { 2 | var util = require('util'); 3 | /* istanbul ignore next */ 4 | if (typeof util.inherits !== 'function') throw ''; 5 | module.exports = util.inherits; 6 | } catch (e) { 7 | /* istanbul ignore next */ 8 | module.exports = require('./inherits_browser.js'); 9 | } 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | 8 | # Output of the go coverage tool, specifically when used with LiteIDE 9 | *.out 10 | 11 | # Dependency directories (remove the comment below to include it) 12 | # vendor/ 13 | 14 | 15 | # Added by cargo 16 | license-gen/target 17 | .idea 18 | build 19 | target 20 | -------------------------------------------------------------------------------- /asar_modules/node_modules/concat-map/index.js: -------------------------------------------------------------------------------- 1 | module.exports = function (xs, fn) { 2 | var res = []; 3 | for (var i = 0; i < xs.length; i++) { 4 | var x = fn(xs[i], i); 5 | if (isArray(x)) res.push.apply(res, x); 6 | else res.push(x); 7 | } 8 | return res; 9 | }; 10 | 11 | var isArray = Array.isArray || function (xs) { 12 | return Object.prototype.toString.call(xs) === '[object Array]'; 13 | }; 14 | -------------------------------------------------------------------------------- /license-gen/src/main.rs: -------------------------------------------------------------------------------- 1 | use random_string::generate; 2 | 3 | const LICENSE_CHARS: &str = "L23456789ABCDEFGHJKMNPQRSTUVWXYZ"; 4 | fn main() { 5 | generate_license(); 6 | } 7 | 8 | fn generate_license(){ 9 | let mut license = generate(22, LICENSE_CHARS); 10 | for n in 0..2 { 11 | let mut o = 0; 12 | for i in (0..16).step_by(2) { 13 | o += LICENSE_CHARS.find(&license[n+i..=n+i]).unwrap() 14 | } 15 | o %= LICENSE_CHARS.len(); 16 | license += &LICENSE_CHARS[o..=o]; 17 | } 18 | license.insert(6, '-'); 19 | license.insert(13, '-'); 20 | license.insert(20, '-'); 21 | println!("License for you: {}", license); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /asar_modules/node_modules/fs.realpath/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fs.realpath", 3 | "version": "1.0.0", 4 | "description": "Use node's fs.realpath, but fall back to the JS implementation if the native one fails", 5 | "main": "index.js", 6 | "dependencies": {}, 7 | "devDependencies": {}, 8 | "scripts": { 9 | "test": "tap test/*.js --cov" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/isaacs/fs.realpath.git" 14 | }, 15 | "keywords": [ 16 | "realpath", 17 | "fs", 18 | "polyfill" 19 | ], 20 | "author": "Isaac Z. Schlueter (http://blog.izs.me/)", 21 | "license": "ISC", 22 | "files": [ 23 | "old.js", 24 | "index.js" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /asar_modules/node_modules/path-is-absolute/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | function posix(path) { 4 | return path.charAt(0) === '/'; 5 | } 6 | 7 | function win32(path) { 8 | // https://github.com/nodejs/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56 9 | var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/; 10 | var result = splitDeviceRe.exec(path); 11 | var device = result[1] || ''; 12 | var isUnc = Boolean(device && device.charAt(1) !== ':'); 13 | 14 | // UNC paths are always absolute 15 | return Boolean(result[2] || isUnc); 16 | } 17 | 18 | module.exports = process.platform === 'win32' ? win32 : posix; 19 | module.exports.posix = posix; 20 | module.exports.win32 = win32; 21 | -------------------------------------------------------------------------------- /asar_modules/node_modules/inherits/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "inherits", 3 | "description": "Browser-friendly inheritance fully compatible with standard node.js inherits()", 4 | "version": "2.0.4", 5 | "keywords": [ 6 | "inheritance", 7 | "class", 8 | "klass", 9 | "oop", 10 | "object-oriented", 11 | "inherits", 12 | "browser", 13 | "browserify" 14 | ], 15 | "main": "./inherits.js", 16 | "browser": "./inherits_browser.js", 17 | "repository": "git://github.com/isaacs/inherits", 18 | "license": "ISC", 19 | "scripts": { 20 | "test": "tap" 21 | }, 22 | "devDependencies": { 23 | "tap": "^14.2.4" 24 | }, 25 | "files": [ 26 | "inherits.js", 27 | "inherits_browser.js" 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /asar_modules/node_modules/once/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "once", 3 | "version": "1.4.0", 4 | "description": "Run a function exactly one time", 5 | "main": "once.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "dependencies": { 10 | "wrappy": "1" 11 | }, 12 | "devDependencies": { 13 | "tap": "^7.0.1" 14 | }, 15 | "scripts": { 16 | "test": "tap test/*.js" 17 | }, 18 | "files": [ 19 | "once.js" 20 | ], 21 | "repository": { 22 | "type": "git", 23 | "url": "git://github.com/isaacs/once" 24 | }, 25 | "keywords": [ 26 | "once", 27 | "function", 28 | "one", 29 | "single" 30 | ], 31 | "author": "Isaac Z. Schlueter (http://blog.izs.me/)", 32 | "license": "ISC" 33 | } 34 | -------------------------------------------------------------------------------- /asar_modules/node_modules/@electron/asar/lib/wrapped-fs.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const fs = process.versions.electron ? require('original-fs') : require('fs') 4 | 5 | const promisifiedMethods = [ 6 | 'lstat', 7 | 'mkdtemp', 8 | 'readFile', 9 | 'stat', 10 | 'writeFile' 11 | ] 12 | 13 | const promisified = {} 14 | 15 | for (const method of Object.keys(fs)) { 16 | if (promisifiedMethods.includes(method)) { 17 | promisified[method] = fs.promises[method] 18 | } else { 19 | promisified[method] = fs[method] 20 | } 21 | } 22 | // To make it more like fs-extra 23 | promisified.mkdirp = (dir) => fs.promises.mkdir(dir, { recursive: true }) 24 | promisified.mkdirpSync = (dir) => fs.mkdirSync(dir, { recursive: true }) 25 | 26 | module.exports = promisified 27 | -------------------------------------------------------------------------------- /asar_modules/node_modules/wrappy/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wrappy", 3 | "version": "1.0.2", 4 | "description": "Callback wrapping utility", 5 | "main": "wrappy.js", 6 | "files": [ 7 | "wrappy.js" 8 | ], 9 | "directories": { 10 | "test": "test" 11 | }, 12 | "dependencies": {}, 13 | "devDependencies": { 14 | "tap": "^2.3.1" 15 | }, 16 | "scripts": { 17 | "test": "tap --coverage test/*.js" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "https://github.com/npm/wrappy" 22 | }, 23 | "author": "Isaac Z. Schlueter (http://blog.izs.me/)", 24 | "license": "ISC", 25 | "bugs": { 26 | "url": "https://github.com/npm/wrappy/issues" 27 | }, 28 | "homepage": "https://github.com/npm/wrappy" 29 | } 30 | -------------------------------------------------------------------------------- /asar_modules/node_modules/inflight/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "inflight", 3 | "version": "1.0.6", 4 | "description": "Add callbacks to requests in flight to avoid async duplication", 5 | "main": "inflight.js", 6 | "files": [ 7 | "inflight.js" 8 | ], 9 | "dependencies": { 10 | "once": "^1.3.0", 11 | "wrappy": "1" 12 | }, 13 | "devDependencies": { 14 | "tap": "^7.1.2" 15 | }, 16 | "scripts": { 17 | "test": "tap test.js --100" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "https://github.com/npm/inflight.git" 22 | }, 23 | "author": "Isaac Z. Schlueter (http://blog.izs.me/)", 24 | "bugs": { 25 | "url": "https://github.com/isaacs/inflight/issues" 26 | }, 27 | "homepage": "https://github.com/isaacs/inflight", 28 | "license": "ISC" 29 | } 30 | -------------------------------------------------------------------------------- /asar_modules/node_modules/inflight/LICENSE: -------------------------------------------------------------------------------- 1 | The ISC License 2 | 3 | Copyright (c) Isaac Z. Schlueter 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 15 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /asar_modules/node_modules/inherits/LICENSE: -------------------------------------------------------------------------------- 1 | The ISC License 2 | 3 | Copyright (c) Isaac Z. Schlueter 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 10 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 11 | FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 12 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 13 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 14 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 15 | PERFORMANCE OF THIS SOFTWARE. 16 | 17 | -------------------------------------------------------------------------------- /asar_modules/node_modules/once/LICENSE: -------------------------------------------------------------------------------- 1 | The ISC License 2 | 3 | Copyright (c) Isaac Z. Schlueter and Contributors 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 15 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /asar_modules/node_modules/wrappy/LICENSE: -------------------------------------------------------------------------------- 1 | The ISC License 2 | 3 | Copyright (c) Isaac Z. Schlueter and Contributors 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 15 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /asar_modules/node_modules/minimatch/LICENSE: -------------------------------------------------------------------------------- 1 | The ISC License 2 | 3 | Copyright (c) Isaac Z. Schlueter and Contributors 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 15 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /asar_modules/node_modules/wrappy/README.md: -------------------------------------------------------------------------------- 1 | # wrappy 2 | 3 | Callback wrapping utility 4 | 5 | ## USAGE 6 | 7 | ```javascript 8 | var wrappy = require("wrappy") 9 | 10 | // var wrapper = wrappy(wrapperFunction) 11 | 12 | // make sure a cb is called only once 13 | // See also: http://npm.im/once for this specific use case 14 | var once = wrappy(function (cb) { 15 | var called = false 16 | return function () { 17 | if (called) return 18 | called = true 19 | return cb.apply(this, arguments) 20 | } 21 | }) 22 | 23 | function printBoo () { 24 | console.log('boo') 25 | } 26 | // has some rando property 27 | printBoo.iAmBooPrinter = true 28 | 29 | var onlyPrintOnce = once(printBoo) 30 | 31 | onlyPrintOnce() // prints 'boo' 32 | onlyPrintOnce() // does nothing 33 | 34 | // random property is retained! 35 | assert.equal(onlyPrintOnce.iAmBooPrinter, true) 36 | ``` 37 | -------------------------------------------------------------------------------- /asar_modules/node_modules/minimatch/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Isaac Z. Schlueter (http://blog.izs.me)", 3 | "name": "minimatch", 4 | "description": "a glob matcher in javascript", 5 | "version": "3.1.2", 6 | "publishConfig": { 7 | "tag": "v3-legacy" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git://github.com/isaacs/minimatch.git" 12 | }, 13 | "main": "minimatch.js", 14 | "scripts": { 15 | "test": "tap", 16 | "preversion": "npm test", 17 | "postversion": "npm publish", 18 | "postpublish": "git push origin --all; git push origin --tags" 19 | }, 20 | "engines": { 21 | "node": "*" 22 | }, 23 | "dependencies": { 24 | "brace-expansion": "^1.1.7" 25 | }, 26 | "devDependencies": { 27 | "tap": "^15.1.6" 28 | }, 29 | "license": "ISC", 30 | "files": [ 31 | "minimatch.js" 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /issue_template.md: -------------------------------------------------------------------------------- 1 | ## 提问模板 2 | ### **描述你在学习中遇到的问题** 3 | 4 | **为避免无效问题和冗余问题,提问前请确认:** 5 | 1. 你确定 Google 不能解决你的问题 6 | 2. 你确定已有的 issue 不能解决你的问题 7 | 3. 你确定 issue 的 title 按照格式如下:[问题]:问题描述 8 | 9 | 10 | 11 | **Describe the Problem 描述你遇到的问题** 12 |  A clear and concise description of what the problem is. 简洁有效的说明。 13 | 14 | 15 | 16 | **To Reproduce 如何重现问题** 17 | Steps to reproduce the behavior 简要描述问题的发生 18 | 19 | 20 | 21 | **Expected behavior 期待解决的效果** 22 |  A clear and concise description of what you expected to happen. 简单描述。 23 | 24 | 25 | 26 | **Screenshots 截图** 27 | If applicable, add screenshots to help explain your problem. 28 | 如有必要,可以截图说明  29 | 30 | 31 | 32 | **Environmemt 环境版本说明** 33 | - OS: [e.g. win] 说明操作系统 34 | - Rust Version 说明语言及版本号 35 | - Typora Package Version 软件版本 36 | 37 | 38 | 39 | **Additional Text 其他补充** 40 | Add any other context about the problem here. 添加你认为有必要的内容,否则不写。 41 | -------------------------------------------------------------------------------- /asar_modules/node_modules/inherits/inherits_browser.js: -------------------------------------------------------------------------------- 1 | if (typeof Object.create === 'function') { 2 | // implementation from standard node.js 'util' module 3 | module.exports = function inherits(ctor, superCtor) { 4 | if (superCtor) { 5 | ctor.super_ = superCtor 6 | ctor.prototype = Object.create(superCtor.prototype, { 7 | constructor: { 8 | value: ctor, 9 | enumerable: false, 10 | writable: true, 11 | configurable: true 12 | } 13 | }) 14 | } 15 | }; 16 | } else { 17 | // old school shim for old browsers 18 | module.exports = function inherits(ctor, superCtor) { 19 | if (superCtor) { 20 | ctor.super_ = superCtor 21 | var TempCtor = function () {} 22 | TempCtor.prototype = superCtor.prototype 23 | ctor.prototype = new TempCtor() 24 | ctor.prototype.constructor = ctor 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /asar_modules/node_modules/path-is-absolute/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "path-is-absolute", 3 | "version": "1.0.1", 4 | "description": "Node.js 0.12 path.isAbsolute() ponyfill", 5 | "license": "MIT", 6 | "repository": "sindresorhus/path-is-absolute", 7 | "author": { 8 | "name": "Sindre Sorhus", 9 | "email": "sindresorhus@gmail.com", 10 | "url": "sindresorhus.com" 11 | }, 12 | "engines": { 13 | "node": ">=0.10.0" 14 | }, 15 | "scripts": { 16 | "test": "xo && node test.js" 17 | }, 18 | "files": [ 19 | "index.js" 20 | ], 21 | "keywords": [ 22 | "path", 23 | "paths", 24 | "file", 25 | "dir", 26 | "absolute", 27 | "isabsolute", 28 | "is-absolute", 29 | "built-in", 30 | "util", 31 | "utils", 32 | "core", 33 | "ponyfill", 34 | "polyfill", 35 | "shim", 36 | "is", 37 | "detect", 38 | "check" 39 | ], 40 | "devDependencies": { 41 | "xo": "^0.16.0" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /asar_modules/node_modules/fs.realpath/README.md: -------------------------------------------------------------------------------- 1 | # fs.realpath 2 | 3 | A backwards-compatible fs.realpath for Node v6 and above 4 | 5 | In Node v6, the JavaScript implementation of fs.realpath was replaced 6 | with a faster (but less resilient) native implementation. That raises 7 | new and platform-specific errors and cannot handle long or excessively 8 | symlink-looping paths. 9 | 10 | This module handles those cases by detecting the new errors and 11 | falling back to the JavaScript implementation. On versions of Node 12 | prior to v6, it has no effect. 13 | 14 | ## USAGE 15 | 16 | ```js 17 | var rp = require('fs.realpath') 18 | 19 | // async version 20 | rp.realpath(someLongAndLoopingPath, function (er, real) { 21 | // the ELOOP was handled, but it was a bit slower 22 | }) 23 | 24 | // sync version 25 | var real = rp.realpathSync(someLongAndLoopingPath) 26 | 27 | // monkeypatch at your own risk! 28 | // This replaces the fs.realpath/fs.realpathSync builtins 29 | rp.monkeypatch() 30 | 31 | // un-do the monkeypatching 32 | rp.unmonkeypatch() 33 | ``` 34 | -------------------------------------------------------------------------------- /asar_modules/node_modules/wrappy/wrappy.js: -------------------------------------------------------------------------------- 1 | // Returns a wrapper function that returns a wrapped callback 2 | // The wrapper function should do some stuff, and return a 3 | // presumably different callback function. 4 | // This makes sure that own properties are retained, so that 5 | // decorations and such are not lost along the way. 6 | module.exports = wrappy 7 | function wrappy (fn, cb) { 8 | if (fn && cb) return wrappy(fn)(cb) 9 | 10 | if (typeof fn !== 'function') 11 | throw new TypeError('need wrapper function') 12 | 13 | Object.keys(fn).forEach(function (k) { 14 | wrapper[k] = fn[k] 15 | }) 16 | 17 | return wrapper 18 | 19 | function wrapper() { 20 | var args = new Array(arguments.length) 21 | for (var i = 0; i < args.length; i++) { 22 | args[i] = arguments[i] 23 | } 24 | var ret = fn.apply(this, args) 25 | var cb = args[args.length-1] 26 | if (typeof ret === 'function' && ret !== cb) { 27 | Object.keys(cb).forEach(function (k) { 28 | ret[k] = cb[k] 29 | }) 30 | } 31 | return ret 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /asar_modules/node_modules/glob/LICENSE: -------------------------------------------------------------------------------- 1 | The ISC License 2 | 3 | Copyright (c) Isaac Z. Schlueter and Contributors 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 15 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | 17 | ## Glob Logo 18 | 19 | Glob's logo created by Tanya Brassie , licensed 20 | under a Creative Commons Attribution-ShareAlike 4.0 International License 21 | https://creativecommons.org/licenses/by-sa/4.0/ 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 DiamondHunters 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 | -------------------------------------------------------------------------------- /asar_modules/node_modules/once/once.js: -------------------------------------------------------------------------------- 1 | var wrappy = require('wrappy') 2 | module.exports = wrappy(once) 3 | module.exports.strict = wrappy(onceStrict) 4 | 5 | once.proto = once(function () { 6 | Object.defineProperty(Function.prototype, 'once', { 7 | value: function () { 8 | return once(this) 9 | }, 10 | configurable: true 11 | }) 12 | 13 | Object.defineProperty(Function.prototype, 'onceStrict', { 14 | value: function () { 15 | return onceStrict(this) 16 | }, 17 | configurable: true 18 | }) 19 | }) 20 | 21 | function once (fn) { 22 | var f = function () { 23 | if (f.called) return f.value 24 | f.called = true 25 | return f.value = fn.apply(this, arguments) 26 | } 27 | f.called = false 28 | return f 29 | } 30 | 31 | function onceStrict (fn) { 32 | var f = function () { 33 | if (f.called) 34 | throw new Error(f.onceError) 35 | f.called = true 36 | return f.value = fn.apply(this, arguments) 37 | } 38 | var name = fn.name || 'Function wrapped with `once`' 39 | f.onceError = name + " shouldn't be called more than once" 40 | f.called = false 41 | return f 42 | } 43 | -------------------------------------------------------------------------------- /asar_modules/node_modules/@electron/asar/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 GitHub Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /asar_modules/node_modules/concat-map/LICENSE: -------------------------------------------------------------------------------- 1 | This software is released under the MIT license: 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /asar_modules/node_modules/inflight/README.md: -------------------------------------------------------------------------------- 1 | # inflight 2 | 3 | Add callbacks to requests in flight to avoid async duplication 4 | 5 | ## USAGE 6 | 7 | ```javascript 8 | var inflight = require('inflight') 9 | 10 | // some request that does some stuff 11 | function req(key, callback) { 12 | // key is any random string. like a url or filename or whatever. 13 | // 14 | // will return either a falsey value, indicating that the 15 | // request for this key is already in flight, or a new callback 16 | // which when called will call all callbacks passed to inflightk 17 | // with the same key 18 | callback = inflight(key, callback) 19 | 20 | // If we got a falsey value back, then there's already a req going 21 | if (!callback) return 22 | 23 | // this is where you'd fetch the url or whatever 24 | // callback is also once()-ified, so it can safely be assigned 25 | // to multiple events etc. First call wins. 26 | setTimeout(function() { 27 | callback(null, key) 28 | }, 100) 29 | } 30 | 31 | // only assigns a single setTimeout 32 | // when it dings, all cbs get called 33 | req('foo', cb1) 34 | req('foo', cb2) 35 | req('foo', cb3) 36 | req('foo', cb4) 37 | ``` 38 | -------------------------------------------------------------------------------- /asar_modules/node_modules/balanced-match/LICENSE.md: -------------------------------------------------------------------------------- 1 | (MIT) 2 | 3 | Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | of the Software, and to permit persons to whom the Software is furnished to do 10 | 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 | -------------------------------------------------------------------------------- /asar_modules/node_modules/brace-expansion/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2013 Julian Gruber 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 | -------------------------------------------------------------------------------- /asar_modules/node_modules/commander/LICENSE: -------------------------------------------------------------------------------- 1 | (The MIT License) 2 | 3 | Copyright (c) 2011 TJ Holowaychuk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | 'Software'), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /asar_modules/node_modules/concat-map/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "concat-map", 3 | "description" : "concatenative mapdashery", 4 | "version" : "0.0.1", 5 | "repository" : { 6 | "type" : "git", 7 | "url" : "git://github.com/substack/node-concat-map.git" 8 | }, 9 | "main" : "index.js", 10 | "keywords" : [ 11 | "concat", 12 | "concatMap", 13 | "map", 14 | "functional", 15 | "higher-order" 16 | ], 17 | "directories" : { 18 | "example" : "example", 19 | "test" : "test" 20 | }, 21 | "scripts" : { 22 | "test" : "tape test/*.js" 23 | }, 24 | "devDependencies" : { 25 | "tape" : "~2.4.0" 26 | }, 27 | "license" : "MIT", 28 | "author" : { 29 | "name" : "James Halliday", 30 | "email" : "mail@substack.net", 31 | "url" : "http://substack.net" 32 | }, 33 | "testling" : { 34 | "files" : "test/*.js", 35 | "browsers" : { 36 | "ie" : [ 6, 7, 8, 9 ], 37 | "ff" : [ 3.5, 10, 15.0 ], 38 | "chrome" : [ 10, 22 ], 39 | "safari" : [ 5.1 ], 40 | "opera" : [ 12 ] 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /asar_modules/node_modules/path-is-absolute/license: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Sindre Sorhus (sindresorhus.com) 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 13 | all 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 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /license-gen/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "cfg-if" 7 | version = "1.0.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 10 | 11 | [[package]] 12 | name = "fastrand" 13 | version = "1.8.0" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" 16 | dependencies = [ 17 | "instant", 18 | ] 19 | 20 | [[package]] 21 | name = "instant" 22 | version = "0.1.12" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" 25 | dependencies = [ 26 | "cfg-if", 27 | ] 28 | 29 | [[package]] 30 | name = "license-gen" 31 | version = "0.1.0" 32 | dependencies = [ 33 | "random-string", 34 | ] 35 | 36 | [[package]] 37 | name = "random-string" 38 | version = "1.0.0" 39 | source = "registry+https://github.com/rust-lang/crates.io-index" 40 | checksum = "cf4e63111ec5292d8af9c220f06fe3bb87991cc78b6f1f7e291d1ae6b8a60817" 41 | dependencies = [ 42 | "fastrand", 43 | ] 44 | -------------------------------------------------------------------------------- /NodeInject_README.md: -------------------------------------------------------------------------------- 1 | ## NodeInject 2 | An inject tools for injecting js code into electron application 3 | 4 | Please follow DMCA when using this code 5 | ### How it works 6 | 7 | 1. unpack `node_modules.asar` package (in `./resources`) 8 | 2. write `hook.js` into `raven` package directory (raven will be required at the early stage of startup in some application) 9 | 3. modify `index.js` of `raven`,injecting require of `hook.js` 10 | 11 | > Currently using embedded javascript file (`hooklog.js`) 12 | 13 | ### Usage 14 | 15 | 1. modify `hook.js` if you need or enable `no_embed` feature to use specified js (`NO_EMBED_HOOK_JS_PATH`) at runtime 16 | 2. use `cargo build` to make executable with embedded js or `cargo build --features no_embed` without embedded js 17 | 3. Move the program to the electron application directory 18 | 4. run 19 | 20 | 21 | ### Compatibility test 22 | 23 | - Windows / Typora 1.4.8 PASSED 24 | - Ubuntu / Typora 1.4.7 PASSED 25 | 26 | Since macos may adopt different packaging methods and webkit as the execution environment, this tool does not support applications under macos. 27 | 28 | ### Examples 29 | 30 | https://github.com/DiamondHunters/NodeInject_Hook_example :Use NodeInject to realize specific functions in Typora 31 | -------------------------------------------------------------------------------- /asar_modules/node_modules/concat-map/test/map.js: -------------------------------------------------------------------------------- 1 | var concatMap = require('../'); 2 | var test = require('tape'); 3 | 4 | test('empty or not', function (t) { 5 | var xs = [ 1, 2, 3, 4, 5, 6 ]; 6 | var ixes = []; 7 | var ys = concatMap(xs, function (x, ix) { 8 | ixes.push(ix); 9 | return x % 2 ? [ x - 0.1, x, x + 0.1 ] : []; 10 | }); 11 | t.same(ys, [ 0.9, 1, 1.1, 2.9, 3, 3.1, 4.9, 5, 5.1 ]); 12 | t.same(ixes, [ 0, 1, 2, 3, 4, 5 ]); 13 | t.end(); 14 | }); 15 | 16 | test('always something', function (t) { 17 | var xs = [ 'a', 'b', 'c', 'd' ]; 18 | var ys = concatMap(xs, function (x) { 19 | return x === 'b' ? [ 'B', 'B', 'B' ] : [ x ]; 20 | }); 21 | t.same(ys, [ 'a', 'B', 'B', 'B', 'c', 'd' ]); 22 | t.end(); 23 | }); 24 | 25 | test('scalars', function (t) { 26 | var xs = [ 'a', 'b', 'c', 'd' ]; 27 | var ys = concatMap(xs, function (x) { 28 | return x === 'b' ? [ 'B', 'B', 'B' ] : x; 29 | }); 30 | t.same(ys, [ 'a', 'B', 'B', 'B', 'c', 'd' ]); 31 | t.end(); 32 | }); 33 | 34 | test('undefs', function (t) { 35 | var xs = [ 'a', 'b', 'c', 'd' ]; 36 | var ys = concatMap(xs, function () {}); 37 | t.same(ys, [ undefined, undefined, undefined, undefined ]); 38 | t.end(); 39 | }); 40 | -------------------------------------------------------------------------------- /asar_modules/node_modules/balanced-match/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "balanced-match", 3 | "description": "Match balanced character pairs, like \"{\" and \"}\"", 4 | "version": "1.0.2", 5 | "repository": { 6 | "type": "git", 7 | "url": "git://github.com/juliangruber/balanced-match.git" 8 | }, 9 | "homepage": "https://github.com/juliangruber/balanced-match", 10 | "main": "index.js", 11 | "scripts": { 12 | "test": "tape test/test.js", 13 | "bench": "matcha test/bench.js" 14 | }, 15 | "devDependencies": { 16 | "matcha": "^0.7.0", 17 | "tape": "^4.6.0" 18 | }, 19 | "keywords": [ 20 | "match", 21 | "regexp", 22 | "test", 23 | "balanced", 24 | "parse" 25 | ], 26 | "author": { 27 | "name": "Julian Gruber", 28 | "email": "mail@juliangruber.com", 29 | "url": "http://juliangruber.com" 30 | }, 31 | "license": "MIT", 32 | "testling": { 33 | "files": "test/*.js", 34 | "browsers": [ 35 | "ie/8..latest", 36 | "firefox/20..latest", 37 | "firefox/nightly", 38 | "chrome/25..latest", 39 | "chrome/canary", 40 | "opera/12..latest", 41 | "opera/next", 42 | "safari/5.1..latest", 43 | "ipad/6.0..latest", 44 | "iphone/6.0..latest", 45 | "android-browser/4.2..latest" 46 | ] 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /asar_modules/node_modules/brace-expansion/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "brace-expansion", 3 | "description": "Brace expansion as known from sh/bash", 4 | "version": "1.1.11", 5 | "repository": { 6 | "type": "git", 7 | "url": "git://github.com/juliangruber/brace-expansion.git" 8 | }, 9 | "homepage": "https://github.com/juliangruber/brace-expansion", 10 | "main": "index.js", 11 | "scripts": { 12 | "test": "tape test/*.js", 13 | "gentest": "bash test/generate.sh", 14 | "bench": "matcha test/perf/bench.js" 15 | }, 16 | "dependencies": { 17 | "balanced-match": "^1.0.0", 18 | "concat-map": "0.0.1" 19 | }, 20 | "devDependencies": { 21 | "matcha": "^0.7.0", 22 | "tape": "^4.6.0" 23 | }, 24 | "keywords": [], 25 | "author": { 26 | "name": "Julian Gruber", 27 | "email": "mail@juliangruber.com", 28 | "url": "http://juliangruber.com" 29 | }, 30 | "license": "MIT", 31 | "testling": { 32 | "files": "test/*.js", 33 | "browsers": [ 34 | "ie/8..latest", 35 | "firefox/20..latest", 36 | "firefox/nightly", 37 | "chrome/25..latest", 38 | "chrome/canary", 39 | "opera/12..latest", 40 | "opera/next", 41 | "safari/5.1..latest", 42 | "ipad/6.0..latest", 43 | "iphone/6.0..latest", 44 | "android-browser/4.2..latest" 45 | ] 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /asar_modules/node_modules/commander/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "commander", 3 | "version": "5.1.0", 4 | "description": "the complete solution for node.js command-line programs", 5 | "keywords": [ 6 | "commander", 7 | "command", 8 | "option", 9 | "parser", 10 | "cli", 11 | "argument", 12 | "args", 13 | "argv" 14 | ], 15 | "author": "TJ Holowaychuk ", 16 | "license": "MIT", 17 | "repository": { 18 | "type": "git", 19 | "url": "https://github.com/tj/commander.js.git" 20 | }, 21 | "scripts": { 22 | "lint": "eslint index.js \"tests/**/*.js\"", 23 | "typescript-lint": "eslint typings/*.ts", 24 | "test": "jest && npm run test-typings", 25 | "test-typings": "tsc -p tsconfig.json" 26 | }, 27 | "main": "index", 28 | "files": [ 29 | "index.js", 30 | "typings/index.d.ts" 31 | ], 32 | "dependencies": {}, 33 | "devDependencies": { 34 | "@types/jest": "^25.2.1", 35 | "@types/node": "^12.12.36", 36 | "@typescript-eslint/eslint-plugin": "^2.29.0", 37 | "eslint": "^6.8.0", 38 | "eslint-config-standard-with-typescript": "^15.0.1", 39 | "eslint-plugin-jest": "^23.8.2", 40 | "jest": "^25.4.0", 41 | "standard": "^14.3.3", 42 | "typescript": "^3.7.5" 43 | }, 44 | "typings": "typings/index.d.ts", 45 | "engines": { 46 | "node": ">= 6" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /asar_modules/node_modules/path-is-absolute/readme.md: -------------------------------------------------------------------------------- 1 | # path-is-absolute [![Build Status](https://travis-ci.org/sindresorhus/path-is-absolute.svg?branch=master)](https://travis-ci.org/sindresorhus/path-is-absolute) 2 | 3 | > Node.js 0.12 [`path.isAbsolute()`](http://nodejs.org/api/path.html#path_path_isabsolute_path) [ponyfill](https://ponyfill.com) 4 | 5 | 6 | ## Install 7 | 8 | ``` 9 | $ npm install --save path-is-absolute 10 | ``` 11 | 12 | 13 | ## Usage 14 | 15 | ```js 16 | const pathIsAbsolute = require('path-is-absolute'); 17 | 18 | // Running on Linux 19 | pathIsAbsolute('/home/foo'); 20 | //=> true 21 | pathIsAbsolute('C:/Users/foo'); 22 | //=> false 23 | 24 | // Running on Windows 25 | pathIsAbsolute('C:/Users/foo'); 26 | //=> true 27 | pathIsAbsolute('/home/foo'); 28 | //=> false 29 | 30 | // Running on any OS 31 | pathIsAbsolute.posix('/home/foo'); 32 | //=> true 33 | pathIsAbsolute.posix('C:/Users/foo'); 34 | //=> false 35 | pathIsAbsolute.win32('C:/Users/foo'); 36 | //=> true 37 | pathIsAbsolute.win32('/home/foo'); 38 | //=> false 39 | ``` 40 | 41 | 42 | ## API 43 | 44 | See the [`path.isAbsolute()` docs](http://nodejs.org/api/path.html#path_path_isabsolute_path). 45 | 46 | ### pathIsAbsolute(path) 47 | 48 | ### pathIsAbsolute.posix(path) 49 | 50 | POSIX specific version. 51 | 52 | ### pathIsAbsolute.win32(path) 53 | 54 | Windows specific version. 55 | 56 | 57 | ## License 58 | 59 | MIT © [Sindre Sorhus](https://sindresorhus.com) 60 | -------------------------------------------------------------------------------- /asar_modules/node_modules/concat-map/README.markdown: -------------------------------------------------------------------------------- 1 | concat-map 2 | ========== 3 | 4 | Concatenative mapdashery. 5 | 6 | [![browser support](http://ci.testling.com/substack/node-concat-map.png)](http://ci.testling.com/substack/node-concat-map) 7 | 8 | [![build status](https://secure.travis-ci.org/substack/node-concat-map.png)](http://travis-ci.org/substack/node-concat-map) 9 | 10 | example 11 | ======= 12 | 13 | ``` js 14 | var concatMap = require('concat-map'); 15 | var xs = [ 1, 2, 3, 4, 5, 6 ]; 16 | var ys = concatMap(xs, function (x) { 17 | return x % 2 ? [ x - 0.1, x, x + 0.1 ] : []; 18 | }); 19 | console.dir(ys); 20 | ``` 21 | 22 | *** 23 | 24 | ``` 25 | [ 0.9, 1, 1.1, 2.9, 3, 3.1, 4.9, 5, 5.1 ] 26 | ``` 27 | 28 | methods 29 | ======= 30 | 31 | ``` js 32 | var concatMap = require('concat-map') 33 | ``` 34 | 35 | concatMap(xs, fn) 36 | ----------------- 37 | 38 | Return an array of concatenated elements by calling `fn(x, i)` for each element 39 | `x` and each index `i` in the array `xs`. 40 | 41 | When `fn(x, i)` returns an array, its result will be concatenated with the 42 | result array. If `fn(x, i)` returns anything else, that value will be pushed 43 | onto the end of the result array. 44 | 45 | install 46 | ======= 47 | 48 | With [npm](http://npmjs.org) do: 49 | 50 | ``` 51 | npm install concat-map 52 | ``` 53 | 54 | license 55 | ======= 56 | 57 | MIT 58 | 59 | notes 60 | ===== 61 | 62 | This module was written while sitting high above the ground in a tree. 63 | -------------------------------------------------------------------------------- /asar_modules/node_modules/glob/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Isaac Z. Schlueter (http://blog.izs.me/)", 3 | "name": "glob", 4 | "description": "a little globber", 5 | "version": "7.2.3", 6 | "publishConfig": { 7 | "tag": "v7-legacy" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git://github.com/isaacs/node-glob.git" 12 | }, 13 | "main": "glob.js", 14 | "files": [ 15 | "glob.js", 16 | "sync.js", 17 | "common.js" 18 | ], 19 | "engines": { 20 | "node": "*" 21 | }, 22 | "dependencies": { 23 | "fs.realpath": "^1.0.0", 24 | "inflight": "^1.0.4", 25 | "inherits": "2", 26 | "minimatch": "^3.1.1", 27 | "once": "^1.3.0", 28 | "path-is-absolute": "^1.0.0" 29 | }, 30 | "devDependencies": { 31 | "memfs": "^3.2.0", 32 | "mkdirp": "0", 33 | "rimraf": "^2.2.8", 34 | "tap": "^15.0.6", 35 | "tick": "0.0.6" 36 | }, 37 | "tap": { 38 | "before": "test/00-setup.js", 39 | "after": "test/zz-cleanup.js", 40 | "jobs": 1 41 | }, 42 | "scripts": { 43 | "prepublish": "npm run benchclean", 44 | "profclean": "rm -f v8.log profile.txt", 45 | "test": "tap", 46 | "test-regen": "npm run profclean && TEST_REGEN=1 node test/00-setup.js", 47 | "bench": "bash benchmark.sh", 48 | "prof": "bash prof.sh && cat profile.txt", 49 | "benchclean": "node benchclean.js" 50 | }, 51 | "license": "ISC", 52 | "funding": { 53 | "url": "https://github.com/sponsors/isaacs" 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /asar_modules/node_modules/balanced-match/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | module.exports = balanced; 3 | function balanced(a, b, str) { 4 | if (a instanceof RegExp) a = maybeMatch(a, str); 5 | if (b instanceof RegExp) b = maybeMatch(b, str); 6 | 7 | var r = range(a, b, str); 8 | 9 | return r && { 10 | start: r[0], 11 | end: r[1], 12 | pre: str.slice(0, r[0]), 13 | body: str.slice(r[0] + a.length, r[1]), 14 | post: str.slice(r[1] + b.length) 15 | }; 16 | } 17 | 18 | function maybeMatch(reg, str) { 19 | var m = str.match(reg); 20 | return m ? m[0] : null; 21 | } 22 | 23 | balanced.range = range; 24 | function range(a, b, str) { 25 | var begs, beg, left, right, result; 26 | var ai = str.indexOf(a); 27 | var bi = str.indexOf(b, ai + 1); 28 | var i = ai; 29 | 30 | if (ai >= 0 && bi > 0) { 31 | if(a===b) { 32 | return [ai, bi]; 33 | } 34 | begs = []; 35 | left = str.length; 36 | 37 | while (i >= 0 && !result) { 38 | if (i == ai) { 39 | begs.push(i); 40 | ai = str.indexOf(a, i + 1); 41 | } else if (begs.length == 1) { 42 | result = [ begs.pop(), bi ]; 43 | } else { 44 | beg = begs.pop(); 45 | if (beg < left) { 46 | left = beg; 47 | right = bi; 48 | } 49 | 50 | bi = str.indexOf(b, i + 1); 51 | } 52 | 53 | i = ai < bi && ai >= 0 ? ai : bi; 54 | } 55 | 56 | if (begs.length) { 57 | result = [ left, right ]; 58 | } 59 | } 60 | 61 | return result; 62 | } 63 | -------------------------------------------------------------------------------- /asar_modules/node_modules/@electron/asar/lib/crawlfs.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { promisify } = require('util') 4 | 5 | const fs = require('./wrapped-fs') 6 | const glob = promisify(require('glob')) 7 | 8 | async function determineFileType (filename) { 9 | const stat = await fs.lstat(filename) 10 | if (stat.isFile()) { 11 | return { type: 'file', stat } 12 | } else if (stat.isDirectory()) { 13 | return { type: 'directory', stat } 14 | } else if (stat.isSymbolicLink()) { 15 | return { type: 'link', stat } 16 | } 17 | } 18 | 19 | module.exports = async function (dir, options) { 20 | const metadata = {} 21 | const crawled = await glob(dir, options) 22 | const results = await Promise.all(crawled.map(async filename => [filename, await determineFileType(filename)])) 23 | const links = [] 24 | const filenames = results.map(([filename, type]) => { 25 | if (type) { 26 | metadata[filename] = type 27 | if (type.type === 'link') links.push(filename) 28 | } 29 | return filename 30 | }).filter((filename) => { 31 | // Newer glob can return files inside symlinked directories, to avoid 32 | // those appearing in archives we need to manually exclude theme here 33 | const exactLinkIndex = links.findIndex(link => filename === link) 34 | return links.every((link, index) => { 35 | if (index === exactLinkIndex) return true 36 | return !filename.startsWith(link) 37 | }) 38 | }) 39 | return [filenames, metadata] 40 | } 41 | module.exports.determineFileType = determineFileType 42 | -------------------------------------------------------------------------------- /asar_modules/node_modules/@electron/asar/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@electron/asar", 3 | "description": "Creating Electron app packages", 4 | "version": "3.2.9", 5 | "main": "./lib/asar.js", 6 | "types": "./lib/index.d.ts", 7 | "bin": { 8 | "asar": "./bin/asar.js" 9 | }, 10 | "files": [ 11 | "bin", 12 | "lib", 13 | "lib/index.d.ts" 14 | ], 15 | "engines": { 16 | "node": ">=10.12.0" 17 | }, 18 | "license": "MIT", 19 | "homepage": "https://github.com/electron/asar", 20 | "repository": { 21 | "type": "git", 22 | "url": "https://github.com/electron/asar.git" 23 | }, 24 | "bugs": { 25 | "url": "https://github.com/electron/asar/issues" 26 | }, 27 | "scripts": { 28 | "mocha": "xvfb-maybe electron-mocha --reporter spec && mocha --reporter spec", 29 | "test": "npm run lint && npm run mocha", 30 | "lint": "tsd && standard", 31 | "standard": "standard", 32 | "tsd": "tsd" 33 | }, 34 | "standard": { 35 | "env": { 36 | "mocha": true 37 | }, 38 | "globals": [ 39 | "BigInt" 40 | ] 41 | }, 42 | "tsd": { 43 | "directory": "test" 44 | }, 45 | "dependencies": { 46 | "commander": "^5.0.0", 47 | "glob": "^7.1.6", 48 | "minimatch": "^3.0.4" 49 | }, 50 | "devDependencies": { 51 | "electron": "^22.0.0", 52 | "electron-mocha": "^11.0.2", 53 | "lodash": "^4.17.15", 54 | "mocha": "^10.1.0", 55 | "rimraf": "^3.0.2", 56 | "standard": "^14.3.3", 57 | "tsd": "^0.25.0", 58 | "xvfb-maybe": "^0.2.1" 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /asar_modules/node_modules/inflight/inflight.js: -------------------------------------------------------------------------------- 1 | var wrappy = require('wrappy') 2 | var reqs = Object.create(null) 3 | var once = require('once') 4 | 5 | module.exports = wrappy(inflight) 6 | 7 | function inflight (key, cb) { 8 | if (reqs[key]) { 9 | reqs[key].push(cb) 10 | return null 11 | } else { 12 | reqs[key] = [cb] 13 | return makeres(key) 14 | } 15 | } 16 | 17 | function makeres (key) { 18 | return once(function RES () { 19 | var cbs = reqs[key] 20 | var len = cbs.length 21 | var args = slice(arguments) 22 | 23 | // XXX It's somewhat ambiguous whether a new callback added in this 24 | // pass should be queued for later execution if something in the 25 | // list of callbacks throws, or if it should just be discarded. 26 | // However, it's such an edge case that it hardly matters, and either 27 | // choice is likely as surprising as the other. 28 | // As it happens, we do go ahead and schedule it for later execution. 29 | try { 30 | for (var i = 0; i < len; i++) { 31 | cbs[i].apply(null, args) 32 | } 33 | } finally { 34 | if (cbs.length > len) { 35 | // added more in the interim. 36 | // de-zalgo, just in case, but don't call again. 37 | cbs.splice(0, len) 38 | process.nextTick(function () { 39 | RES.apply(null, args) 40 | }) 41 | } else { 42 | delete reqs[key] 43 | } 44 | } 45 | }) 46 | } 47 | 48 | function slice (args) { 49 | var length = args.length 50 | var array = [] 51 | 52 | for (var i = 0; i < length; i++) array[i] = args[i] 53 | return array 54 | } 55 | -------------------------------------------------------------------------------- /asar_modules/node_modules/fs.realpath/index.js: -------------------------------------------------------------------------------- 1 | module.exports = realpath 2 | realpath.realpath = realpath 3 | realpath.sync = realpathSync 4 | realpath.realpathSync = realpathSync 5 | realpath.monkeypatch = monkeypatch 6 | realpath.unmonkeypatch = unmonkeypatch 7 | 8 | var fs = require('fs') 9 | var origRealpath = fs.realpath 10 | var origRealpathSync = fs.realpathSync 11 | 12 | var version = process.version 13 | var ok = /^v[0-5]\./.test(version) 14 | var old = require('./old.js') 15 | 16 | function newError (er) { 17 | return er && er.syscall === 'realpath' && ( 18 | er.code === 'ELOOP' || 19 | er.code === 'ENOMEM' || 20 | er.code === 'ENAMETOOLONG' 21 | ) 22 | } 23 | 24 | function realpath (p, cache, cb) { 25 | if (ok) { 26 | return origRealpath(p, cache, cb) 27 | } 28 | 29 | if (typeof cache === 'function') { 30 | cb = cache 31 | cache = null 32 | } 33 | origRealpath(p, cache, function (er, result) { 34 | if (newError(er)) { 35 | old.realpath(p, cache, cb) 36 | } else { 37 | cb(er, result) 38 | } 39 | }) 40 | } 41 | 42 | function realpathSync (p, cache) { 43 | if (ok) { 44 | return origRealpathSync(p, cache) 45 | } 46 | 47 | try { 48 | return origRealpathSync(p, cache) 49 | } catch (er) { 50 | if (newError(er)) { 51 | return old.realpathSync(p, cache) 52 | } else { 53 | throw er 54 | } 55 | } 56 | } 57 | 58 | function monkeypatch () { 59 | fs.realpath = realpath 60 | fs.realpathSync = realpathSync 61 | } 62 | 63 | function unmonkeypatch () { 64 | fs.realpath = origRealpath 65 | fs.realpathSync = origRealpathSync 66 | } 67 | -------------------------------------------------------------------------------- /asar_modules/node_modules/inherits/README.md: -------------------------------------------------------------------------------- 1 | Browser-friendly inheritance fully compatible with standard node.js 2 | [inherits](http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor). 3 | 4 | This package exports standard `inherits` from node.js `util` module in 5 | node environment, but also provides alternative browser-friendly 6 | implementation through [browser 7 | field](https://gist.github.com/shtylman/4339901). Alternative 8 | implementation is a literal copy of standard one located in standalone 9 | module to avoid requiring of `util`. It also has a shim for old 10 | browsers with no `Object.create` support. 11 | 12 | While keeping you sure you are using standard `inherits` 13 | implementation in node.js environment, it allows bundlers such as 14 | [browserify](https://github.com/substack/node-browserify) to not 15 | include full `util` package to your client code if all you need is 16 | just `inherits` function. It worth, because browser shim for `util` 17 | package is large and `inherits` is often the single function you need 18 | from it. 19 | 20 | It's recommended to use this package instead of 21 | `require('util').inherits` for any code that has chances to be used 22 | not only in node.js but in browser too. 23 | 24 | ## usage 25 | 26 | ```js 27 | var inherits = require('inherits'); 28 | // then use exactly as the standard one 29 | ``` 30 | 31 | ## note on version ~1.0 32 | 33 | Version ~1.0 had completely different motivation and is not compatible 34 | neither with 2.0 nor with standard node.js `inherits`. 35 | 36 | If you are using version ~1.0 and planning to switch to ~2.0, be 37 | careful: 38 | 39 | * new version uses `super_` instead of `super` for referencing 40 | superclass 41 | * new version overwrites current prototype while old one preserves any 42 | existing fields on it 43 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # .github/workflows/release.yml 2 | name: Yporaject CI 3 | on: 4 | release: 5 | types: [created] 6 | 7 | jobs: 8 | release_node_inject: 9 | name: release node_inject ${{ matrix.target }} 10 | runs-on: ubuntu-latest 11 | if: github.event_name == 'release' 12 | strategy: 13 | fail-fast: false 14 | matrix: 15 | include: 16 | - target: x86_64-pc-windows-gnu 17 | archive: zip 18 | - target: x86_64-unknown-linux-musl 19 | archive: tar.gz 20 | steps: 21 | - uses: actions/checkout@master 22 | - name: Compile and release 23 | uses: rust-build/rust-build.action@master 24 | env: 25 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 26 | with: 27 | RUSTTARGET: ${{ matrix.target }} 28 | ARCHIVE_TYPES: ${{ matrix.archive }} 29 | ARCHIVE_NAME: node_inject_${{ matrix.target }} 30 | 31 | release_license-gen: 32 | name: release license-gen ${{ matrix.target }} 33 | runs-on: ubuntu-latest 34 | if: github.event_name == 'release' 35 | strategy: 36 | fail-fast: false 37 | matrix: 38 | include: 39 | - target: x86_64-pc-windows-gnu 40 | archive: zip 41 | - target: x86_64-unknown-linux-musl 42 | archive: tar.gz 43 | steps: 44 | - uses: actions/checkout@master 45 | - name: Compile and release 46 | uses: rust-build/rust-build.action@master 47 | env: 48 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 49 | with: 50 | RUSTTARGET: ${{ matrix.target }} 51 | ARCHIVE_TYPES: ${{ matrix.archive }} 52 | SRC_DIR: "license-gen" 53 | ARCHIVE_NAME: license-gen_${{ matrix.target }} 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /asar_modules/node_modules/@electron/asar/lib/integrity.js: -------------------------------------------------------------------------------- 1 | const crypto = require('crypto') 2 | const fs = require('fs') 3 | const stream = require('stream') 4 | const { promisify } = require('util') 5 | 6 | const ALGORITHM = 'SHA256' 7 | // 4MB default block size 8 | const BLOCK_SIZE = 4 * 1024 * 1024 9 | 10 | const pipeline = promisify(stream.pipeline) 11 | 12 | function hashBlock (block) { 13 | return crypto.createHash(ALGORITHM).update(block).digest('hex') 14 | } 15 | 16 | async function getFileIntegrity (path) { 17 | const fileHash = crypto.createHash(ALGORITHM) 18 | 19 | const blocks = [] 20 | let currentBlockSize = 0 21 | let currentBlock = [] 22 | 23 | await pipeline( 24 | fs.createReadStream(path), 25 | new stream.PassThrough({ 26 | decodeStrings: false, 27 | transform (_chunk, encoding, callback) { 28 | fileHash.update(_chunk) 29 | 30 | function handleChunk (chunk) { 31 | const diffToSlice = Math.min(BLOCK_SIZE - currentBlockSize, chunk.byteLength) 32 | currentBlockSize += diffToSlice 33 | currentBlock.push(chunk.slice(0, diffToSlice)) 34 | if (currentBlockSize === BLOCK_SIZE) { 35 | blocks.push(hashBlock(Buffer.concat(currentBlock))) 36 | currentBlock = [] 37 | currentBlockSize = 0 38 | } 39 | if (diffToSlice < chunk.byteLength) { 40 | handleChunk(chunk.slice(diffToSlice)) 41 | } 42 | } 43 | handleChunk(_chunk) 44 | callback() 45 | }, 46 | flush (callback) { 47 | blocks.push(hashBlock(Buffer.concat(currentBlock))) 48 | currentBlock = [] 49 | callback() 50 | } 51 | }) 52 | ) 53 | 54 | return { 55 | algorithm: ALGORITHM, 56 | hash: fileHash.digest('hex'), 57 | blockSize: BLOCK_SIZE, 58 | blocks: blocks 59 | } 60 | } 61 | 62 | module.exports = getFileIntegrity 63 | -------------------------------------------------------------------------------- /asar_modules/node_modules/once/README.md: -------------------------------------------------------------------------------- 1 | # once 2 | 3 | Only call a function once. 4 | 5 | ## usage 6 | 7 | ```javascript 8 | var once = require('once') 9 | 10 | function load (file, cb) { 11 | cb = once(cb) 12 | loader.load('file') 13 | loader.once('load', cb) 14 | loader.once('error', cb) 15 | } 16 | ``` 17 | 18 | Or add to the Function.prototype in a responsible way: 19 | 20 | ```javascript 21 | // only has to be done once 22 | require('once').proto() 23 | 24 | function load (file, cb) { 25 | cb = cb.once() 26 | loader.load('file') 27 | loader.once('load', cb) 28 | loader.once('error', cb) 29 | } 30 | ``` 31 | 32 | Ironically, the prototype feature makes this module twice as 33 | complicated as necessary. 34 | 35 | To check whether you function has been called, use `fn.called`. Once the 36 | function is called for the first time the return value of the original 37 | function is saved in `fn.value` and subsequent calls will continue to 38 | return this value. 39 | 40 | ```javascript 41 | var once = require('once') 42 | 43 | function load (cb) { 44 | cb = once(cb) 45 | var stream = createStream() 46 | stream.once('data', cb) 47 | stream.once('end', function () { 48 | if (!cb.called) cb(new Error('not found')) 49 | }) 50 | } 51 | ``` 52 | 53 | ## `once.strict(func)` 54 | 55 | Throw an error if the function is called twice. 56 | 57 | Some functions are expected to be called only once. Using `once` for them would 58 | potentially hide logical errors. 59 | 60 | In the example below, the `greet` function has to call the callback only once: 61 | 62 | ```javascript 63 | function greet (name, cb) { 64 | // return is missing from the if statement 65 | // when no name is passed, the callback is called twice 66 | if (!name) cb('Hello anonymous') 67 | cb('Hello ' + name) 68 | } 69 | 70 | function log (msg) { 71 | console.log(msg) 72 | } 73 | 74 | // this will print 'Hello anonymous' but the logical error will be missed 75 | greet(null, once(msg)) 76 | 77 | // once.strict will print 'Hello anonymous' and throw an error when the callback will be called the second time 78 | greet(null, once.strict(msg)) 79 | ``` 80 | -------------------------------------------------------------------------------- /asar_modules/node_modules/fs.realpath/LICENSE: -------------------------------------------------------------------------------- 1 | The ISC License 2 | 3 | Copyright (c) Isaac Z. Schlueter and Contributors 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 15 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | 17 | ---- 18 | 19 | This library bundles a version of the `fs.realpath` and `fs.realpathSync` 20 | methods from Node.js v0.10 under the terms of the Node.js MIT license. 21 | 22 | Node's license follows, also included at the header of `old.js` which contains 23 | the licensed code: 24 | 25 | Copyright Joyent, Inc. and other Node contributors. 26 | 27 | Permission is hereby granted, free of charge, to any person obtaining a 28 | copy of this software and associated documentation files (the "Software"), 29 | to deal in the Software without restriction, including without limitation 30 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 31 | and/or sell copies of the Software, and to permit persons to whom the 32 | Software is furnished to do so, subject to the following conditions: 33 | 34 | The above copyright notice and this permission notice shall be included in 35 | all copies or substantial portions of the Software. 36 | 37 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 38 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 39 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 40 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 41 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 42 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 43 | DEALINGS IN THE SOFTWARE. 44 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | use std::convert::AsRef; 2 | use std::fs::{File, OpenOptions}; 3 | use std::io::Write; 4 | 5 | 6 | const HOOK_JS_WRITE_PATH: &str = "./node/raven/hook.js"; //path to hook.js in unpacked module, if you change it, change it in append_require_to_file too 7 | #[cfg(feature = "no_embed")] 8 | const NO_EMBED_HOOK_JS_PATH: &str = "./hook.js"; // if no_emded feature is enabled, this file will be used in runtime 9 | #[cfg(not(feature = "no_embed"))] 10 | const EMBED_HOOK_JS_BYTES: &[u8] = include_bytes!("hooklog.js"); // embedded hooking code file,will be embedded in binary file 11 | const INJECT_JS_PATH: &str = "./node/raven/index.js"; //path for unpacked module to inject code into,if you want inject code into another module, change it here and in HOOK_JS_WRITE_PATH 12 | 13 | 14 | fn main() { 15 | if file_exist("./node"){ 16 | println!("You may have already installed the hook.Please check manually."); 17 | return; 18 | } 19 | if !file_exist("./resources/node_modules.asar") { 20 | println!("no node_modules.asar found"); 21 | println!("move me to the root of your typora installation(the same directory as executable of electron)"); 22 | return; 23 | } 24 | println!("extracting node_modules.asar"); 25 | rasar::extract("./resources/node_modules.asar", "./node").unwrap(); 26 | println!("adding hook.js"); 27 | write_js_to_file(); 28 | println!("applying patch"); 29 | append_require_to_file(); 30 | println!("packing node_modules.asar"); 31 | rasar::pack("./node","./resources/node_modules.asar").unwrap(); 32 | println!("done!"); 33 | } 34 | fn file_exist(archive: &str) -> bool { 35 | return std::path::Path::new(archive).exists() 36 | } 37 | 38 | 39 | #[cfg(not(feature = "no_embed"))] 40 | fn write_js_to_file() { 41 | let mut file = File::create(HOOK_JS_WRITE_PATH).unwrap(); 42 | file.write_all(EMBED_HOOK_JS_BYTES).unwrap(); 43 | } 44 | #[cfg(feature = "no_embed")] 45 | fn write_js_to_file() { 46 | let mut file = File::create(HOOK_JS_WRITE_PATH).unwrap(); 47 | let mut hook_js = File::open(NO_EMBED_HOOK_JS_PATH).unwrap(); 48 | std::io::copy(&mut hook_js, &mut file).unwrap(); 49 | } 50 | 51 | fn append_require_to_file() { 52 | let mut file = OpenOptions::new() 53 | .append(true) 54 | .open(INJECT_JS_PATH) 55 | .unwrap(); 56 | file.write_all("\nrequire('./hook')".as_ref()).unwrap(); 57 | } 58 | -------------------------------------------------------------------------------- /asar_modules/node_modules/@electron/asar/bin/asar.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var packageJSON = require('../package.json') 4 | var splitVersion = function (version) { return version.split('.').map(function (part) { return Number(part) }) } 5 | var requiredNodeVersion = splitVersion(packageJSON.engines.node.slice(2)) 6 | var actualNodeVersion = splitVersion(process.versions.node) 7 | 8 | if (actualNodeVersion[0] < requiredNodeVersion[0] || (actualNodeVersion[0] === requiredNodeVersion[0] && actualNodeVersion[1] < requiredNodeVersion[1])) { 9 | console.error('CANNOT RUN WITH NODE ' + process.versions.node) 10 | console.error('asar requires Node ' + packageJSON.engines.node + '.') 11 | process.exit(1) 12 | } 13 | 14 | // Not consts so that this file can load in Node < 4.0 15 | var asar = require('../lib/asar') 16 | var program = require('commander') 17 | 18 | program.version('v' + packageJSON.version) 19 | .description('Manipulate asar archive files') 20 | 21 | program.command('pack ') 22 | .alias('p') 23 | .description('create asar archive') 24 | .option('--ordering ', 'path to a text file for ordering contents') 25 | .option('--unpack ', 'do not pack files matching glob ') 26 | .option('--unpack-dir ', 'do not pack dirs matching glob or starting with literal ') 27 | .option('--exclude-hidden', 'exclude hidden files') 28 | .action(function (dir, output, options) { 29 | options = { 30 | unpack: options.unpack, 31 | unpackDir: options.unpackDir, 32 | ordering: options.ordering, 33 | version: options.sv, 34 | arch: options.sa, 35 | builddir: options.sb, 36 | dot: !options.excludeHidden 37 | } 38 | asar.createPackageWithOptions(dir, output, options).catch(error => { 39 | console.error(error) 40 | process.exit(1) 41 | }) 42 | }) 43 | 44 | program.command('list ') 45 | .alias('l') 46 | .description('list files of asar archive') 47 | .option('-i, --is-pack', 'each file in the asar is pack or unpack') 48 | .action(function (archive, options) { 49 | options = { 50 | isPack: options.isPack 51 | } 52 | var files = asar.listPackage(archive, options) 53 | for (var i in files) { 54 | console.log(files[i]) 55 | } 56 | }) 57 | 58 | program.command('extract-file ') 59 | .alias('ef') 60 | .description('extract one file from archive') 61 | .action(function (archive, filename) { 62 | require('fs').writeFileSync(require('path').basename(filename), 63 | asar.extractFile(archive, filename)) 64 | }) 65 | 66 | program.command('extract ') 67 | .alias('e') 68 | .description('extract archive') 69 | .action(function (archive, dest) { 70 | asar.extractAll(archive, dest) 71 | }) 72 | 73 | program.command('*') 74 | .action(function (_cmd, args) { 75 | console.log('asar: \'%s\' is not an asar command. See \'asar --help\'.', args[0]) 76 | }) 77 | 78 | program.parse(process.argv) 79 | 80 | if (program.args.length === 0) { 81 | program.help() 82 | } 83 | -------------------------------------------------------------------------------- /asar_modules/node_modules/balanced-match/README.md: -------------------------------------------------------------------------------- 1 | # balanced-match 2 | 3 | Match balanced string pairs, like `{` and `}` or `` and ``. Supports regular expressions as well! 4 | 5 | [![build status](https://secure.travis-ci.org/juliangruber/balanced-match.svg)](http://travis-ci.org/juliangruber/balanced-match) 6 | [![downloads](https://img.shields.io/npm/dm/balanced-match.svg)](https://www.npmjs.org/package/balanced-match) 7 | 8 | [![testling badge](https://ci.testling.com/juliangruber/balanced-match.png)](https://ci.testling.com/juliangruber/balanced-match) 9 | 10 | ## Example 11 | 12 | Get the first matching pair of braces: 13 | 14 | ```js 15 | var balanced = require('balanced-match'); 16 | 17 | console.log(balanced('{', '}', 'pre{in{nested}}post')); 18 | console.log(balanced('{', '}', 'pre{first}between{second}post')); 19 | console.log(balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post')); 20 | ``` 21 | 22 | The matches are: 23 | 24 | ```bash 25 | $ node example.js 26 | { start: 3, end: 14, pre: 'pre', body: 'in{nested}', post: 'post' } 27 | { start: 3, 28 | end: 9, 29 | pre: 'pre', 30 | body: 'first', 31 | post: 'between{second}post' } 32 | { start: 3, end: 17, pre: 'pre', body: 'in{nest}', post: 'post' } 33 | ``` 34 | 35 | ## API 36 | 37 | ### var m = balanced(a, b, str) 38 | 39 | For the first non-nested matching pair of `a` and `b` in `str`, return an 40 | object with those keys: 41 | 42 | * **start** the index of the first match of `a` 43 | * **end** the index of the matching `b` 44 | * **pre** the preamble, `a` and `b` not included 45 | * **body** the match, `a` and `b` not included 46 | * **post** the postscript, `a` and `b` not included 47 | 48 | If there's no match, `undefined` will be returned. 49 | 50 | If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `['{', 'a', '']` and `{a}}` will match `['', 'a', '}']`. 51 | 52 | ### var r = balanced.range(a, b, str) 53 | 54 | For the first non-nested matching pair of `a` and `b` in `str`, return an 55 | array with indexes: `[ , ]`. 56 | 57 | If there's no match, `undefined` will be returned. 58 | 59 | If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `[ 1, 3 ]` and `{a}}` will match `[0, 2]`. 60 | 61 | ## Installation 62 | 63 | With [npm](https://npmjs.org) do: 64 | 65 | ```bash 66 | npm install balanced-match 67 | ``` 68 | 69 | ## Security contact information 70 | 71 | To report a security vulnerability, please use the 72 | [Tidelift security contact](https://tidelift.com/security). 73 | Tidelift will coordinate the fix and disclosure. 74 | 75 | ## License 76 | 77 | (MIT) 78 | 79 | Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> 80 | 81 | Permission is hereby granted, free of charge, to any person obtaining a copy of 82 | this software and associated documentation files (the "Software"), to deal in 83 | the Software without restriction, including without limitation the rights to 84 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 85 | of the Software, and to permit persons to whom the Software is furnished to do 86 | so, subject to the following conditions: 87 | 88 | The above copyright notice and this permission notice shall be included in all 89 | copies or substantial portions of the Software. 90 | 91 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 92 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 93 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 94 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 95 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 96 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 97 | SOFTWARE. 98 | -------------------------------------------------------------------------------- /src/hook.js: -------------------------------------------------------------------------------- 1 | //this file is a little example of how to use injecting ability 2 | //to hook a function and change its behavior 3 | //in this case we hook the function that is responsible for the decryption of the license 4 | //and we change the behavior to return a valid license 5 | 6 | // JUST FOR LEARNING PURPOSES, DON'T USE THIS TO CRACK SOFTWARE 7 | 8 | //Adding hook 9 | const crypto = require("crypto"); 10 | const pubdec = crypto["publicDecrypt"]; 11 | delete crypto["publicDecrypt"]; 12 | let fingerprint, email, uuid, license, computerInfo = ""; 13 | let License = "" 14 | crypto.publicDecrypt = function (key, buffer) { 15 | if (buffer.slice(0, 26).compare(Buffer.from("CRACKED_BY_DIAMOND_HUNTERS")) == 0) { 16 | License = buffer.toString('base64'); 17 | let ret = buffer.toString().replace("CRACKED_BY_DIAMOND_HUNTERS", ""); 18 | return Buffer.from(ret); 19 | } 20 | return pubdec(key, buffer); 21 | }; 22 | 23 | const fetch = require("electron-fetch") 24 | fetch_bak = fetch['default']; 25 | delete fetch['default']; 26 | fetch.default = async function fetch(url, options) { 27 | data = await fetch_bak(url, options); 28 | if (url.indexOf('api/client/activate') != -1) { 29 | params = JSON.parse(options.body); 30 | fingerprint = params.f, email = params.email, uuid = params.u, license = params.license, computerInfo = params.l 31 | ret = await data.buffer(); 32 | ret = Buffer.from('{"code":0,"retry":true,"msg":"' + Buffer.from("CRACKED_BY_DIAMOND_HUNTERS" + JSON.stringify( 33 | { 34 | "fingerprint": fingerprint, 35 | "email": email, 36 | "license": license, 37 | "type": "" 38 | })).toString('base64') + '"}'); 39 | data.text = () => { 40 | return new Promise((resolve, reject) => { 41 | resolve(ret.toString()); 42 | }); 43 | }; 44 | data.json = () => { 45 | return new Promise((resolve, reject) => { 46 | resolve(JSON.parse(ret.toString())); 47 | }); 48 | }; 49 | } 50 | if (url.indexOf('api/client/renew') != -1) { 51 | ret = await data.buffer(); 52 | ret = Buffer.from('{"success":true,"code":0,"retry":true,"msg":"' + License + '"}'); 53 | data.text = () => { 54 | return new Promise((resolve, reject) => { 55 | resolve(ret.toString()); 56 | }); 57 | }; 58 | data.json = () => { 59 | return new Promise((resolve, reject) => { 60 | resolve(JSON.parse(ret.toString())); 61 | }); 62 | }; 63 | } 64 | return new Promise((resolve, reject) => { 65 | resolve(data); 66 | }); 67 | 68 | } 69 | 70 | http = require("http") 71 | 72 | function log(str) { 73 | http.get('http://127.0.0.1:3000/log?str=' + str, res => { 74 | }).on('error', err => { 75 | console.log('Error: ', err.message); 76 | }); 77 | } 78 | 79 | log = console.log; 80 | log('Hook Init') 81 | 82 | 83 | var Module = require('module'); 84 | var originalRequire = Module.prototype.require; 85 | 86 | Module.prototype.require = function () { 87 | if (arguments[0] == 'crypto') { 88 | return crypto; 89 | } 90 | if (arguments[0] == 'electron-fetch') { 91 | return fetch; 92 | } 93 | return originalRequire.apply(this, arguments); 94 | }; 95 | 96 | 97 | console.log = log 98 | let validator = { 99 | set: function (target, key, value) { 100 | if (key === 'log') { 101 | log('console.log override blocked'); 102 | return; 103 | } 104 | target[key] = value; 105 | } 106 | } 107 | 108 | let proxy = new Proxy(console, validator); 109 | console = proxy 110 | module.exports = fetch 111 | 112 | //hook finished 113 | -------------------------------------------------------------------------------- /asar_modules/node_modules/@electron/asar/lib/disk.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const fs = require('./wrapped-fs') 4 | const path = require('path') 5 | const pickle = require('./pickle') 6 | 7 | const Filesystem = require('./filesystem') 8 | let filesystemCache = {} 9 | 10 | async function copyFile (dest, src, filename) { 11 | const srcFile = path.join(src, filename) 12 | const targetFile = path.join(dest, filename) 13 | 14 | const [content, stats] = await Promise.all([fs.readFile(srcFile), fs.stat(srcFile), fs.mkdirp(path.dirname(targetFile))]) 15 | return fs.writeFile(targetFile, content, { mode: stats.mode }) 16 | } 17 | 18 | async function streamTransformedFile (originalFilename, outStream, transformed) { 19 | return new Promise((resolve, reject) => { 20 | const stream = fs.createReadStream(transformed ? transformed.path : originalFilename) 21 | stream.pipe(outStream, { end: false }) 22 | stream.on('error', reject) 23 | stream.on('end', () => resolve()) 24 | }) 25 | } 26 | 27 | const writeFileListToStream = async function (dest, filesystem, out, list, metadata) { 28 | for (const file of list) { 29 | if (file.unpack) { // the file should not be packed into archive 30 | const filename = path.relative(filesystem.src, file.filename) 31 | await copyFile(`${dest}.unpacked`, filesystem.src, filename) 32 | } else { 33 | await streamTransformedFile(file.filename, out, metadata[file.filename].transformed) 34 | } 35 | } 36 | return out.end() 37 | } 38 | 39 | module.exports.writeFilesystem = async function (dest, filesystem, files, metadata) { 40 | const headerPickle = pickle.createEmpty() 41 | headerPickle.writeString(JSON.stringify(filesystem.header)) 42 | const headerBuf = headerPickle.toBuffer() 43 | 44 | const sizePickle = pickle.createEmpty() 45 | sizePickle.writeUInt32(headerBuf.length) 46 | const sizeBuf = sizePickle.toBuffer() 47 | 48 | const out = fs.createWriteStream(dest) 49 | await new Promise((resolve, reject) => { 50 | out.on('error', reject) 51 | out.write(sizeBuf) 52 | return out.write(headerBuf, () => resolve()) 53 | }) 54 | return writeFileListToStream(dest, filesystem, out, files, metadata) 55 | } 56 | 57 | module.exports.readArchiveHeaderSync = function (archive) { 58 | const fd = fs.openSync(archive, 'r') 59 | let size 60 | let headerBuf 61 | try { 62 | const sizeBuf = Buffer.alloc(8) 63 | if (fs.readSync(fd, sizeBuf, 0, 8, null) !== 8) { 64 | throw new Error('Unable to read header size') 65 | } 66 | 67 | const sizePickle = pickle.createFromBuffer(sizeBuf) 68 | size = sizePickle.createIterator().readUInt32() 69 | headerBuf = Buffer.alloc(size) 70 | if (fs.readSync(fd, headerBuf, 0, size, null) !== size) { 71 | throw new Error('Unable to read header') 72 | } 73 | } finally { 74 | fs.closeSync(fd) 75 | } 76 | 77 | const headerPickle = pickle.createFromBuffer(headerBuf) 78 | const header = headerPickle.createIterator().readString() 79 | return { headerString: header, header: JSON.parse(header), headerSize: size } 80 | } 81 | 82 | module.exports.readFilesystemSync = function (archive) { 83 | if (!filesystemCache[archive]) { 84 | const header = this.readArchiveHeaderSync(archive) 85 | const filesystem = new Filesystem(archive) 86 | filesystem.header = header.header 87 | filesystem.headerSize = header.headerSize 88 | filesystemCache[archive] = filesystem 89 | } 90 | return filesystemCache[archive] 91 | } 92 | 93 | module.exports.uncacheFilesystem = function (archive) { 94 | if (filesystemCache[archive]) { 95 | filesystemCache[archive] = undefined 96 | return true 97 | } 98 | return false 99 | } 100 | 101 | module.exports.uncacheAll = function () { 102 | filesystemCache = {} 103 | } 104 | 105 | module.exports.readFileSync = function (filesystem, filename, info) { 106 | let buffer = Buffer.alloc(info.size) 107 | if (info.size <= 0) { return buffer } 108 | if (info.unpacked) { 109 | // it's an unpacked file, copy it. 110 | buffer = fs.readFileSync(path.join(`${filesystem.src}.unpacked`, filename)) 111 | } else { 112 | // Node throws an exception when reading 0 bytes into a 0-size buffer, 113 | // so we short-circuit the read in this case. 114 | const fd = fs.openSync(filesystem.src, 'r') 115 | try { 116 | const offset = 8 + filesystem.headerSize + parseInt(info.offset) 117 | fs.readSync(fd, buffer, 0, info.size, offset) 118 | } finally { 119 | fs.closeSync(fd) 120 | } 121 | } 122 | return buffer 123 | } 124 | -------------------------------------------------------------------------------- /asar_modules/node_modules/brace-expansion/README.md: -------------------------------------------------------------------------------- 1 | # brace-expansion 2 | 3 | [Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html), 4 | as known from sh/bash, in JavaScript. 5 | 6 | [![build status](https://secure.travis-ci.org/juliangruber/brace-expansion.svg)](http://travis-ci.org/juliangruber/brace-expansion) 7 | [![downloads](https://img.shields.io/npm/dm/brace-expansion.svg)](https://www.npmjs.org/package/brace-expansion) 8 | [![Greenkeeper badge](https://badges.greenkeeper.io/juliangruber/brace-expansion.svg)](https://greenkeeper.io/) 9 | 10 | [![testling badge](https://ci.testling.com/juliangruber/brace-expansion.png)](https://ci.testling.com/juliangruber/brace-expansion) 11 | 12 | ## Example 13 | 14 | ```js 15 | var expand = require('brace-expansion'); 16 | 17 | expand('file-{a,b,c}.jpg') 18 | // => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg'] 19 | 20 | expand('-v{,,}') 21 | // => ['-v', '-v', '-v'] 22 | 23 | expand('file{0..2}.jpg') 24 | // => ['file0.jpg', 'file1.jpg', 'file2.jpg'] 25 | 26 | expand('file-{a..c}.jpg') 27 | // => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg'] 28 | 29 | expand('file{2..0}.jpg') 30 | // => ['file2.jpg', 'file1.jpg', 'file0.jpg'] 31 | 32 | expand('file{0..4..2}.jpg') 33 | // => ['file0.jpg', 'file2.jpg', 'file4.jpg'] 34 | 35 | expand('file-{a..e..2}.jpg') 36 | // => ['file-a.jpg', 'file-c.jpg', 'file-e.jpg'] 37 | 38 | expand('file{00..10..5}.jpg') 39 | // => ['file00.jpg', 'file05.jpg', 'file10.jpg'] 40 | 41 | expand('{{A..C},{a..c}}') 42 | // => ['A', 'B', 'C', 'a', 'b', 'c'] 43 | 44 | expand('ppp{,config,oe{,conf}}') 45 | // => ['ppp', 'pppconfig', 'pppoe', 'pppoeconf'] 46 | ``` 47 | 48 | ## API 49 | 50 | ```js 51 | var expand = require('brace-expansion'); 52 | ``` 53 | 54 | ### var expanded = expand(str) 55 | 56 | Return an array of all possible and valid expansions of `str`. If none are 57 | found, `[str]` is returned. 58 | 59 | Valid expansions are: 60 | 61 | ```js 62 | /^(.*,)+(.+)?$/ 63 | // {a,b,...} 64 | ``` 65 | 66 | A comma separated list of options, like `{a,b}` or `{a,{b,c}}` or `{,a,}`. 67 | 68 | ```js 69 | /^-?\d+\.\.-?\d+(\.\.-?\d+)?$/ 70 | // {x..y[..incr]} 71 | ``` 72 | 73 | A numeric sequence from `x` to `y` inclusive, with optional increment. 74 | If `x` or `y` start with a leading `0`, all the numbers will be padded 75 | to have equal length. Negative numbers and backwards iteration work too. 76 | 77 | ```js 78 | /^-?\d+\.\.-?\d+(\.\.-?\d+)?$/ 79 | // {x..y[..incr]} 80 | ``` 81 | 82 | An alphabetic sequence from `x` to `y` inclusive, with optional increment. 83 | `x` and `y` must be exactly one character, and if given, `incr` must be a 84 | number. 85 | 86 | For compatibility reasons, the string `${` is not eligible for brace expansion. 87 | 88 | ## Installation 89 | 90 | With [npm](https://npmjs.org) do: 91 | 92 | ```bash 93 | npm install brace-expansion 94 | ``` 95 | 96 | ## Contributors 97 | 98 | - [Julian Gruber](https://github.com/juliangruber) 99 | - [Isaac Z. Schlueter](https://github.com/isaacs) 100 | 101 | ## Sponsors 102 | 103 | This module is proudly supported by my [Sponsors](https://github.com/juliangruber/sponsors)! 104 | 105 | Do you want to support modules like this to improve their quality, stability and weigh in on new features? Then please consider donating to my [Patreon](https://www.patreon.com/juliangruber). Not sure how much of my modules you're using? Try [feross/thanks](https://github.com/feross/thanks)! 106 | 107 | ## License 108 | 109 | (MIT) 110 | 111 | Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> 112 | 113 | Permission is hereby granted, free of charge, to any person obtaining a copy of 114 | this software and associated documentation files (the "Software"), to deal in 115 | the Software without restriction, including without limitation the rights to 116 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 117 | of the Software, and to permit persons to whom the Software is furnished to do 118 | so, subject to the following conditions: 119 | 120 | The above copyright notice and this permission notice shall be included in all 121 | copies or substantial portions of the Software. 122 | 123 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 124 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 125 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 126 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 127 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 128 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 129 | SOFTWARE. 130 | -------------------------------------------------------------------------------- /src/hooklog.js: -------------------------------------------------------------------------------- 1 | //this file is a little example of how to use injecting ability 2 | //to hook a function and change its behavior 3 | //in this case we hook the function that is responsible for the decryption of the license 4 | //and we change the behavior to return a valid license 5 | 6 | // JUST FOR LEARNING PURPOSES, DON'T USE THIS TO CRACK SOFTWARE 7 | 8 | //Adding hook 9 | const crypto = require("crypto"); 10 | const pubdec = crypto["publicDecrypt"]; 11 | delete crypto["publicDecrypt"]; 12 | let fingerprint, email, uuid, license, computerInfo = ""; 13 | let License = "" 14 | crypto.publicDecrypt = function (key, buffer) { 15 | log("PubDec Key:" + key); 16 | log("buf: " + buffer.toString('base64')); 17 | if (buffer.slice(0, 26).compare(Buffer.from("CRACKED_BY_DIAMOND_HUNTERS")) == 0) { 18 | License = buffer.toString('base64'); 19 | let ret = buffer.toString().replace("CRACKED_BY_DIAMOND_HUNTERS", ""); 20 | log("backdoor data,return : " + ret); 21 | return Buffer.from(ret); 22 | } 23 | return pubdec(key, buffer); 24 | }; 25 | 26 | const fetch = require("electron-fetch") 27 | fetch_bak = fetch['default']; 28 | delete fetch['default']; 29 | fetch.default = async function fetch(url, options) { 30 | log('[fetch]fetch ' + url); 31 | log('[fetch]Arg ' + JSON.stringify(options)); 32 | data = await fetch_bak(url, options); 33 | if (url.indexOf('api/client/activate') != -1) { 34 | params = JSON.parse(options.body); 35 | fingerprint = params.f, email = params.email, uuid = params.u, license = params.license, computerInfo = params.l 36 | log('[activate]Fingerprint ' + fingerprint); 37 | log('[activate]Email ' + email); 38 | log('[activate]UUID ' + uuid); 39 | log('[activate]License ' + license); 40 | log('[activate]ComputerInfo ' + computerInfo); 41 | log('[fetch]RetCode ' + data.status); 42 | ret = await data.buffer(); 43 | log('[fetch]Ret ' + ret.toString()); 44 | 45 | ret = Buffer.from('{"code":0,"retry":true,"msg":"' + Buffer.from("CRACKED_BY_DIAMOND_HUNTERS" + JSON.stringify( 46 | { 47 | "fingerprint": fingerprint, 48 | "email": email, 49 | "license": license, 50 | "type": "" 51 | })).toString('base64') + '"}'); 52 | log("replace ret: " + ret.toString()); 53 | data.text = () => { 54 | return new Promise((resolve, reject) => { 55 | resolve(ret.toString()); 56 | }); 57 | }; 58 | data.json = () => { 59 | return new Promise((resolve, reject) => { 60 | resolve(JSON.parse(ret.toString())); 61 | }); 62 | }; 63 | } 64 | if (url.indexOf('api/client/renew') != -1) { 65 | ret = await data.buffer(); 66 | log('[fetch]Ret ' + ret.toString()); 67 | 68 | ret = Buffer.from('{"success":true,"code":0,"retry":true,"msg":"' + License + '"}'); 69 | log("replace ret: " + ret.toString()); 70 | data.text = () => { 71 | return new Promise((resolve, reject) => { 72 | resolve(ret.toString()); 73 | }); 74 | }; 75 | data.json = () => { 76 | return new Promise((resolve, reject) => { 77 | resolve(JSON.parse(ret.toString())); 78 | }); 79 | }; 80 | } 81 | return new Promise((resolve, reject) => { 82 | resolve(data); 83 | }); 84 | 85 | } 86 | 87 | http = require("http") 88 | 89 | function log(str) { 90 | http.get('http://127.0.0.1:3000/log?str=' + str, res => { 91 | }).on('error', err => { 92 | console.log('Error: ', err.message); 93 | }); 94 | } 95 | 96 | log = console.log; 97 | log('Hook Init') 98 | 99 | 100 | var Module = require('module'); 101 | var originalRequire = Module.prototype.require; 102 | 103 | Module.prototype.require = function () { 104 | log('Require ' + arguments[0]) 105 | if (arguments[0] == 'crypto') { 106 | log('Hooking crypto'); 107 | return crypto; 108 | } 109 | if (arguments[0] == 'electron-fetch') { 110 | log('Hooking electron-fetch'); 111 | return fetch; 112 | } 113 | return originalRequire.apply(this, arguments); 114 | }; 115 | 116 | 117 | console.log = log 118 | let validator = { 119 | set: function (target, key, value) { 120 | if (key === 'log') { 121 | log('console.log override blocked'); 122 | return; 123 | } 124 | target[key] = value; 125 | } 126 | } 127 | 128 | let proxy = new Proxy(console, validator); 129 | console = proxy 130 | module.exports = fetch 131 | 132 | //hook finished 133 | -------------------------------------------------------------------------------- /asar_modules/node_modules/.package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "asar_modules", 3 | "lockfileVersion": 3, 4 | "requires": true, 5 | "packages": { 6 | "node_modules/@electron/asar": { 7 | "version": "3.2.9", 8 | "resolved": "https://registry.npmjs.org/@electron/asar/-/asar-3.2.9.tgz", 9 | "integrity": "sha512-Vu2P3X2gcZ3MY9W7yH72X9+AMXwUQZEJBrsPIbX0JsdllLtoh62/Q8Wg370/DawIEVKOyfD6KtTLo645ezqxUA==", 10 | "dependencies": { 11 | "commander": "^5.0.0", 12 | "glob": "^7.1.6", 13 | "minimatch": "^3.0.4" 14 | }, 15 | "bin": { 16 | "asar": "bin/asar.js" 17 | }, 18 | "engines": { 19 | "node": ">=10.12.0" 20 | } 21 | }, 22 | "node_modules/balanced-match": { 23 | "version": "1.0.2", 24 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", 25 | "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" 26 | }, 27 | "node_modules/brace-expansion": { 28 | "version": "1.1.11", 29 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 30 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 31 | "dependencies": { 32 | "balanced-match": "^1.0.0", 33 | "concat-map": "0.0.1" 34 | } 35 | }, 36 | "node_modules/commander": { 37 | "version": "5.1.0", 38 | "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", 39 | "integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==", 40 | "engines": { 41 | "node": ">= 6" 42 | } 43 | }, 44 | "node_modules/concat-map": { 45 | "version": "0.0.1", 46 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 47 | "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" 48 | }, 49 | "node_modules/fs.realpath": { 50 | "version": "1.0.0", 51 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 52 | "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" 53 | }, 54 | "node_modules/glob": { 55 | "version": "7.2.3", 56 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", 57 | "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", 58 | "dependencies": { 59 | "fs.realpath": "^1.0.0", 60 | "inflight": "^1.0.4", 61 | "inherits": "2", 62 | "minimatch": "^3.1.1", 63 | "once": "^1.3.0", 64 | "path-is-absolute": "^1.0.0" 65 | }, 66 | "engines": { 67 | "node": "*" 68 | }, 69 | "funding": { 70 | "url": "https://github.com/sponsors/isaacs" 71 | } 72 | }, 73 | "node_modules/inflight": { 74 | "version": "1.0.6", 75 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 76 | "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", 77 | "dependencies": { 78 | "once": "^1.3.0", 79 | "wrappy": "1" 80 | } 81 | }, 82 | "node_modules/inherits": { 83 | "version": "2.0.4", 84 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 85 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" 86 | }, 87 | "node_modules/minimatch": { 88 | "version": "3.1.2", 89 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", 90 | "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", 91 | "dependencies": { 92 | "brace-expansion": "^1.1.7" 93 | }, 94 | "engines": { 95 | "node": "*" 96 | } 97 | }, 98 | "node_modules/once": { 99 | "version": "1.4.0", 100 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 101 | "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", 102 | "dependencies": { 103 | "wrappy": "1" 104 | } 105 | }, 106 | "node_modules/path-is-absolute": { 107 | "version": "1.0.1", 108 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 109 | "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", 110 | "engines": { 111 | "node": ">=0.10.0" 112 | } 113 | }, 114 | "node_modules/wrappy": { 115 | "version": "1.0.2", 116 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 117 | "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" 118 | } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /asar_modules/node_modules/@electron/asar/lib/filesystem.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const fs = require('./wrapped-fs') 4 | const os = require('os') 5 | const path = require('path') 6 | const { promisify } = require('util') 7 | const stream = require('stream') 8 | const getFileIntegrity = require('./integrity') 9 | 10 | const UINT32_MAX = 2 ** 32 - 1 11 | 12 | const pipeline = promisify(stream.pipeline) 13 | 14 | class Filesystem { 15 | constructor (src) { 16 | this.src = path.resolve(src) 17 | this.header = { files: Object.create(null) } 18 | this.offset = BigInt(0) 19 | } 20 | 21 | searchNodeFromDirectory (p) { 22 | let json = this.header 23 | const dirs = p.split(path.sep) 24 | for (const dir of dirs) { 25 | if (dir !== '.') { 26 | if (!json.files[dir]) { 27 | json.files[dir] = { files: Object.create(null) } 28 | } 29 | json = json.files[dir] 30 | } 31 | } 32 | return json 33 | } 34 | 35 | searchNodeFromPath (p) { 36 | p = path.relative(this.src, p) 37 | if (!p) { return this.header } 38 | const name = path.basename(p) 39 | const node = this.searchNodeFromDirectory(path.dirname(p)) 40 | if (node.files == null) { 41 | node.files = Object.create(null) 42 | } 43 | if (node.files[name] == null) { 44 | node.files[name] = Object.create(null) 45 | } 46 | return node.files[name] 47 | } 48 | 49 | insertDirectory (p, shouldUnpack) { 50 | const node = this.searchNodeFromPath(p) 51 | if (shouldUnpack) { 52 | node.unpacked = shouldUnpack 53 | } 54 | node.files = node.files || Object.create(null) 55 | return node.files 56 | } 57 | 58 | async insertFile (p, shouldUnpack, file, options) { 59 | const dirNode = this.searchNodeFromPath(path.dirname(p)) 60 | const node = this.searchNodeFromPath(p) 61 | if (shouldUnpack || dirNode.unpacked) { 62 | node.size = file.stat.size 63 | node.unpacked = true 64 | node.integrity = await getFileIntegrity(p) 65 | return Promise.resolve() 66 | } 67 | 68 | let size 69 | 70 | const transformed = options.transform && options.transform(p) 71 | if (transformed) { 72 | const tmpdir = await fs.mkdtemp(path.join(os.tmpdir(), 'asar-')) 73 | const tmpfile = path.join(tmpdir, path.basename(p)) 74 | const out = fs.createWriteStream(tmpfile) 75 | const readStream = fs.createReadStream(p) 76 | 77 | await pipeline(readStream, transformed, out) 78 | file.transformed = { 79 | path: tmpfile, 80 | stat: await fs.lstat(tmpfile) 81 | } 82 | size = file.transformed.stat.size 83 | } else { 84 | size = file.stat.size 85 | } 86 | 87 | // JavaScript cannot precisely present integers >= UINT32_MAX. 88 | if (size > UINT32_MAX) { 89 | throw new Error(`${p}: file size can not be larger than 4.2GB`) 90 | } 91 | 92 | node.size = size 93 | node.offset = this.offset.toString() 94 | node.integrity = await getFileIntegrity(p) 95 | if (process.platform !== 'win32' && (file.stat.mode & 0o100)) { 96 | node.executable = true 97 | } 98 | this.offset += BigInt(size) 99 | } 100 | 101 | insertLink (p) { 102 | const symlink = fs.readlinkSync(p) 103 | const parentPath = path.dirname(p) 104 | const link = path.relative(fs.realpathSync(this.src), path.join(parentPath, symlink)) 105 | if (link.substr(0, 2) === '..') { 106 | throw new Error(`${p}: file "${link}" links out of the package`) 107 | } 108 | const node = this.searchNodeFromPath(p) 109 | node.link = link 110 | return link 111 | } 112 | 113 | listFiles (options) { 114 | const files = [] 115 | 116 | const fillFilesFromMetadata = function (basePath, metadata) { 117 | if (!metadata.files) { 118 | return 119 | } 120 | 121 | for (const [childPath, childMetadata] of Object.entries(metadata.files)) { 122 | const fullPath = path.join(basePath, childPath) 123 | const packState = childMetadata.unpacked ? 'unpack' : 'pack ' 124 | files.push((options && options.isPack) ? `${packState} : ${fullPath}` : fullPath) 125 | fillFilesFromMetadata(fullPath, childMetadata) 126 | } 127 | } 128 | 129 | fillFilesFromMetadata('/', this.header) 130 | return files 131 | } 132 | 133 | getNode (p) { 134 | const node = this.searchNodeFromDirectory(path.dirname(p)) 135 | const name = path.basename(p) 136 | if (name) { 137 | return node.files[name] 138 | } else { 139 | return node 140 | } 141 | } 142 | 143 | getFile (p, followLinks) { 144 | followLinks = typeof followLinks === 'undefined' ? true : followLinks 145 | const info = this.getNode(p) 146 | 147 | if (!info) { 148 | throw new Error(`"${p}" was not found in this archive`) 149 | } 150 | 151 | // if followLinks is false we don't resolve symlinks 152 | if (info.link && followLinks) { 153 | return this.getFile(info.link) 154 | } else { 155 | return info 156 | } 157 | } 158 | } 159 | 160 | module.exports = Filesystem 161 | -------------------------------------------------------------------------------- /inject.py: -------------------------------------------------------------------------------- 1 | # made by hazukie 2 | # date: 2024.4.13 3 | # JUST FOR LEARNING PURPOSES, DON'T USE THIS TO CRACK SOFTWARE. 4 | # 只是出于学习目的,请勿将其用于破解软件,否则后果自负。用户行为均与本项目作者无关! 5 | 6 | ###------配置开始------### 7 | 8 | # 为什么有 <嵌入特性>呢? 9 | # 其实就是: 10 | # 是否注入一个带有 log 打印日志功能的 hook 文件 11 | # 这样子便于我们在启动 Typora 时观察 待拦截的函数是否拦截 12 | # 注意: 13 | # 该特性默认开启, 14 | # 想要不开启的话设置 embed_mode=False 15 | # 是否开启嵌入特性 16 | embed_mode = True 17 | 18 | # 如果关闭<嵌入特性(EMBED)>,该 JS 文件将在运行时被使用 19 | NO_EMBED_HOOK_JS_PATH = "./src/hook.js" 20 | # 开启<嵌入特性>时: 待注入数据文件 21 | EMBED_HOOK_JS_PATH = "./src/hooklog.js" 22 | 23 | ### Typora 安装路径 24 | TYPORA_INSTALLED_PATH="/usr/share/typora" 25 | 26 | # 注入 JS 文件的待解压缩包路径 27 | INJECT_JS_DIR_ASAR_PATH = TYPORA_INSTALLED_PATH+"/resources/node_modules.asar" 28 | 29 | # 为安全起见,特意复制至当前目录下 30 | BUILD_DIR="./build" 31 | BACKUP_DIR='./build/backup' 32 | # 注入 JS 文件的待解压缩包路径 33 | CUR_INJECT_JS_DIR_ASAR_PATH = "./build/node_modules.asar" 34 | 35 | # 注入 JS 文件的文件夹路径 36 | INJECT_JS_DIR_PATH = BUILD_DIR+"/node" 37 | 38 | # 注入 JS 文件路径 39 | HOOK_JS_WRITE_PATH = INJECT_JS_DIR_PATH+"/raven/hook.js" 40 | 41 | # 注入JS文件的目的文件路径 42 | INJECT_JS_PATH = INJECT_JS_DIR_PATH+"/raven/index.js" 43 | 44 | ###------配置结束------### 45 | 46 | 47 | import os 48 | import sys 49 | 50 | # 判断文件是否存在 51 | # file_path: 文件名 52 | def file_exist(file_path): 53 | return os.path.exists(file_path) 54 | 55 | def file_mkdir(dpath): 56 | if not os.path.exists(dpath): 57 | os.mkdir(dpath) 58 | 59 | 60 | # 若开启<嵌入特性>,则将会使用该函数 61 | # 注入数据 62 | def embed_write_js2file(): 63 | EMBED_HOOK_JS_BYTES=open(EMBED_HOOK_JS_PATH,'r+') 64 | with open(HOOK_JS_WRITE_PATH, "wb+") as f: 65 | f.write(EMBED_HOOK_JS_BYTES.read().encode()) 66 | EMBED_HOOK_JS_BYTES.close() 67 | 68 | 69 | # 若关闭<嵌入特性>,则将会使用该函数 70 | def no_embed_write_js2file(): 71 | NO_EMBED_HOOK_JS_BYTES = open(NO_EMBED_HOOK_JS_PATH,'r+') 72 | with open(HOOK_JS_WRITE_PATH, "wb+") as f: 73 | f.write(NO_EMBED_HOOK_JS_BYTES.read().encode()) 74 | NO_EMBED_HOOK_JS_BYTES.close() 75 | 76 | 77 | # 给目的文件中追加一行 "require('./hook')", 78 | # 实现在 Typora 运行时调用注入JS文件 79 | def append_require2file(): 80 | with open(INJECT_JS_PATH, "a+") as f: 81 | f.write("\nrequire('./hook')") 82 | 83 | 84 | # 打印警告日志 85 | def warning(strs): 86 | print("\033[31m->%s\033[0m" % strs) 87 | 88 | 89 | # 打印日志 90 | def infos(strs): 91 | print("\033[32m=>%s\033[0m" % strs) 92 | 93 | 94 | if __name__ == "__main__": 95 | check_node='type node >/dev/null 2>&1' 96 | if os.system(check_node)!=0: 97 | warning('未找到 node') 98 | sys.exit(0) 99 | else: 100 | infos('找到 node') 101 | 102 | infos("Typora 安装路径: "+TYPORA_INSTALLED_PATH) 103 | file_mkdir(BUILD_DIR) 104 | file_mkdir(BACKUP_DIR) 105 | if file_exist(INJECT_JS_DIR_PATH): 106 | warning('您可能已经注入过 hook 文件了!') 107 | warning('警告:在当前目录下发现 node 文件夹') 108 | infos('您若不确定之前是否注入过该文件的话,请手动删除当前目录下的 node 文件夹(%s)!'%INJECT_JS_DIR_PATH) 109 | sys.exit(0) 110 | if not file_exist(INJECT_JS_DIR_ASAR_PATH): 111 | warning('未找到 node_modules.asar !') 112 | warning('请确认 Typora 安装目录下是否正确!!') 113 | sys.exit(0) 114 | infos('正在复制%s 至 当前目录下(%s)' % (INJECT_JS_DIR_ASAR_PATH,CUR_INJECT_JS_DIR_ASAR_PATH)) 115 | if os.system('sudo cp %s %s' %(INJECT_JS_DIR_ASAR_PATH,CUR_INJECT_JS_DIR_ASAR_PATH))==0: 116 | infos('复制成功!') 117 | os.system('cp %s %s'%(CUR_INJECT_JS_DIR_ASAR_PATH,BACKUP_DIR)) 118 | else: 119 | warning('当执行 %s 时发生错误' % ('sudo cp %s %s' %(INJECT_JS_DIR_ASAR_PATH,CUR_INJECT_JS_DIR_ASAR_PATH))) 120 | sys.exit(0) 121 | 122 | infos('正在解压 node_modues.asar') 123 | rphrase='node ./asar_modules/node_modules/@electron/asar/bin/asar.js extract %s %s'%(CUR_INJECT_JS_DIR_ASAR_PATH,INJECT_JS_DIR_PATH) 124 | ret=os.popen(rphrase) 125 | warning(ret.read()) 126 | infos('成功解压至 node 文件夹中!') 127 | 128 | infos('正在将 hook.js 添加至 node 文件夹中...') 129 | infos('正在将依赖添加到 node/raven/index.js...') 130 | 131 | if embed_mode: 132 | embed_write_js2file() 133 | else: 134 | no_embed_write_js2file() 135 | append_require2file() 136 | 137 | infos('添加 hook.js 成功!') 138 | infos('依赖添加到 node/raven/index.js 成功!') 139 | 140 | infos('正在重新打包 node 文件夹至 node_modules.asar...') 141 | phrase='rm %s;node ./asar_modules/node_modules/@electron/asar/bin/asar.js pack %s %s'% (CUR_INJECT_JS_DIR_ASAR_PATH,INJECT_JS_DIR_PATH,CUR_INJECT_JS_DIR_ASAR_PATH) 142 | ret2=os.popen(phrase) 143 | warning(ret2.read()) 144 | infos('打包完成!') 145 | 146 | warning("###### 正在将 $CUR_INJECT_ASAR_PATH 移动至 $INJECT_JS_DIR_ASAR_PATH ######") 147 | do_cp_p='sudo cp %s %s'%(CUR_INJECT_JS_DIR_ASAR_PATH,INJECT_JS_DIR_ASAR_PATH) 148 | do_cp_ret=os.popen(do_cp_p) 149 | warning(do_cp_ret.read()) 150 | warning("若执行当前脚本后不能正常打开软件的话,则请执行以下命令还原:") 151 | warning("\tcp ./build/backup/node_modules.asar %s\n" %(INJECT_JS_DIR_ASAR_PATH)) 152 | 153 | infos("您的序列号为:") 154 | infos("\tLSGDW2-6M43UN-KHKH2A-D6FDJF") 155 | infos("\tD9KYN9-MCCL2F-59LFPC-NK2CPX\n") 156 | warning("如果激活失败,恐怕您还得安装 rust 环境并使用 license-gen/target/debug/license-gen 生成新的序列号") 157 | -------------------------------------------------------------------------------- /asar_modules/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "asar_modules", 3 | "lockfileVersion": 3, 4 | "requires": true, 5 | "packages": { 6 | "": { 7 | "dependencies": { 8 | "@electron/asar": "^3.2.9" 9 | } 10 | }, 11 | "node_modules/@electron/asar": { 12 | "version": "3.2.9", 13 | "resolved": "https://registry.npmjs.org/@electron/asar/-/asar-3.2.9.tgz", 14 | "integrity": "sha512-Vu2P3X2gcZ3MY9W7yH72X9+AMXwUQZEJBrsPIbX0JsdllLtoh62/Q8Wg370/DawIEVKOyfD6KtTLo645ezqxUA==", 15 | "dependencies": { 16 | "commander": "^5.0.0", 17 | "glob": "^7.1.6", 18 | "minimatch": "^3.0.4" 19 | }, 20 | "bin": { 21 | "asar": "bin/asar.js" 22 | }, 23 | "engines": { 24 | "node": ">=10.12.0" 25 | } 26 | }, 27 | "node_modules/balanced-match": { 28 | "version": "1.0.2", 29 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", 30 | "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" 31 | }, 32 | "node_modules/brace-expansion": { 33 | "version": "1.1.11", 34 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 35 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 36 | "dependencies": { 37 | "balanced-match": "^1.0.0", 38 | "concat-map": "0.0.1" 39 | } 40 | }, 41 | "node_modules/commander": { 42 | "version": "5.1.0", 43 | "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", 44 | "integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==", 45 | "engines": { 46 | "node": ">= 6" 47 | } 48 | }, 49 | "node_modules/concat-map": { 50 | "version": "0.0.1", 51 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 52 | "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" 53 | }, 54 | "node_modules/fs.realpath": { 55 | "version": "1.0.0", 56 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 57 | "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" 58 | }, 59 | "node_modules/glob": { 60 | "version": "7.2.3", 61 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", 62 | "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", 63 | "dependencies": { 64 | "fs.realpath": "^1.0.0", 65 | "inflight": "^1.0.4", 66 | "inherits": "2", 67 | "minimatch": "^3.1.1", 68 | "once": "^1.3.0", 69 | "path-is-absolute": "^1.0.0" 70 | }, 71 | "engines": { 72 | "node": "*" 73 | }, 74 | "funding": { 75 | "url": "https://github.com/sponsors/isaacs" 76 | } 77 | }, 78 | "node_modules/inflight": { 79 | "version": "1.0.6", 80 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 81 | "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", 82 | "dependencies": { 83 | "once": "^1.3.0", 84 | "wrappy": "1" 85 | } 86 | }, 87 | "node_modules/inherits": { 88 | "version": "2.0.4", 89 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 90 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" 91 | }, 92 | "node_modules/minimatch": { 93 | "version": "3.1.2", 94 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", 95 | "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", 96 | "dependencies": { 97 | "brace-expansion": "^1.1.7" 98 | }, 99 | "engines": { 100 | "node": "*" 101 | } 102 | }, 103 | "node_modules/once": { 104 | "version": "1.4.0", 105 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 106 | "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", 107 | "dependencies": { 108 | "wrappy": "1" 109 | } 110 | }, 111 | "node_modules/path-is-absolute": { 112 | "version": "1.0.1", 113 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 114 | "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", 115 | "engines": { 116 | "node": ">=0.10.0" 117 | } 118 | }, 119 | "node_modules/wrappy": { 120 | "version": "1.0.2", 121 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 122 | "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /inject_utf.bat: -------------------------------------------------------------------------------- 1 | :: ####### 作者声明 ######### 2 | :: a copied script for windows. 3 | :: made by hazukie 4 | :: date: 2024.5.12 5 | :: JUST FOR LEARNING PURPOSES, DON'T USE THIS TO CRACK SOFTWARE. 6 | :: 只是出于学习目的,请勿将其用于破解软件,否则后果自负。用户行为均与本项目作者无关! 7 | 8 | @echo off 9 | call :warning 当前脚本仅适用于 windows 平台,且仅在 windows10 版本下通过测试 10 | call :warning 若在执行过程中出现问题,请及时在项目作者反馈 11 | call :infos 开始执行脚本 12 | :: ####### 作者声明 ######### 13 | 14 | 15 | :: ####### 数据配置 ######### 16 | :: 待注入数据文件路径 17 | set CUR_HOOK_JS_PATH=src\hooklog.js 18 | :: ####### 数据配置 ######### 19 | :: Typora 安装路径 20 | set TYPORA_INSTALLED_PATH="C:\Program Files\Typora\resources" 21 | 22 | ::set INJECT_ASAR_PATH=%TYPORA_INSTALLED_PATH:"=%\node_modules.asar 23 | 24 | set CUR_INJECT_ASAR_PATH=build\node_modules.asar 25 | set CUR_PACKED_ASAR_PATH=build\node_modules.asar.pack 26 | 27 | set CUR_INJECT_JS_DIR_PATH=build\node_modules 28 | set CUR_HOOK_JS_WRITE_PATH=%CUR_INJECT_JS_DIR_PATH%\raven\hook.js 29 | set CUR_INJECT_JS_PATH=%CUR_INJECT_JS_DIR_PATH%\raven\index.js 30 | 31 | :: ####### 执行配置 ######### 32 | 33 | :: Node 安装路径 34 | set NODE_INSTALLED_PATH=C:\Users\hazukie\AppData\Roaming\nvm\v20.10.0\node.exe 35 | 36 | :: ASAR 解压缩可执行程序代码存放处 37 | :: Yproject 项目下 asar_modules/node_modules/@electron/asar/bin/ 38 | :: 此处使用相对地址,即相对于你执行的位置! 39 | :: asar 解压缩程序将会被 脚本函数 asar_zip 调用 40 | set ASAR_BIN=./asar_modules/node_modules/@electron/asar/bin/asar.js 41 | :: ####### 执行配置 ######### 42 | 43 | 44 | 45 | :: ####### 执行开始 ######### 46 | call :warning "该脚本包含 sudo 指令,请您确保知悉高危命令执行的后果且承担相关代价" 47 | call :warning "在执行過程中,请您仔细确认相关提示,当提示「即将执行高危命令」时,那么此种情形将考验您的判断力" 48 | call :infos "Typora 安装路径: " %TYPORA_INSTALLED_PATH% 49 | call :askif "Typora 安装路径是否正确?" 50 | if %ret% equ "0" ( 51 | echo 程序继续执行 ) else ( 52 | call :ask "不正确的话你可以尝试输入新的路径" ) 53 | 54 | if %ret% neq "0" ( 55 | set TYPORA_INSTALLED_PATH= 56 | set TYPORA_INSTALLED_PATH=%ret: =%) 57 | 58 | call :infos "已确认当前安装路径为: " %TYPORA_INSTALLED_PATH% 59 | set INJECT_ASAR_PATH= 60 | set INJECT_ASAR_PATH=%TYPORA_INSTALLED_PATH:"=%\node_modules.asar 61 | call :infos %INJECT_ASAR_PATH% 62 | 63 | :: 检测 node 是否存在 64 | call :ask "请输入 Node 安装路径" 65 | call :infos "你为避免反复确认,可以直接改 NODE_INSTALLED_PATH 的值!!" 66 | set NODE_INSTALLED_PATH= 67 | set NODE_INSTALLED_PATH=%ret: =% 68 | call :infos "Node 安装路径为: " %NODE_INSTALLED_PATH% 69 | 70 | call :checkf %NODE_INSTALLED_PATH% 71 | :: 正在测试 node 是否可用... 72 | call :checkf %NODE_INSTALLED_PATH% 73 | %NODE_INSTALLED_PATH% -v 74 | 75 | :: 检测 Typora 安装路径是否存在 76 | call :checkf %TYPORA_INSTALLED_PATH% 77 | 78 | :: 前置条件已经准备完毕 79 | :: 正式开始初始化 80 | call :mkinit "%INJECT_ASAR_PATH%" 81 | 82 | :: 开始解压缩 83 | call :asar_zip "%INJECT_ASAR_PATH%" 84 | goto :eof 85 | :: ####### 执行结束 ######### 86 | 87 | 88 | 89 | 90 | :: ####### 函数配置 ######### 91 | 92 | @rem 打印警告日志 93 | @echo off 94 | :warning 95 | echo ## 警告: %~1%~2 96 | goto :eof 97 | 98 | @rem 打印日志 99 | @echo off 100 | :infos 101 | echo 提示: %~1%~2 102 | goto :eof 103 | 104 | 105 | @rem 询问输入函数 106 | @echo off 107 | :ask 108 | set ret= 109 | set /p ret=%~1: 110 | if "%ret%" equ "" ( 111 | call :warning "您输入为空...请重试!" 112 | goto :ask ) 113 | goto :eof 114 | 115 | 116 | @rem 询问是否函数 117 | @rem 参数1: 问题,参数2: 比较条件(可选) 118 | @echo off 119 | :askif 120 | set /p ret=%~1 (y/n): 121 | if "%ret:~0,1%" neq "y" ( 122 | call :infos "您的回复: %ret%" 123 | set ret= 124 | set ret="1" ) else ( 125 | call :infos "您的回复: %ret%" 126 | set ret= 127 | set ret="0" ) 128 | goto :eof 129 | 130 | 131 | @rem 文件初始化函数 132 | @echo off 133 | :mkinit 134 | call :infos "正在初始化..." 135 | if exist build ( 136 | call :infos "build 文件夹已经存在" 137 | call :warning "正在删除 build 文件夹" 138 | rd /s /q build ) else ( 139 | call :infos "未发现 build 文件夹" 140 | ) 141 | call :infos "正在创建 build 文件夹" 142 | mkdir build 143 | call :infos "build 文件夹创建完成" 144 | 145 | if exist build\node_modules ( 146 | call :infos "build/node_modules 文件夹已经存在" 147 | call :warning "正在删除 build 文件夹" 148 | rd /s /q build\node_modules ) else ( 149 | call :infos "未发现 build/node_modules 文件夹" 150 | ) 151 | call :infos "正在创建 build/node_modules 文件夹" 152 | mkdir build\node_modules 153 | call :infos "build/node_modules 文件夹创建完成" 154 | 155 | call :infos "正在复制 node_modules.asar 至 build 文件夹中..." 156 | copy %1 "%CUR_INJECT_ASAR_PATH%" 157 | 158 | goto :eof 159 | 160 | @rem 文件存在函数 161 | @echo off 162 | :checkf 163 | call :infos "正在检测 %1 是否存在或可用..." 164 | if exist %1 ( 165 | call :infos %1 "文件存在" ) else ( 166 | call :warning %1 "文件不存在!" 167 | call :infos "脚本已正常退出..." 168 | exit 0) 169 | goto :eof 170 | 171 | 172 | @rem 添加 hook.js 173 | :write_js2file 174 | :: 复制内容至 hook.js 文件 175 | type "%CUR_HOOK_JS_PATH%" > "%CUR_HOOK_JS_WRITE_PATH%" 176 | goto :eof 177 | 178 | 179 | @rem 添加 hook.js 依赖至 index.js 180 | :append_require2file 181 | :: 添加内容至 index.js 文件 182 | echo /* append hook!*/ >> "%CUR_INJECT_JS_PATH%" 183 | echo require('./hook') >> "%CUR_INJECT_JS_PATH%" 184 | goto :eof 185 | 186 | 187 | 188 | @rem 解压缩执行函数 189 | @rem 参数0:unpack/pack 190 | @rem 参数1:源 191 | @rem 参数2:目的地 192 | @echo off 193 | :asar_zip 194 | ::call :checkf %ASAR_BIN% 195 | :: 解压 node_modules 到 当前 build 文件夹下 196 | echo %NODE_INSTALLED_PATH% %ASAR_BIN% extract "%CUR_INJECT_ASAR_PATH%" "%CUR_INJECT_JS_DIR_PATH%" 197 | 198 | %NODE_INSTALLED_PATH% %ASAR_BIN% extract "%CUR_INJECT_ASAR_PATH%" "%CUR_INJECT_JS_DIR_PATH%" 199 | 200 | :: 添加 hook.js 201 | call :write_js2file 202 | :: 添加 index.js 203 | call :append_require2file 204 | 205 | :: 重新打包 node_modules 为 node_modules.asar.pack 206 | echo %NODE_INSTALLED_PATH% %ASAR_BIN% pack %CUR_INJECT_JS_DIR_PATH% %CUR_PACKED_ASAR_PATH% 207 | %NODE_INSTALLED_PATH% %ASAR_BIN% pack %CUR_INJECT_JS_DIR_PATH% %CUR_PACKED_ASAR_PATH% 208 | 209 | 210 | :: 复制到 typora 安装程序 211 | call :infos "正在复制 node_modules.asar.pack 至 Typora 文件夹中..." 212 | copy "%CUR_PACKED_ASAR_PATH%" %1 213 | goto :eof 214 | -------------------------------------------------------------------------------- /asar_modules/node_modules/brace-expansion/index.js: -------------------------------------------------------------------------------- 1 | var concatMap = require('concat-map'); 2 | var balanced = require('balanced-match'); 3 | 4 | module.exports = expandTop; 5 | 6 | var escSlash = '\0SLASH'+Math.random()+'\0'; 7 | var escOpen = '\0OPEN'+Math.random()+'\0'; 8 | var escClose = '\0CLOSE'+Math.random()+'\0'; 9 | var escComma = '\0COMMA'+Math.random()+'\0'; 10 | var escPeriod = '\0PERIOD'+Math.random()+'\0'; 11 | 12 | function numeric(str) { 13 | return parseInt(str, 10) == str 14 | ? parseInt(str, 10) 15 | : str.charCodeAt(0); 16 | } 17 | 18 | function escapeBraces(str) { 19 | return str.split('\\\\').join(escSlash) 20 | .split('\\{').join(escOpen) 21 | .split('\\}').join(escClose) 22 | .split('\\,').join(escComma) 23 | .split('\\.').join(escPeriod); 24 | } 25 | 26 | function unescapeBraces(str) { 27 | return str.split(escSlash).join('\\') 28 | .split(escOpen).join('{') 29 | .split(escClose).join('}') 30 | .split(escComma).join(',') 31 | .split(escPeriod).join('.'); 32 | } 33 | 34 | 35 | // Basically just str.split(","), but handling cases 36 | // where we have nested braced sections, which should be 37 | // treated as individual members, like {a,{b,c},d} 38 | function parseCommaParts(str) { 39 | if (!str) 40 | return ['']; 41 | 42 | var parts = []; 43 | var m = balanced('{', '}', str); 44 | 45 | if (!m) 46 | return str.split(','); 47 | 48 | var pre = m.pre; 49 | var body = m.body; 50 | var post = m.post; 51 | var p = pre.split(','); 52 | 53 | p[p.length-1] += '{' + body + '}'; 54 | var postParts = parseCommaParts(post); 55 | if (post.length) { 56 | p[p.length-1] += postParts.shift(); 57 | p.push.apply(p, postParts); 58 | } 59 | 60 | parts.push.apply(parts, p); 61 | 62 | return parts; 63 | } 64 | 65 | function expandTop(str) { 66 | if (!str) 67 | return []; 68 | 69 | // I don't know why Bash 4.3 does this, but it does. 70 | // Anything starting with {} will have the first two bytes preserved 71 | // but *only* at the top level, so {},a}b will not expand to anything, 72 | // but a{},b}c will be expanded to [a}c,abc]. 73 | // One could argue that this is a bug in Bash, but since the goal of 74 | // this module is to match Bash's rules, we escape a leading {} 75 | if (str.substr(0, 2) === '{}') { 76 | str = '\\{\\}' + str.substr(2); 77 | } 78 | 79 | return expand(escapeBraces(str), true).map(unescapeBraces); 80 | } 81 | 82 | function identity(e) { 83 | return e; 84 | } 85 | 86 | function embrace(str) { 87 | return '{' + str + '}'; 88 | } 89 | function isPadded(el) { 90 | return /^-?0\d/.test(el); 91 | } 92 | 93 | function lte(i, y) { 94 | return i <= y; 95 | } 96 | function gte(i, y) { 97 | return i >= y; 98 | } 99 | 100 | function expand(str, isTop) { 101 | var expansions = []; 102 | 103 | var m = balanced('{', '}', str); 104 | if (!m || /\$$/.test(m.pre)) return [str]; 105 | 106 | var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); 107 | var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); 108 | var isSequence = isNumericSequence || isAlphaSequence; 109 | var isOptions = m.body.indexOf(',') >= 0; 110 | if (!isSequence && !isOptions) { 111 | // {a},b} 112 | if (m.post.match(/,.*\}/)) { 113 | str = m.pre + '{' + m.body + escClose + m.post; 114 | return expand(str); 115 | } 116 | return [str]; 117 | } 118 | 119 | var n; 120 | if (isSequence) { 121 | n = m.body.split(/\.\./); 122 | } else { 123 | n = parseCommaParts(m.body); 124 | if (n.length === 1) { 125 | // x{{a,b}}y ==> x{a}y x{b}y 126 | n = expand(n[0], false).map(embrace); 127 | if (n.length === 1) { 128 | var post = m.post.length 129 | ? expand(m.post, false) 130 | : ['']; 131 | return post.map(function(p) { 132 | return m.pre + n[0] + p; 133 | }); 134 | } 135 | } 136 | } 137 | 138 | // at this point, n is the parts, and we know it's not a comma set 139 | // with a single entry. 140 | 141 | // no need to expand pre, since it is guaranteed to be free of brace-sets 142 | var pre = m.pre; 143 | var post = m.post.length 144 | ? expand(m.post, false) 145 | : ['']; 146 | 147 | var N; 148 | 149 | if (isSequence) { 150 | var x = numeric(n[0]); 151 | var y = numeric(n[1]); 152 | var width = Math.max(n[0].length, n[1].length) 153 | var incr = n.length == 3 154 | ? Math.abs(numeric(n[2])) 155 | : 1; 156 | var test = lte; 157 | var reverse = y < x; 158 | if (reverse) { 159 | incr *= -1; 160 | test = gte; 161 | } 162 | var pad = n.some(isPadded); 163 | 164 | N = []; 165 | 166 | for (var i = x; test(i, y); i += incr) { 167 | var c; 168 | if (isAlphaSequence) { 169 | c = String.fromCharCode(i); 170 | if (c === '\\') 171 | c = ''; 172 | } else { 173 | c = String(i); 174 | if (pad) { 175 | var need = width - c.length; 176 | if (need > 0) { 177 | var z = new Array(need + 1).join('0'); 178 | if (i < 0) 179 | c = '-' + z + c.slice(1); 180 | else 181 | c = z + c; 182 | } 183 | } 184 | } 185 | N.push(c); 186 | } 187 | } else { 188 | N = concatMap(n, function(el) { return expand(el, false) }); 189 | } 190 | 191 | for (var j = 0; j < N.length; j++) { 192 | for (var k = 0; k < post.length; k++) { 193 | var expansion = pre + N[j] + post[k]; 194 | if (!isTop || isSequence || expansion) 195 | expansions.push(expansion); 196 | } 197 | } 198 | 199 | return expansions; 200 | } 201 | 202 | -------------------------------------------------------------------------------- /inject.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # made by hazukie 3 | # date: 2024.4.13 4 | # JUST FOR LEARNING PURPOSES, DON'T USE THIS TO CRACK SOFTWARE. 5 | # 只是出于学习目的,请勿将其用于破解软件,否则后果自负。用户行为均与本项目作者无关! 6 | 7 | ##################################### 8 | #### 函数配置部分 #### 9 | #################################### 10 | # 打印警告日志 11 | warning() { 12 | printf "\033[31m-> $*\n\033[0m" 13 | } 14 | 15 | # 打印日志 16 | infos() { 17 | printf "\033[32m=> $*\n\033[0m" 18 | } 19 | 20 | # 捕获 Ctrl+C 中断键 21 | trap 'onCtrlC' INT 22 | function onCtrlC() { 23 | printf "\n" 24 | warning "触发 Ctrl+C,已中止当前脚本运行..." 25 | exit 0 26 | } 27 | 28 | # 提示高危命令执行 29 | check_dangerous_cmd(){ 30 | warning "即将执行 $*" 31 | warning "是否确认执行高危命令? (y/n)" 32 | read -p "-> " -r dcheck 33 | if [[ "${dcheck:0:1}" != "y" ]];then 34 | warning "已取消执行高危命令,程序中止退出..." 35 | exit 1 36 | else 37 | infos "正在执行高危命令 $*" 38 | fi 39 | } 40 | 41 | # 询问函数: 42 | # 调用函数后通过 ret 变量获取返回值, 43 | function ask(){ 44 | infos "$*" 45 | read -p "-> " -r content 46 | until [[ ! -z "$content" ]]; 47 | do 48 | infos "$*" 49 | read -p "-> " -r content 50 | done 51 | ret="" 52 | ret="$content" 53 | } 54 | 55 | 56 | check_typora_installed_path(){ 57 | warning "该脚本包含 sudo 指令,请您确保知悉高危命令执行的后果且承担相关代价" 58 | warning "在执行過程中,请您仔细确认相关提示,当提示「即将执行高危命令」时,那么此种情形将考验您的判断力" 59 | infos "Typora 安装路径: $*" 60 | warning "Typora 安装路径是否正确?(y/n)" 61 | ret="$*" 62 | read -p "-> " -r check 63 | if [[ "${check:0:1}" != "y" ]];then 64 | ask "不正确的话你可以尝试输入新的路径:" 65 | infos "已确认当前安装路径为: $ret\n" 66 | fi 67 | } 68 | 69 | 70 | # 判断 node 是否安装 71 | check_node(){ 72 | warning "检测是否存在 node..." 73 | if ! type node >/dev/null 2>&1;then 74 | warning "未找到 node..." 75 | exit 0 76 | else 77 | infos "node 存在\n" 78 | fi 79 | } 80 | 81 | # 判断文件是否存在 82 | file_exist() { 83 | if [ -e "$1" ]; then 84 | infos "checking $* is exist..." 85 | ret=1 86 | else 87 | warning "checking $* is non-exist..." 88 | ret=0 89 | fi 90 | } 91 | 92 | #注入数据 93 | write_js2file() { 94 | cat "$CUR_HOOK_JS_PATH">"$HOOK_JS_WRITE_PATH" 95 | } 96 | 97 | 98 | # 给目的文件中追加一行 "require('./hook')", 99 | # 实现在 Typora 运行时调用注入JS文件 100 | append_require2file() { 101 | echo -e "\nrequire('./hook')">> "$CUR_INJECT_JS_PATH" 102 | } 103 | 104 | #前置准备工作 105 | mkinit(){ 106 | # 检查相关文件夹是否存在 107 | file_exist "$CUR_INJECT_JS_DIR_PATH" 108 | if [ "$ret" == "1" ]; then 109 | warning "您可能已经注入过 hook 文件了!\n警告:在当前目录下发现 node 文件夹" 110 | infos "您若不确定之前是否注入过该文件的话,请手动删除当前目录下的 node 文件夹($CUR_INJECT_JS_DIR_PATH)!\n" 111 | infos "您可以有以下选择:" 112 | infos "\t 1. 删除目录" 113 | warning "\t\trm $CUR_INJECT_JS_DIR_PATH -r\n" 114 | infos "\t 2. 复制已注入压缩包(已确认)至 $INJECT_JS_DIR_ASAR_PATH" 115 | warning "\t\tsudo cp $CUR_PACKED_ASAR_PATH $INJECT_JS_DIR_ASAR_PATH" 116 | exit 0 117 | fi 118 | file_exist "$INJECT_JS_DIR_ASAR_PATH" 119 | if [ "$ret" == "1" ]; then 120 | # 检查 node 是否存在 121 | check_node 122 | 123 | # 复制 asar 文件至当前项目 build 下 124 | infos "复制 node_modules 至 当前目录下($(pwd)/build)" 125 | check_dangerous_cmd "sudo cp $INJECT_JS_DIR_ASAR_PATH $CUR_INJECT_ASAR_PATH" 126 | sudo cp $INJECT_JS_DIR_ASAR_PATH $CUR_INJECT_ASAR_PATH 127 | else 128 | warning "未找到 node_modules.asar!" 129 | warning "请确认 Typora 安装目录下是否正确,以及该安装目录下的 resources 中是否存在 node_modules.asar!" 130 | exit 0 131 | fi 132 | } 133 | 134 | ################## 函数配置部分 ############### 135 | 136 | 137 | 138 | 139 | ################## 数据配置部分 ############### 140 | 141 | # 待注入数据文件路径 142 | CUR_HOOK_JS_PATH="./src/hooklog.js" 143 | 144 | # Typora 安装路径 145 | TYPORA_INSTALLED_PATH="/usr/share/typora" 146 | # 再次确认是否正确 147 | check_typora_installed_path "$TYPORA_INSTALLED_PATH" 148 | TYPORA_INSTALLED_PATH="$ret" 149 | 150 | # 注入 JS 文件的待解压缩包路径 151 | INJECT_JS_DIR_ASAR_PATH="$TYPORA_INSTALLED_PATH/resources/node_modules.asar" 152 | 153 | # 为防止破坏原压缩包,特意复制至当前目录 154 | if [[ ! -d ./build ]];then 155 | mkdir build 156 | fi 157 | # 当前压缩包副本路径 158 | CUR_INJECT_ASAR_PATH="./build/node_modules.asar" 159 | 160 | # 当前重新打包压缩包路径 161 | CUR_PACKED_ASAR_PATH="${CUR_INJECT_ASAR_PATH}_new" 162 | 163 | # 当前注入 JS 文件的文件夹路径 164 | CUR_INJECT_JS_DIR_PATH="./build/node" 165 | 166 | # 注入 JS 文件路径 167 | HOOK_JS_WRITE_PATH="$CUR_INJECT_JS_DIR_PATH/raven/hook.js" 168 | 169 | # 注入JS文件的目的文件路径 170 | CUR_INJECT_JS_PATH="$CUR_INJECT_JS_DIR_PATH/raven/index.js" 171 | 172 | # 解压缩 Asar 包的程序路径 173 | ASAR_BIN="./asar_modules/node_modules/@electron/asar/bin/asar.js" 174 | ################## 数据配置部分 ############### 175 | 176 | 177 | 178 | ################## 正式执行部分 ############### 179 | # 前置工作初始化 180 | mkinit 181 | 182 | # 解压 asar 文件 183 | infos "正在解压 node_modues.asar" 184 | node $ASAR_BIN extract $CUR_INJECT_ASAR_PATH $CUR_INJECT_JS_DIR_PATH 185 | infos "成功解压至 $(pwd)/node 文件夹中!\n" 186 | 187 | # 添加js文件和依赖 188 | infos "正在将 hook.js 添加至 $CUR_INJECT_JS_DIR_PATH 文件夹中..." 189 | write_js2file 190 | infos "正在将依赖添加到 $CUR_INJECT_JS_PATH...\n" 191 | append_require2file 192 | infos "添加 $CUR_HOOK_JS_PATH 成功!" 193 | infos "在 $CUR_INJECT_JS_PATH 添加依赖成功!\n" 194 | 195 | # 重新打包成 asar 文件 196 | infos "正在重新打包 node 文件夹至 $CUR_PACKED_ASAR_PATH..." 197 | node $ASAR_BIN pack $CUR_INJECT_JS_DIR_PATH $CUR_PACKED_ASAR_PATH 198 | infos "打包完成!\n" 199 | 200 | # 复制 asar 文件到软件处 201 | warning "###### 正在将 $CUR_INJECT_ASAR_PATH 移动至 $INJECT_JS_DIR_ASAR_PATH ######" 202 | check_dangerous_cmd "sudo cp $CUR_PACKED_ASAR_PATH $INJECT_JS_DIR_ASAR_PATH" 203 | sudo cp $CUR_PACKED_ASAR_PATH $INJECT_JS_DIR_ASAR_PATH 204 | 205 | # 善后工作 206 | warning "若执行当前脚本后不能正常打开软件的话,则请执行以下命令还原:" 207 | warning "\tcp $CUR_INJECT_ASAR_PATH $INJECT_JS_DIR_ASAR_PATH\n" 208 | infos "您的序列号为:" 209 | infos "\tLSGDW2-6M43UN-KHKH2A-D6FDJF" 210 | infos "\tD9KYN9-MCCL2F-59LFPC-NK2CPX\n" 211 | warning "如果激活失败,恐怕您还得安装 rust 环境并使用 license-gen/target/debug/license-gen 生成新的序列号" 212 | ################## 正式执行部分 ############### 213 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "ansi_term" 7 | version = "0.12.1" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" 10 | dependencies = [ 11 | "winapi", 12 | ] 13 | 14 | [[package]] 15 | name = "atty" 16 | version = "0.2.14" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 19 | dependencies = [ 20 | "hermit-abi", 21 | "libc", 22 | "winapi", 23 | ] 24 | 25 | [[package]] 26 | name = "bitflags" 27 | version = "1.3.2" 28 | source = "registry+https://github.com/rust-lang/crates.io-index" 29 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 30 | 31 | [[package]] 32 | name = "cfg-if" 33 | version = "1.0.0" 34 | source = "registry+https://github.com/rust-lang/crates.io-index" 35 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 36 | 37 | [[package]] 38 | name = "clap" 39 | version = "2.34.0" 40 | source = "registry+https://github.com/rust-lang/crates.io-index" 41 | checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" 42 | dependencies = [ 43 | "ansi_term", 44 | "atty", 45 | "bitflags", 46 | "strsim", 47 | "textwrap", 48 | "unicode-width", 49 | "vec_map", 50 | ] 51 | 52 | [[package]] 53 | name = "fastrand" 54 | version = "1.8.0" 55 | source = "registry+https://github.com/rust-lang/crates.io-index" 56 | checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" 57 | dependencies = [ 58 | "instant", 59 | ] 60 | 61 | [[package]] 62 | name = "glob" 63 | version = "0.3.0" 64 | source = "registry+https://github.com/rust-lang/crates.io-index" 65 | checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" 66 | 67 | [[package]] 68 | name = "hermit-abi" 69 | version = "0.1.19" 70 | source = "registry+https://github.com/rust-lang/crates.io-index" 71 | checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 72 | dependencies = [ 73 | "libc", 74 | ] 75 | 76 | [[package]] 77 | name = "instant" 78 | version = "0.1.12" 79 | source = "registry+https://github.com/rust-lang/crates.io-index" 80 | checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" 81 | dependencies = [ 82 | "cfg-if", 83 | ] 84 | 85 | [[package]] 86 | name = "itoa" 87 | version = "1.0.4" 88 | source = "registry+https://github.com/rust-lang/crates.io-index" 89 | checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" 90 | 91 | [[package]] 92 | name = "libc" 93 | version = "0.2.137" 94 | source = "registry+https://github.com/rust-lang/crates.io-index" 95 | checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" 96 | 97 | [[package]] 98 | name = "node_inject" 99 | version = "0.1.0" 100 | dependencies = [ 101 | "random-string", 102 | "rasar", 103 | ] 104 | 105 | [[package]] 106 | name = "random-string" 107 | version = "1.0.0" 108 | source = "registry+https://github.com/rust-lang/crates.io-index" 109 | checksum = "cf4e63111ec5292d8af9c220f06fe3bb87991cc78b6f1f7e291d1ae6b8a60817" 110 | dependencies = [ 111 | "fastrand", 112 | ] 113 | 114 | [[package]] 115 | name = "rasar" 116 | version = "0.1.6" 117 | source = "git+https://github.com/Zerthox/rasar.git#a384c9413fc905b7eef5f48ef4e2f74f73e7addd" 118 | dependencies = [ 119 | "clap", 120 | "glob", 121 | "serde_json", 122 | ] 123 | 124 | [[package]] 125 | name = "ryu" 126 | version = "1.0.11" 127 | source = "registry+https://github.com/rust-lang/crates.io-index" 128 | checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" 129 | 130 | [[package]] 131 | name = "serde" 132 | version = "1.0.147" 133 | source = "registry+https://github.com/rust-lang/crates.io-index" 134 | checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" 135 | 136 | [[package]] 137 | name = "serde_json" 138 | version = "1.0.87" 139 | source = "registry+https://github.com/rust-lang/crates.io-index" 140 | checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" 141 | dependencies = [ 142 | "itoa", 143 | "ryu", 144 | "serde", 145 | ] 146 | 147 | [[package]] 148 | name = "strsim" 149 | version = "0.8.0" 150 | source = "registry+https://github.com/rust-lang/crates.io-index" 151 | checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" 152 | 153 | [[package]] 154 | name = "textwrap" 155 | version = "0.11.0" 156 | source = "registry+https://github.com/rust-lang/crates.io-index" 157 | checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" 158 | dependencies = [ 159 | "unicode-width", 160 | ] 161 | 162 | [[package]] 163 | name = "unicode-width" 164 | version = "0.1.10" 165 | source = "registry+https://github.com/rust-lang/crates.io-index" 166 | checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" 167 | 168 | [[package]] 169 | name = "vec_map" 170 | version = "0.8.2" 171 | source = "registry+https://github.com/rust-lang/crates.io-index" 172 | checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" 173 | 174 | [[package]] 175 | name = "winapi" 176 | version = "0.3.9" 177 | source = "registry+https://github.com/rust-lang/crates.io-index" 178 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 179 | dependencies = [ 180 | "winapi-i686-pc-windows-gnu", 181 | "winapi-x86_64-pc-windows-gnu", 182 | ] 183 | 184 | [[package]] 185 | name = "winapi-i686-pc-windows-gnu" 186 | version = "0.4.0" 187 | source = "registry+https://github.com/rust-lang/crates.io-index" 188 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 189 | 190 | [[package]] 191 | name = "winapi-x86_64-pc-windows-gnu" 192 | version = "0.4.0" 193 | source = "registry+https://github.com/rust-lang/crates.io-index" 194 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 195 | -------------------------------------------------------------------------------- /asar_modules/node_modules/@electron/asar/README.md: -------------------------------------------------------------------------------- 1 | # @electron/asar - Electron Archive 2 | 3 | [![CircleCI build status](https://circleci.com/gh/electron/asar/tree/main.svg?style=shield)](https://circleci.com/gh/electron/asar/tree/main) 4 | [![npm version](http://img.shields.io/npm/v/@electron/asar.svg)](https://npmjs.org/package/@electron/asar) 5 | 6 | Asar is a simple extensive archive format, it works like `tar` that concatenates 7 | all files together without compression, while having random access support. 8 | 9 | ## Features 10 | 11 | * Support random access 12 | * Use JSON to store files' information 13 | * Very easy to write a parser 14 | 15 | ## Command line utility 16 | 17 | ### Install 18 | 19 | This module requires Node 10 or later. 20 | 21 | ```bash 22 | $ npm install --engine-strict @electron/asar 23 | ``` 24 | 25 | ### Usage 26 | 27 | ```bash 28 | $ asar --help 29 | 30 | Usage: asar [options] [command] 31 | 32 | Commands: 33 | 34 | pack|p 35 | create asar archive 36 | 37 | list|l 38 | list files of asar archive 39 | 40 | extract-file|ef 41 | extract one file from archive 42 | 43 | extract|e 44 | extract archive 45 | 46 | 47 | Options: 48 | 49 | -h, --help output usage information 50 | -V, --version output the version number 51 | 52 | ``` 53 | 54 | #### Excluding multiple resources from being packed 55 | 56 | Given: 57 | ``` 58 | app 59 | (a) ├── x1 60 | (b) ├── x2 61 | (c) ├── y3 62 | (d) │   ├── x1 63 | (e) │   └── z1 64 | (f) │   └── x2 65 | (g) └── z4 66 | (h) └── w1 67 | ``` 68 | 69 | Exclude: a, b 70 | ```bash 71 | $ asar pack app app.asar --unpack-dir "{x1,x2}" 72 | ``` 73 | 74 | Exclude: a, b, d, f 75 | ```bash 76 | $ asar pack app app.asar --unpack-dir "**/{x1,x2}" 77 | ``` 78 | 79 | Exclude: a, b, d, f, h 80 | ```bash 81 | $ asar pack app app.asar --unpack-dir "{**/x1,**/x2,z4/w1}" 82 | ``` 83 | 84 | ## Using programmatically 85 | 86 | ### Example 87 | 88 | ```javascript 89 | const asar = require('@electron/asar'); 90 | 91 | const src = 'some/path/'; 92 | const dest = 'name.asar'; 93 | 94 | await asar.createPackage(src, dest); 95 | console.log('done.'); 96 | ``` 97 | 98 | Please note that there is currently **no** error handling provided! 99 | 100 | ### Transform 101 | You can pass in a `transform` option, that is a function, which either returns 102 | nothing, or a `stream.Transform`. The latter will be used on files that will be 103 | in the `.asar` file to transform them (e.g. compress). 104 | 105 | ```javascript 106 | const asar = require('@electron/asar'); 107 | 108 | const src = 'some/path/'; 109 | const dest = 'name.asar'; 110 | 111 | function transform (filename) { 112 | return new CustomTransformStream() 113 | } 114 | 115 | await asar.createPackageWithOptions(src, dest, { transform: transform }); 116 | console.log('done.'); 117 | ``` 118 | 119 | ## Using with grunt 120 | 121 | There is also an unofficial grunt plugin to generate asar archives at [bwin/grunt-asar][grunt-asar]. 122 | 123 | ## Format 124 | 125 | Asar uses [Pickle][pickle] to safely serialize binary value to file. 126 | 127 | The format of asar is very flat: 128 | 129 | ``` 130 | | UInt32: header_size | String: header | Bytes: file1 | ... | Bytes: file42 | 131 | ``` 132 | 133 | The `header_size` and `header` are serialized with [Pickle][pickle] class, and 134 | `header_size`'s [Pickle][pickle] object is 8 bytes. 135 | 136 | The `header` is a JSON string, and the `header_size` is the size of `header`'s 137 | `Pickle` object. 138 | 139 | Structure of `header` is something like this: 140 | 141 | ```json 142 | { 143 | "files": { 144 | "tmp": { 145 | "files": {} 146 | }, 147 | "usr" : { 148 | "files": { 149 | "bin": { 150 | "files": { 151 | "ls": { 152 | "offset": "0", 153 | "size": 100, 154 | "executable": true, 155 | "integrity": { 156 | "algorithm": "SHA256", 157 | "hash": "...", 158 | "blockSize": 1024, 159 | "blocks": ["...", "..."] 160 | } 161 | }, 162 | "cd": { 163 | "offset": "100", 164 | "size": 100, 165 | "executable": true, 166 | "integrity": { 167 | "algorithm": "SHA256", 168 | "hash": "...", 169 | "blockSize": 1024, 170 | "blocks": ["...", "..."] 171 | } 172 | } 173 | } 174 | } 175 | } 176 | }, 177 | "etc": { 178 | "files": { 179 | "hosts": { 180 | "offset": "200", 181 | "size": 32, 182 | "integrity": { 183 | "algorithm": "SHA256", 184 | "hash": "...", 185 | "blockSize": 1024, 186 | "blocks": ["...", "..."] 187 | } 188 | } 189 | } 190 | } 191 | } 192 | } 193 | ``` 194 | 195 | `offset` and `size` records the information to read the file from archive, the 196 | `offset` starts from 0 so you have to manually add the size of `header_size` and 197 | `header` to the `offset` to get the real offset of the file. 198 | 199 | `offset` is a UINT64 number represented in string, because there is no way to 200 | precisely represent UINT64 in JavaScript `Number`. `size` is a JavaScript 201 | `Number` that is no larger than `Number.MAX_SAFE_INTEGER`, which has a value of 202 | `9007199254740991` and is about 8PB in size. We didn't store `size` in UINT64 203 | because file size in Node.js is represented as `Number` and it is not safe to 204 | convert `Number` to UINT64. 205 | 206 | `integrity` is an object consisting of a few keys: 207 | * A hashing `algorithm`, currently only `SHA256` is supported. 208 | * A hex encoded `hash` value representing the hash of the entire file. 209 | * An array of hex encoded hashes for the `blocks` of the file. i.e. for a blockSize of 4KB this array contains the hash of every block if you split the file into N 4KB blocks. 210 | * A integer value `blockSize` representing the size in bytes of each block in the `blocks` hashes above 211 | 212 | [pickle]: https://chromium.googlesource.com/chromium/src/+/main/base/pickle.h 213 | [grunt-asar]: https://github.com/bwin/grunt-asar 214 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## TYpora 最新版激发教程 2 | 3 | > Yporainject([复制自 NodeInject 项目 Copy from repo NodeInject](https://github.com/DiamondHunters/NodeInject)) 4 | 5 | > **[查看 Node_inject 项目说明书 See the README of that repo](./NodeInject_README.md)** 6 | > 7 | > 作者:叶月绘梨依 8 | > 日期:2023年6月10日 9 | --- 10 | 11 | ### 无法支持 最新版本 1.10,请注意安装包版本号! 12 | 13 | #### 已通过测试平台(来自原项目 Node_inject) 14 | - [x] Windows 15 | - [x] Ubuntu 16 | - [ ] MacOs 17 | > Since macos may adopt different packaging methods and webkit as the execution environment, this tool does not support applications under macos. 18 | #### 本仓库使用到的开源项目 19 | - [Node_inject](https://github.com/DiamondHunters/NodeInject) 20 | - [Node_inject_example](https://github.com/DiamondHunters/NodeInject_Hook_example) 21 | 22 | ### **[怎么提问 how to issue](./issue_template.md)** 23 | 24 | 请您提问之前,请自行确认: 25 | - 尝试通过网络解决遇到的问题,你确信网络不能解决你的问题 26 | - 确定已有的 **issue** 不能解决你的问题 27 | - 确定 **issue** 按照如下格式: [问题]: 问题描述 28 | 29 | **请您按照提问模板填写(文件位于仓库 issue_template.md)
30 | 谢谢您的配合,祝您生活愉快!** 31 | 32 | 33 | --- 34 | 35 | ## 最新方法 36 | **激活时请勾选国内服务器,否则会激活不成功** 37 | **特别提示:** 当前两个脚本可能有不完备的地方,使用时请格外注意 38 | #### 1. 使用 [`Python 脚本 inject.py`](./inject.py) 39 | ```bash 40 | # 在当前项目目录下(Yproject) 41 | python inject.py 42 | ``` 43 | #### 2. 使用 [`Bash 脚本 inject.sh`](./inject.sh) 44 | ```bash 45 | # 在当前项目目录下(Yproject) 46 | ./inject.sh 47 | ``` 48 | ![inject.sh 使用效果图](./img/image-202405070106.png) 49 | 50 | 51 | 52 | ### **Windows 平台** 53 | 54 | **当前仅在 win10 下 powershell(管理员运行模式) 测试通过,可能仍有不足之处** 55 | **使用前,请谨慎通读脚本,或备份 typora 安装包以便重新安装** 56 | 57 | [GBK 编码版批处理文件 inject_gbk.bat ](./inject_gbk.bat) 58 | 59 | [UTF 编码版批处理文件 inject_utf.bat ](./inject_utf.bat) 60 | 61 | ```bash 62 | # 请 搜索 powershell,并以管理员权限运行 63 | 64 | ## 以下均假定在 管理员模式 powershell 终端下运行!! 65 | # 移动至当前项目处 66 | # 比如 当前项目为 D:\Yproject 67 | 68 | d: #切换到 D 盘 69 | cd Yproject # 移动到相关目录 70 | .\inject_gbk.bat 71 | ``` 72 | 73 | 74 | 75 | **脚本依赖要求**: 以上脚本均依赖 node 运行库, 故请安装 node(亦可通过 nvm 管理器安装 node) 76 | 77 | ```bash 78 | #arch 79 | sudo pacman -S nodejs 80 | #ubuntu 81 | sudo apt install nodejs 82 | 83 | #windows 84 | #请先安装 nodejs 85 | # 推荐:https://github.com/coreybutler/nvm-windows 86 | # 或者参考:https://zhuanlan.zhihu.com/p/442215189 87 | # 找到安装路径下的node.exe,复制路径 88 | # 然后更改 inject_gbk.bat或 inject_utf.bat 中的 NODE_INSTALLED_PATH 值 89 | 90 | ``` 91 | 92 | 93 | 94 | #### 3. 若不想使用以上两个脚本,或使用以上脚本运行失败者,则请参照 **原方法** 进行。 95 | 96 | **注意**:license_code 文件内置有已经生成的序列码,可直接使用。若出现意外,那么还请安装 rust 环境,并通过以下步骤以获得激活序列: 97 | 98 | ```bash 99 | # 假设您已经在 Yproject 目录下 100 | # 并成功配置 rust 环境 101 | cd ./license-gen 102 | cargo build 103 | ./target/debug/license-gen 104 | 输出 License for you: xxxxxx... 105 | ``` 106 | 107 | 108 | --- 109 | 110 | 111 | 112 | 113 | 114 | ## 原方法 115 | 116 | #### 1. 下载最新版 Typora 安装包 117 | 118 | - [前往 Typora 中文官网下载](https://typoraio.cn/releases/all) 119 | 120 | - 在终端下输入以下命令直接下载(我电脑是 X86 架构的,请根据自己电脑自行选择) 121 | 122 | ```bash 123 | # 查看电脑架构 124 | uname -m 125 | 126 | # 下载 Typora 安装包 127 | # X86(Amd) 架构 128 | wget https://download2.typoraio.cn/linux/typora_1.7.4_amd64.deb --output-document typora.deb 129 | 130 | # Arm 架构 131 | wget https://download2.typoraio.cn/linux/typora_1.7.4_arm64.deb --output-document typora.deb 132 | 133 | # 安装 Typora 软件包 134 | sudo dpkg -i typora.deb 135 | ``` 136 | 137 | 138 | 139 | #### 2. 克隆 Yporaject 项目 140 | 141 | 可以直接克隆本项目仓库(本项目对原两个项目进行了合并),好处是一键编译即可,坏处是本项目并未和原项目代码同步 142 | 143 | ```bash 144 | # 可以直接克隆本项目的仓库, depth=1 表示仅克隆最新版本,以减少等待时间 145 | git clone https://github.com/hazukieq/Yporaject.git --depth=1 146 | ``` 147 | 148 | 或者克隆原项目仓库 149 | 150 | ```bash 151 | # 原项目仓库, depth=1 表示仅克隆最新版本,以减少等待时间 152 | git clone https://github.com/DiamondHunters/NodeInject --depth=1 153 | 154 | git clone https://github.com/DiamondHunters/NodeInject_Hook_example --depth=1 155 | 156 | # 建立 Yproraject 文件夹 157 | mkdir Yporaject 158 | 159 | # 将两个项目资源合并 160 | # 将 NodeInject 项目代码复制到 Yproraject 文件夹 161 | cp NodeInject/* Yporaject -r 162 | 163 | # 将 NodeInject_Hook_example/hook.js 复制到 Yporaject/src 文件夹 164 | cp NodeInject_Hook_example/hook.js Yporaject/src 165 | 166 | # 将 NodeInject_Hook_example/license_gen 文件夹复制到 Yporaject 文件夹 167 | cp NodeInject_Hook_example/license_gen Yporaject -r 168 | ``` 169 | 170 | 171 | 172 | #### 3. 配置 Rust 编译环境 173 | 174 | 由于编译项目需要 **Rust** 的支持,所以我们需要配置相关环境(若已有,则可跳过该步骤) 175 | 176 | ```bash 177 | # 运行官方脚本安装即可 178 | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh 179 | 180 | # 检查 cargo,若看到如下版本信息,则说明配置成功 181 | cargo -V 182 | cargo 1.70.0 (ec8a8a0ca 2023-04-25) 183 | ``` 184 | 185 | 注:若安装过程中出现其他问题,请自行网上搜索相关安装教程,关键字 `ubuntu ` `cargo ` `rust` `install` 186 | 187 | 188 | 189 | #### 4. 编译 Yporaject 项目 190 | 191 | ```bash 192 | # 进入 Yporaject 项目 193 | cd Yporaject 194 | # 运行编译命令 195 | cargo build 196 | # 查看二进制是否生成,程序名称为 node_inject 197 | ls target/debug 198 | # 尝试运行该二进制程序 199 | cargo run 200 | output: 201 | no node_modules.asar found 202 | move me to the root of your typora installation(the same directory as executable of electron) 203 | ``` 204 | 205 | 请务必确认当前项目目录 **target/debug 下** 是否生成了 **node_inject 二进制程序** 206 | 207 | 208 | 209 | #### 5. 复制二进制程序到安装目录下 210 | 211 | ```bash 212 | # 记录当前目录路径,待会返回需要用到 213 | cur=`pwd` 214 | 215 | # 复制二进制程序到相关目录下 216 | sudo cp target/debug/node_inject /usr/share/typora 217 | # 进入相关目录 218 | cd /usr/share/typora 219 | # 给予二进制程序执行权限 220 | sudo chmod +x node_inject 221 | 222 | # 运行二进制程序 223 | # (请注意程序运行输出信息,观察是否运行成功!!) 224 | # 若无读写权限,建议使用 sudo ./node_inject 225 | sudo ./node_inject 226 | ``` 227 | 228 | 229 | 230 | #### 6. 获取许可证激发码 231 | 232 | ```bash 233 | # 返回项目 234 | cd $cur 235 | # 进入 license-gen 文件夹 236 | cd license-gen 237 | # 编译代码 238 | cargo build 239 | # 运行二进制程序 240 | cargo run 241 | # 你将会得到以下输出 242 | output: 243 | Finished dev [unoptimized + debuginfo] target(s) in 0.00s 244 | Running `target/debug/license-gen` 245 | License for you: xxxxxx-xxxxxx-xxxxxx-xxxxxx 246 | ``` 247 | 248 | 复制 **License for you: xxxxxx-xxxxxx-xxxxxx-xxxxxx** 的那一串激发码,待会需要用到 249 | 250 | #### 7. 激活软件 251 | 252 | ```bash 253 | #运行 Typora (你也可以在桌面上点击相关图标) 254 | typora & 255 | ``` 256 | 257 | 依次点击界面上方菜单栏选项 **help > my license(帮助 > 我的许可证...)** 258 | 259 | ![image-20230611002616301](./img/image-20230611002616301.png) 260 | 261 | 262 | 263 | 264 | 265 | ![image-20230611002645270](./img/image-20230611002645270.png) 266 | 267 | 268 | 269 | 邮箱可以随便填 270 | 271 | 然后在第二输入框中,**粘贴刚才得到的激发码** 272 | 273 | 点击 `激活` 按钮后,你将会看到以下界面 274 | 275 | 276 | 277 | ![image-20230611002933127](./img/LICENSE.png) 278 | 279 | 280 | 281 | #### 结语 282 | 283 | 经过几番查找,好多教程都不怎么符合我的需求,且在 `CSDN` 等平台上各种转载、胡乱复制的帖子...看得真是心累。不知是不是由于我用的软件比较新的缘故, 比如 **poraCracker 就没有用。后面看到了NodeInject这个项目,我抱着尝试的态度按照项目指南操作,没想到竟然真的激活成功了。为了以后自己能想起这个方法,特此记录。 284 | 285 | 286 | 287 | ##### 参考资料 288 | 289 | 1. [**(Linux/Windows) Typora 理论多版本兼容破解方案**](https://www.52pojie.cn/thread-1710146-1-1.html) 290 | 2. [RUST 安装](https://www.rust-lang.org/zh-CN/learn/get-started) 291 | -------------------------------------------------------------------------------- /asar_modules/node_modules/glob/common.js: -------------------------------------------------------------------------------- 1 | exports.setopts = setopts 2 | exports.ownProp = ownProp 3 | exports.makeAbs = makeAbs 4 | exports.finish = finish 5 | exports.mark = mark 6 | exports.isIgnored = isIgnored 7 | exports.childrenIgnored = childrenIgnored 8 | 9 | function ownProp (obj, field) { 10 | return Object.prototype.hasOwnProperty.call(obj, field) 11 | } 12 | 13 | var fs = require("fs") 14 | var path = require("path") 15 | var minimatch = require("minimatch") 16 | var isAbsolute = require("path-is-absolute") 17 | var Minimatch = minimatch.Minimatch 18 | 19 | function alphasort (a, b) { 20 | return a.localeCompare(b, 'en') 21 | } 22 | 23 | function setupIgnores (self, options) { 24 | self.ignore = options.ignore || [] 25 | 26 | if (!Array.isArray(self.ignore)) 27 | self.ignore = [self.ignore] 28 | 29 | if (self.ignore.length) { 30 | self.ignore = self.ignore.map(ignoreMap) 31 | } 32 | } 33 | 34 | // ignore patterns are always in dot:true mode. 35 | function ignoreMap (pattern) { 36 | var gmatcher = null 37 | if (pattern.slice(-3) === '/**') { 38 | var gpattern = pattern.replace(/(\/\*\*)+$/, '') 39 | gmatcher = new Minimatch(gpattern, { dot: true }) 40 | } 41 | 42 | return { 43 | matcher: new Minimatch(pattern, { dot: true }), 44 | gmatcher: gmatcher 45 | } 46 | } 47 | 48 | function setopts (self, pattern, options) { 49 | if (!options) 50 | options = {} 51 | 52 | // base-matching: just use globstar for that. 53 | if (options.matchBase && -1 === pattern.indexOf("/")) { 54 | if (options.noglobstar) { 55 | throw new Error("base matching requires globstar") 56 | } 57 | pattern = "**/" + pattern 58 | } 59 | 60 | self.silent = !!options.silent 61 | self.pattern = pattern 62 | self.strict = options.strict !== false 63 | self.realpath = !!options.realpath 64 | self.realpathCache = options.realpathCache || Object.create(null) 65 | self.follow = !!options.follow 66 | self.dot = !!options.dot 67 | self.mark = !!options.mark 68 | self.nodir = !!options.nodir 69 | if (self.nodir) 70 | self.mark = true 71 | self.sync = !!options.sync 72 | self.nounique = !!options.nounique 73 | self.nonull = !!options.nonull 74 | self.nosort = !!options.nosort 75 | self.nocase = !!options.nocase 76 | self.stat = !!options.stat 77 | self.noprocess = !!options.noprocess 78 | self.absolute = !!options.absolute 79 | self.fs = options.fs || fs 80 | 81 | self.maxLength = options.maxLength || Infinity 82 | self.cache = options.cache || Object.create(null) 83 | self.statCache = options.statCache || Object.create(null) 84 | self.symlinks = options.symlinks || Object.create(null) 85 | 86 | setupIgnores(self, options) 87 | 88 | self.changedCwd = false 89 | var cwd = process.cwd() 90 | if (!ownProp(options, "cwd")) 91 | self.cwd = cwd 92 | else { 93 | self.cwd = path.resolve(options.cwd) 94 | self.changedCwd = self.cwd !== cwd 95 | } 96 | 97 | self.root = options.root || path.resolve(self.cwd, "/") 98 | self.root = path.resolve(self.root) 99 | if (process.platform === "win32") 100 | self.root = self.root.replace(/\\/g, "/") 101 | 102 | // TODO: is an absolute `cwd` supposed to be resolved against `root`? 103 | // e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test') 104 | self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd) 105 | if (process.platform === "win32") 106 | self.cwdAbs = self.cwdAbs.replace(/\\/g, "/") 107 | self.nomount = !!options.nomount 108 | 109 | // disable comments and negation in Minimatch. 110 | // Note that they are not supported in Glob itself anyway. 111 | options.nonegate = true 112 | options.nocomment = true 113 | // always treat \ in patterns as escapes, not path separators 114 | options.allowWindowsEscape = false 115 | 116 | self.minimatch = new Minimatch(pattern, options) 117 | self.options = self.minimatch.options 118 | } 119 | 120 | function finish (self) { 121 | var nou = self.nounique 122 | var all = nou ? [] : Object.create(null) 123 | 124 | for (var i = 0, l = self.matches.length; i < l; i ++) { 125 | var matches = self.matches[i] 126 | if (!matches || Object.keys(matches).length === 0) { 127 | if (self.nonull) { 128 | // do like the shell, and spit out the literal glob 129 | var literal = self.minimatch.globSet[i] 130 | if (nou) 131 | all.push(literal) 132 | else 133 | all[literal] = true 134 | } 135 | } else { 136 | // had matches 137 | var m = Object.keys(matches) 138 | if (nou) 139 | all.push.apply(all, m) 140 | else 141 | m.forEach(function (m) { 142 | all[m] = true 143 | }) 144 | } 145 | } 146 | 147 | if (!nou) 148 | all = Object.keys(all) 149 | 150 | if (!self.nosort) 151 | all = all.sort(alphasort) 152 | 153 | // at *some* point we statted all of these 154 | if (self.mark) { 155 | for (var i = 0; i < all.length; i++) { 156 | all[i] = self._mark(all[i]) 157 | } 158 | if (self.nodir) { 159 | all = all.filter(function (e) { 160 | var notDir = !(/\/$/.test(e)) 161 | var c = self.cache[e] || self.cache[makeAbs(self, e)] 162 | if (notDir && c) 163 | notDir = c !== 'DIR' && !Array.isArray(c) 164 | return notDir 165 | }) 166 | } 167 | } 168 | 169 | if (self.ignore.length) 170 | all = all.filter(function(m) { 171 | return !isIgnored(self, m) 172 | }) 173 | 174 | self.found = all 175 | } 176 | 177 | function mark (self, p) { 178 | var abs = makeAbs(self, p) 179 | var c = self.cache[abs] 180 | var m = p 181 | if (c) { 182 | var isDir = c === 'DIR' || Array.isArray(c) 183 | var slash = p.slice(-1) === '/' 184 | 185 | if (isDir && !slash) 186 | m += '/' 187 | else if (!isDir && slash) 188 | m = m.slice(0, -1) 189 | 190 | if (m !== p) { 191 | var mabs = makeAbs(self, m) 192 | self.statCache[mabs] = self.statCache[abs] 193 | self.cache[mabs] = self.cache[abs] 194 | } 195 | } 196 | 197 | return m 198 | } 199 | 200 | // lotta situps... 201 | function makeAbs (self, f) { 202 | var abs = f 203 | if (f.charAt(0) === '/') { 204 | abs = path.join(self.root, f) 205 | } else if (isAbsolute(f) || f === '') { 206 | abs = f 207 | } else if (self.changedCwd) { 208 | abs = path.resolve(self.cwd, f) 209 | } else { 210 | abs = path.resolve(f) 211 | } 212 | 213 | if (process.platform === 'win32') 214 | abs = abs.replace(/\\/g, '/') 215 | 216 | return abs 217 | } 218 | 219 | 220 | // Return true, if pattern ends with globstar '**', for the accompanying parent directory. 221 | // Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents 222 | function isIgnored (self, path) { 223 | if (!self.ignore.length) 224 | return false 225 | 226 | return self.ignore.some(function(item) { 227 | return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path)) 228 | }) 229 | } 230 | 231 | function childrenIgnored (self, path) { 232 | if (!self.ignore.length) 233 | return false 234 | 235 | return self.ignore.some(function(item) { 236 | return !!(item.gmatcher && item.gmatcher.match(path)) 237 | }) 238 | } 239 | -------------------------------------------------------------------------------- /asar_modules/node_modules/@electron/asar/lib/index.d.ts: -------------------------------------------------------------------------------- 1 | import { Stats } from "fs"; 2 | 3 | interface IMinimatchOptions { 4 | /** 5 | * Dump a ton of stuff to stderr. 6 | * 7 | * @default false 8 | */ 9 | debug?: boolean | undefined; 10 | 11 | /** 12 | * Do not expand `{a,b}` and `{1..3}` brace sets. 13 | * 14 | * @default false 15 | */ 16 | nobrace?: boolean | undefined; 17 | 18 | /** 19 | * Disable `**` matching against multiple folder names. 20 | * 21 | * @default false 22 | */ 23 | noglobstar?: boolean | undefined; 24 | 25 | /** 26 | * Allow patterns to match filenames starting with a period, 27 | * even if the pattern does not explicitly have a period in that spot. 28 | * 29 | * Note that by default, `'a/**' + '/b'` will **not** match `a/.d/b`, unless `dot` is set. 30 | * 31 | * @default false 32 | */ 33 | dot?: boolean | undefined; 34 | 35 | /** 36 | * Disable "extglob" style patterns like `+(a|b)`. 37 | * 38 | * @default false 39 | */ 40 | noext?: boolean | undefined; 41 | 42 | /** 43 | * Perform a case-insensitive match. 44 | * 45 | * @default false 46 | */ 47 | nocase?: boolean | undefined; 48 | 49 | /** 50 | * When a match is not found by `minimatch.match`, 51 | * return a list containing the pattern itself if this option is set. 52 | * Otherwise, an empty list is returned if there are no matches. 53 | * 54 | * @default false 55 | */ 56 | nonull?: boolean | undefined; 57 | 58 | /** 59 | * If set, then patterns without slashes will be matched 60 | * against the basename of the path if it contains slashes. For example, 61 | * `a?b` would match the path `/xyz/123/acb`, but not `/xyz/acb/123`. 62 | * 63 | * @default false 64 | */ 65 | matchBase?: boolean | undefined; 66 | 67 | /** 68 | * Suppress the behavior of treating `#` at the start of a pattern as a comment. 69 | * 70 | * @default false 71 | */ 72 | nocomment?: boolean | undefined; 73 | 74 | /** 75 | * Suppress the behavior of treating a leading `!` character as negation. 76 | * 77 | * @default false 78 | */ 79 | nonegate?: boolean | undefined; 80 | 81 | /** 82 | * Returns from negate expressions the same as if they were not negated. 83 | * (Ie, true on a hit, false on a miss.) 84 | * 85 | * @default false 86 | */ 87 | flipNegate?: boolean | undefined; 88 | 89 | /** 90 | * Compare a partial path to a pattern. As long as the parts of the path that 91 | * are present are not contradicted by the pattern, it will be treated as a 92 | * match. This is useful in applications where you're walking through a 93 | * folder structure, and don't yet have the full path, but want to ensure that 94 | * you do not walk down paths that can never be a match. 95 | * 96 | * @default false 97 | * 98 | * @example 99 | * import minimatch = require("minimatch"); 100 | * 101 | * minimatch('/a/b', '/a/*' + '/c/d', { partial: true }) // true, might be /a/b/c/d 102 | * minimatch('/a/b', '/**' + '/d', { partial: true }) // true, might be /a/b/.../d 103 | * minimatch('/x/y/z', '/a/**' + '/z', { partial: true }) // false, because x !== a 104 | */ 105 | partial?: boolean; 106 | 107 | /** 108 | * Use `\\` as a path separator _only_, and _never_ as an escape 109 | * character. If set, all `\\` characters are replaced with `/` in 110 | * the pattern. Note that this makes it **impossible** to match 111 | * against paths containing literal glob pattern characters, but 112 | * allows matching with patterns constructed using `path.join()` and 113 | * `path.resolve()` on Windows platforms, mimicking the (buggy!) 114 | * behavior of earlier versions on Windows. Please use with 115 | * caution, and be mindful of the caveat about Windows paths 116 | * 117 | * For legacy reasons, this is also set if 118 | * `options.allowWindowsEscape` is set to the exact value `false`. 119 | * 120 | * @default false 121 | */ 122 | windowsPathsNoEscape?: boolean; 123 | } 124 | 125 | import fs = require("fs"); 126 | interface IGlobOptions extends IMinimatchOptions { 127 | cwd?: string | undefined; 128 | root?: string | undefined; 129 | dot?: boolean | undefined; 130 | nomount?: boolean | undefined; 131 | mark?: boolean | undefined; 132 | nosort?: boolean | undefined; 133 | stat?: boolean | undefined; 134 | silent?: boolean | undefined; 135 | strict?: boolean | undefined; 136 | cache?: 137 | | { [path: string]: boolean | "DIR" | "FILE" | ReadonlyArray } 138 | | undefined; 139 | statCache?: 140 | | { [path: string]: false | { isDirectory(): boolean } | undefined } 141 | | undefined; 142 | symlinks?: { [path: string]: boolean | undefined } | undefined; 143 | realpathCache?: { [path: string]: string } | undefined; 144 | sync?: boolean | undefined; 145 | nounique?: boolean | undefined; 146 | nonull?: boolean | undefined; 147 | debug?: boolean | undefined; 148 | nobrace?: boolean | undefined; 149 | noglobstar?: boolean | undefined; 150 | noext?: boolean | undefined; 151 | nocase?: boolean | undefined; 152 | matchBase?: any; 153 | nodir?: boolean | undefined; 154 | ignore?: string | ReadonlyArray | undefined; 155 | follow?: boolean | undefined; 156 | realpath?: boolean | undefined; 157 | nonegate?: boolean | undefined; 158 | nocomment?: boolean | undefined; 159 | absolute?: boolean | undefined; 160 | allowWindowsEscape?: boolean | undefined; 161 | fs?: typeof fs; 162 | } 163 | 164 | export type CreateOptions = { 165 | dot?: boolean; 166 | globOptions?: IGlobOptions; 167 | ordering?: string; 168 | pattern?: string; 169 | transform?: (filePath: string) => NodeJS.ReadWriteStream | void; 170 | unpack?: string; 171 | unpackDir?: string; 172 | }; 173 | 174 | export type ListOptions = { 175 | isPack: boolean; 176 | }; 177 | 178 | export type EntryMetadata = { 179 | unpacked: boolean; 180 | }; 181 | 182 | export type DirectoryMetadata = EntryMetadata & { 183 | files: { [property: string]: EntryMetadata }; 184 | }; 185 | 186 | export type FileMetadata = EntryMetadata & { 187 | executable?: true; 188 | offset?: number; 189 | size?: number; 190 | }; 191 | 192 | export type LinkMetadata = { 193 | link: string; 194 | }; 195 | 196 | export type Metadata = DirectoryMetadata | FileMetadata | LinkMetadata; 197 | 198 | export type InputMetadataType = 'directory' | 'file' | 'link'; 199 | 200 | export type InputMetadata = { 201 | [property: string]: { 202 | type: InputMetadataType; 203 | stat: Stats; 204 | } 205 | }; 206 | 207 | export type DirectoryRecord = { 208 | files: Record; 209 | }; 210 | 211 | export type FileRecord = { 212 | offset: string; 213 | size: number; 214 | executable?: boolean; 215 | integrity: { 216 | hash: string; 217 | algorithm: 'SHA256'; 218 | blocks: string[]; 219 | blockSize: number; 220 | }; 221 | } 222 | 223 | export type ArchiveHeader = { 224 | // The JSON parsed header string 225 | header: DirectoryRecord; 226 | headerString: string; 227 | headerSize: number; 228 | } 229 | 230 | export function createPackage(src: string, dest: string): Promise; 231 | export function createPackageWithOptions( 232 | src: string, 233 | dest: string, 234 | options: CreateOptions 235 | ): Promise; 236 | export function createPackageFromFiles( 237 | src: string, 238 | dest: string, 239 | filenames: string[], 240 | metadata?: InputMetadata, 241 | options?: CreateOptions 242 | ): Promise; 243 | 244 | export function statFile(archive: string, filename: string, followLinks?: boolean): Metadata; 245 | export function getRawHeader(archive: string): ArchiveHeader; 246 | export function listPackage(archive: string, options?: ListOptions): string[]; 247 | export function extractFile(archive: string, filename: string): Buffer; 248 | export function extractAll(archive: string, dest: string): void; 249 | export function uncache(archive: string): boolean; 250 | export function uncacheAll(): void; 251 | -------------------------------------------------------------------------------- /asar_modules/node_modules/minimatch/README.md: -------------------------------------------------------------------------------- 1 | # minimatch 2 | 3 | A minimal matching utility. 4 | 5 | [![Build Status](https://travis-ci.org/isaacs/minimatch.svg?branch=master)](http://travis-ci.org/isaacs/minimatch) 6 | 7 | 8 | This is the matching library used internally by npm. 9 | 10 | It works by converting glob expressions into JavaScript `RegExp` 11 | objects. 12 | 13 | ## Usage 14 | 15 | ```javascript 16 | var minimatch = require("minimatch") 17 | 18 | minimatch("bar.foo", "*.foo") // true! 19 | minimatch("bar.foo", "*.bar") // false! 20 | minimatch("bar.foo", "*.+(bar|foo)", { debug: true }) // true, and noisy! 21 | ``` 22 | 23 | ## Features 24 | 25 | Supports these glob features: 26 | 27 | * Brace Expansion 28 | * Extended glob matching 29 | * "Globstar" `**` matching 30 | 31 | See: 32 | 33 | * `man sh` 34 | * `man bash` 35 | * `man 3 fnmatch` 36 | * `man 5 gitignore` 37 | 38 | ## Minimatch Class 39 | 40 | Create a minimatch object by instantiating the `minimatch.Minimatch` class. 41 | 42 | ```javascript 43 | var Minimatch = require("minimatch").Minimatch 44 | var mm = new Minimatch(pattern, options) 45 | ``` 46 | 47 | ### Properties 48 | 49 | * `pattern` The original pattern the minimatch object represents. 50 | * `options` The options supplied to the constructor. 51 | * `set` A 2-dimensional array of regexp or string expressions. 52 | Each row in the 53 | array corresponds to a brace-expanded pattern. Each item in the row 54 | corresponds to a single path-part. For example, the pattern 55 | `{a,b/c}/d` would expand to a set of patterns like: 56 | 57 | [ [ a, d ] 58 | , [ b, c, d ] ] 59 | 60 | If a portion of the pattern doesn't have any "magic" in it 61 | (that is, it's something like `"foo"` rather than `fo*o?`), then it 62 | will be left as a string rather than converted to a regular 63 | expression. 64 | 65 | * `regexp` Created by the `makeRe` method. A single regular expression 66 | expressing the entire pattern. This is useful in cases where you wish 67 | to use the pattern somewhat like `fnmatch(3)` with `FNM_PATH` enabled. 68 | * `negate` True if the pattern is negated. 69 | * `comment` True if the pattern is a comment. 70 | * `empty` True if the pattern is `""`. 71 | 72 | ### Methods 73 | 74 | * `makeRe` Generate the `regexp` member if necessary, and return it. 75 | Will return `false` if the pattern is invalid. 76 | * `match(fname)` Return true if the filename matches the pattern, or 77 | false otherwise. 78 | * `matchOne(fileArray, patternArray, partial)` Take a `/`-split 79 | filename, and match it against a single row in the `regExpSet`. This 80 | method is mainly for internal use, but is exposed so that it can be 81 | used by a glob-walker that needs to avoid excessive filesystem calls. 82 | 83 | All other methods are internal, and will be called as necessary. 84 | 85 | ### minimatch(path, pattern, options) 86 | 87 | Main export. Tests a path against the pattern using the options. 88 | 89 | ```javascript 90 | var isJS = minimatch(file, "*.js", { matchBase: true }) 91 | ``` 92 | 93 | ### minimatch.filter(pattern, options) 94 | 95 | Returns a function that tests its 96 | supplied argument, suitable for use with `Array.filter`. Example: 97 | 98 | ```javascript 99 | var javascripts = fileList.filter(minimatch.filter("*.js", {matchBase: true})) 100 | ``` 101 | 102 | ### minimatch.match(list, pattern, options) 103 | 104 | Match against the list of 105 | files, in the style of fnmatch or glob. If nothing is matched, and 106 | options.nonull is set, then return a list containing the pattern itself. 107 | 108 | ```javascript 109 | var javascripts = minimatch.match(fileList, "*.js", {matchBase: true})) 110 | ``` 111 | 112 | ### minimatch.makeRe(pattern, options) 113 | 114 | Make a regular expression object from the pattern. 115 | 116 | ## Options 117 | 118 | All options are `false` by default. 119 | 120 | ### debug 121 | 122 | Dump a ton of stuff to stderr. 123 | 124 | ### nobrace 125 | 126 | Do not expand `{a,b}` and `{1..3}` brace sets. 127 | 128 | ### noglobstar 129 | 130 | Disable `**` matching against multiple folder names. 131 | 132 | ### dot 133 | 134 | Allow patterns to match filenames starting with a period, even if 135 | the pattern does not explicitly have a period in that spot. 136 | 137 | Note that by default, `a/**/b` will **not** match `a/.d/b`, unless `dot` 138 | is set. 139 | 140 | ### noext 141 | 142 | Disable "extglob" style patterns like `+(a|b)`. 143 | 144 | ### nocase 145 | 146 | Perform a case-insensitive match. 147 | 148 | ### nonull 149 | 150 | When a match is not found by `minimatch.match`, return a list containing 151 | the pattern itself if this option is set. When not set, an empty list 152 | is returned if there are no matches. 153 | 154 | ### matchBase 155 | 156 | If set, then patterns without slashes will be matched 157 | against the basename of the path if it contains slashes. For example, 158 | `a?b` would match the path `/xyz/123/acb`, but not `/xyz/acb/123`. 159 | 160 | ### nocomment 161 | 162 | Suppress the behavior of treating `#` at the start of a pattern as a 163 | comment. 164 | 165 | ### nonegate 166 | 167 | Suppress the behavior of treating a leading `!` character as negation. 168 | 169 | ### flipNegate 170 | 171 | Returns from negate expressions the same as if they were not negated. 172 | (Ie, true on a hit, false on a miss.) 173 | 174 | ### partial 175 | 176 | Compare a partial path to a pattern. As long as the parts of the path that 177 | are present are not contradicted by the pattern, it will be treated as a 178 | match. This is useful in applications where you're walking through a 179 | folder structure, and don't yet have the full path, but want to ensure that 180 | you do not walk down paths that can never be a match. 181 | 182 | For example, 183 | 184 | ```js 185 | minimatch('/a/b', '/a/*/c/d', { partial: true }) // true, might be /a/b/c/d 186 | minimatch('/a/b', '/**/d', { partial: true }) // true, might be /a/b/.../d 187 | minimatch('/x/y/z', '/a/**/z', { partial: true }) // false, because x !== a 188 | ``` 189 | 190 | ### allowWindowsEscape 191 | 192 | Windows path separator `\` is by default converted to `/`, which 193 | prohibits the usage of `\` as a escape character. This flag skips that 194 | behavior and allows using the escape character. 195 | 196 | ## Comparisons to other fnmatch/glob implementations 197 | 198 | While strict compliance with the existing standards is a worthwhile 199 | goal, some discrepancies exist between minimatch and other 200 | implementations, and are intentional. 201 | 202 | If the pattern starts with a `!` character, then it is negated. Set the 203 | `nonegate` flag to suppress this behavior, and treat leading `!` 204 | characters normally. This is perhaps relevant if you wish to start the 205 | pattern with a negative extglob pattern like `!(a|B)`. Multiple `!` 206 | characters at the start of a pattern will negate the pattern multiple 207 | times. 208 | 209 | If a pattern starts with `#`, then it is treated as a comment, and 210 | will not match anything. Use `\#` to match a literal `#` at the 211 | start of a line, or set the `nocomment` flag to suppress this behavior. 212 | 213 | The double-star character `**` is supported by default, unless the 214 | `noglobstar` flag is set. This is supported in the manner of bsdglob 215 | and bash 4.1, where `**` only has special significance if it is the only 216 | thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but 217 | `a/**b` will not. 218 | 219 | If an escaped pattern has no matches, and the `nonull` flag is set, 220 | then minimatch.match returns the pattern as-provided, rather than 221 | interpreting the character escapes. For example, 222 | `minimatch.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than 223 | `"*a?"`. This is akin to setting the `nullglob` option in bash, except 224 | that it does not resolve escaped pattern characters. 225 | 226 | If brace expansion is not disabled, then it is performed before any 227 | other interpretation of the glob pattern. Thus, a pattern like 228 | `+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded 229 | **first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are 230 | checked for validity. Since those two are valid, matching proceeds. 231 | -------------------------------------------------------------------------------- /asar_modules/node_modules/@electron/asar/lib/pickle.js: -------------------------------------------------------------------------------- 1 | // sizeof(T). 2 | const SIZE_INT32 = 4 3 | const SIZE_UINT32 = 4 4 | const SIZE_INT64 = 8 5 | const SIZE_UINT64 = 8 6 | const SIZE_FLOAT = 4 7 | const SIZE_DOUBLE = 8 8 | 9 | // The allocation granularity of the payload. 10 | const PAYLOAD_UNIT = 64 11 | 12 | // Largest JS number. 13 | const CAPACITY_READ_ONLY = 9007199254740992 14 | 15 | // Aligns 'i' by rounding it up to the next multiple of 'alignment'. 16 | const alignInt = function (i, alignment) { 17 | return i + (alignment - (i % alignment)) % alignment 18 | } 19 | 20 | // PickleIterator reads data from a Pickle. The Pickle object must remain valid 21 | // while the PickleIterator object is in use. 22 | const PickleIterator = (function () { 23 | function PickleIterator (pickle) { 24 | this.payload = pickle.header 25 | this.payloadOffset = pickle.headerSize 26 | this.readIndex = 0 27 | this.endIndex = pickle.getPayloadSize() 28 | } 29 | 30 | PickleIterator.prototype.readBool = function () { 31 | return this.readInt() !== 0 32 | } 33 | 34 | PickleIterator.prototype.readInt = function () { 35 | return this.readBytes(SIZE_INT32, Buffer.prototype.readInt32LE) 36 | } 37 | 38 | PickleIterator.prototype.readUInt32 = function () { 39 | return this.readBytes(SIZE_UINT32, Buffer.prototype.readUInt32LE) 40 | } 41 | 42 | PickleIterator.prototype.readInt64 = function () { 43 | return this.readBytes(SIZE_INT64, Buffer.prototype.readInt64LE) 44 | } 45 | 46 | PickleIterator.prototype.readUInt64 = function () { 47 | return this.readBytes(SIZE_UINT64, Buffer.prototype.readUInt64LE) 48 | } 49 | 50 | PickleIterator.prototype.readFloat = function () { 51 | return this.readBytes(SIZE_FLOAT, Buffer.prototype.readFloatLE) 52 | } 53 | 54 | PickleIterator.prototype.readDouble = function () { 55 | return this.readBytes(SIZE_DOUBLE, Buffer.prototype.readDoubleLE) 56 | } 57 | 58 | PickleIterator.prototype.readString = function () { 59 | return this.readBytes(this.readInt()).toString() 60 | } 61 | 62 | PickleIterator.prototype.readBytes = function (length, method) { 63 | const readPayloadOffset = this.getReadPayloadOffsetAndAdvance(length) 64 | if (method != null) { 65 | return method.call(this.payload, readPayloadOffset, length) 66 | } else { 67 | return this.payload.slice(readPayloadOffset, readPayloadOffset + length) 68 | } 69 | } 70 | 71 | PickleIterator.prototype.getReadPayloadOffsetAndAdvance = function (length) { 72 | if (length > this.endIndex - this.readIndex) { 73 | this.readIndex = this.endIndex 74 | throw new Error('Failed to read data with length of ' + length) 75 | } 76 | const readPayloadOffset = this.payloadOffset + this.readIndex 77 | this.advance(length) 78 | return readPayloadOffset 79 | } 80 | 81 | PickleIterator.prototype.advance = function (size) { 82 | const alignedSize = alignInt(size, SIZE_UINT32) 83 | if (this.endIndex - this.readIndex < alignedSize) { 84 | this.readIndex = this.endIndex 85 | } else { 86 | this.readIndex += alignedSize 87 | } 88 | } 89 | 90 | return PickleIterator 91 | })() 92 | 93 | // This class provides facilities for basic binary value packing and unpacking. 94 | // 95 | // The Pickle class supports appending primitive values (ints, strings, etc.) 96 | // to a pickle instance. The Pickle instance grows its internal memory buffer 97 | // dynamically to hold the sequence of primitive values. The internal memory 98 | // buffer is exposed as the "data" of the Pickle. This "data" can be passed 99 | // to a Pickle object to initialize it for reading. 100 | // 101 | // When reading from a Pickle object, it is important for the consumer to know 102 | // what value types to read and in what order to read them as the Pickle does 103 | // not keep track of the type of data written to it. 104 | // 105 | // The Pickle's data has a header which contains the size of the Pickle's 106 | // payload. It can optionally support additional space in the header. That 107 | // space is controlled by the header_size parameter passed to the Pickle 108 | // constructor. 109 | const Pickle = (function () { 110 | function Pickle (buffer) { 111 | if (buffer) { 112 | this.initFromBuffer(buffer) 113 | } else { 114 | this.initEmpty() 115 | } 116 | } 117 | 118 | Pickle.prototype.initEmpty = function () { 119 | this.header = Buffer.alloc(0) 120 | this.headerSize = SIZE_UINT32 121 | this.capacityAfterHeader = 0 122 | this.writeOffset = 0 123 | this.resize(PAYLOAD_UNIT) 124 | this.setPayloadSize(0) 125 | } 126 | 127 | Pickle.prototype.initFromBuffer = function (buffer) { 128 | this.header = buffer 129 | this.headerSize = buffer.length - this.getPayloadSize() 130 | this.capacityAfterHeader = CAPACITY_READ_ONLY 131 | this.writeOffset = 0 132 | if (this.headerSize > buffer.length) { 133 | this.headerSize = 0 134 | } 135 | if (this.headerSize !== alignInt(this.headerSize, SIZE_UINT32)) { 136 | this.headerSize = 0 137 | } 138 | if (this.headerSize === 0) { 139 | this.header = Buffer.alloc(0) 140 | } 141 | } 142 | 143 | Pickle.prototype.createIterator = function () { 144 | return new PickleIterator(this) 145 | } 146 | 147 | Pickle.prototype.toBuffer = function () { 148 | return this.header.slice(0, this.headerSize + this.getPayloadSize()) 149 | } 150 | 151 | Pickle.prototype.writeBool = function (value) { 152 | return this.writeInt(value ? 1 : 0) 153 | } 154 | 155 | Pickle.prototype.writeInt = function (value) { 156 | return this.writeBytes(value, SIZE_INT32, Buffer.prototype.writeInt32LE) 157 | } 158 | 159 | Pickle.prototype.writeUInt32 = function (value) { 160 | return this.writeBytes(value, SIZE_UINT32, Buffer.prototype.writeUInt32LE) 161 | } 162 | 163 | Pickle.prototype.writeInt64 = function (value) { 164 | return this.writeBytes(value, SIZE_INT64, Buffer.prototype.writeInt64LE) 165 | } 166 | 167 | Pickle.prototype.writeUInt64 = function (value) { 168 | return this.writeBytes(value, SIZE_UINT64, Buffer.prototype.writeUInt64LE) 169 | } 170 | 171 | Pickle.prototype.writeFloat = function (value) { 172 | return this.writeBytes(value, SIZE_FLOAT, Buffer.prototype.writeFloatLE) 173 | } 174 | 175 | Pickle.prototype.writeDouble = function (value) { 176 | return this.writeBytes(value, SIZE_DOUBLE, Buffer.prototype.writeDoubleLE) 177 | } 178 | 179 | Pickle.prototype.writeString = function (value) { 180 | const length = Buffer.byteLength(value, 'utf8') 181 | if (!this.writeInt(length)) { 182 | return false 183 | } 184 | return this.writeBytes(value, length) 185 | } 186 | 187 | Pickle.prototype.setPayloadSize = function (payloadSize) { 188 | return this.header.writeUInt32LE(payloadSize, 0) 189 | } 190 | 191 | Pickle.prototype.getPayloadSize = function () { 192 | return this.header.readUInt32LE(0) 193 | } 194 | 195 | Pickle.prototype.writeBytes = function (data, length, method) { 196 | const dataLength = alignInt(length, SIZE_UINT32) 197 | const newSize = this.writeOffset + dataLength 198 | if (newSize > this.capacityAfterHeader) { 199 | this.resize(Math.max(this.capacityAfterHeader * 2, newSize)) 200 | } 201 | if (method != null) { 202 | method.call(this.header, data, this.headerSize + this.writeOffset) 203 | } else { 204 | this.header.write(data, this.headerSize + this.writeOffset, length) 205 | } 206 | const endOffset = this.headerSize + this.writeOffset + length 207 | this.header.fill(0, endOffset, endOffset + dataLength - length) 208 | this.setPayloadSize(newSize) 209 | this.writeOffset = newSize 210 | return true 211 | } 212 | 213 | Pickle.prototype.resize = function (newCapacity) { 214 | newCapacity = alignInt(newCapacity, PAYLOAD_UNIT) 215 | this.header = Buffer.concat([this.header, Buffer.alloc(newCapacity)]) 216 | this.capacityAfterHeader = newCapacity 217 | } 218 | 219 | return Pickle 220 | })() 221 | 222 | module.exports = { 223 | createEmpty: function () { 224 | return new Pickle() 225 | }, 226 | 227 | createFromBuffer: function (buffer) { 228 | return new Pickle(buffer) 229 | } 230 | } 231 | -------------------------------------------------------------------------------- /asar_modules/node_modules/@electron/asar/lib/asar.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const fs = require('./wrapped-fs') 4 | const path = require('path') 5 | const minimatch = require('minimatch') 6 | 7 | const Filesystem = require('./filesystem') 8 | const disk = require('./disk') 9 | const crawlFilesystem = require('./crawlfs') 10 | 11 | /** 12 | * Whether a directory should be excluded from packing due to the `--unpack-dir" option. 13 | * 14 | * @param {string} dirPath - directory path to check 15 | * @param {string} pattern - literal prefix [for backward compatibility] or glob pattern 16 | * @param {array} unpackDirs - Array of directory paths previously marked as unpacked 17 | */ 18 | function isUnpackedDir (dirPath, pattern, unpackDirs) { 19 | if (dirPath.startsWith(pattern) || minimatch(dirPath, pattern)) { 20 | if (!unpackDirs.includes(dirPath)) { 21 | unpackDirs.push(dirPath) 22 | } 23 | return true 24 | } else { 25 | return unpackDirs.some(unpackDir => dirPath.startsWith(unpackDir)) 26 | } 27 | } 28 | 29 | module.exports.createPackage = async function (src, dest) { 30 | return module.exports.createPackageWithOptions(src, dest, {}) 31 | } 32 | 33 | module.exports.createPackageWithOptions = async function (src, dest, options) { 34 | const globOptions = options.globOptions ? options.globOptions : {} 35 | globOptions.dot = options.dot === undefined ? true : options.dot 36 | 37 | const pattern = src + (options.pattern ? options.pattern : '/**/*') 38 | 39 | const [filenames, metadata] = await crawlFilesystem(pattern, globOptions) 40 | return module.exports.createPackageFromFiles(src, dest, filenames, metadata, options) 41 | } 42 | 43 | /** 44 | * Create an ASAR archive from a list of filenames. 45 | * 46 | * @param {string} src: Base path. All files are relative to this. 47 | * @param {string} dest: Archive filename (& path). 48 | * @param {array} filenames: List of filenames relative to src. 49 | * @param {object} metadata: Object with filenames as keys and {type='directory|file|link', stat: fs.stat} as values. (Optional) 50 | * @param {object} options: Options passed to `createPackageWithOptions`. 51 | */ 52 | module.exports.createPackageFromFiles = async function (src, dest, filenames, metadata, options) { 53 | if (typeof metadata === 'undefined' || metadata === null) { metadata = {} } 54 | if (typeof options === 'undefined' || options === null) { options = {} } 55 | 56 | src = path.normalize(src) 57 | dest = path.normalize(dest) 58 | filenames = filenames.map(function (filename) { return path.normalize(filename) }) 59 | 60 | const filesystem = new Filesystem(src) 61 | const files = [] 62 | const unpackDirs = [] 63 | 64 | let filenamesSorted = [] 65 | if (options.ordering) { 66 | const orderingFiles = (await fs.readFile(options.ordering)).toString().split('\n').map(line => { 67 | if (line.includes(':')) { line = line.split(':').pop() } 68 | line = line.trim() 69 | if (line.startsWith('/')) { line = line.slice(1) } 70 | return line 71 | }) 72 | 73 | const ordering = [] 74 | for (const file of orderingFiles) { 75 | const pathComponents = file.split(path.sep) 76 | let str = src 77 | for (const pathComponent of pathComponents) { 78 | str = path.join(str, pathComponent) 79 | ordering.push(str) 80 | } 81 | } 82 | 83 | let missing = 0 84 | const total = filenames.length 85 | 86 | for (const file of ordering) { 87 | if (!filenamesSorted.includes(file) && filenames.includes(file)) { 88 | filenamesSorted.push(file) 89 | } 90 | } 91 | 92 | for (const file of filenames) { 93 | if (!filenamesSorted.includes(file)) { 94 | filenamesSorted.push(file) 95 | missing += 1 96 | } 97 | } 98 | 99 | console.log(`Ordering file has ${((total - missing) / total) * 100}% coverage.`) 100 | } else { 101 | filenamesSorted = filenames 102 | } 103 | 104 | const handleFile = async function (filename) { 105 | if (!metadata[filename]) { 106 | metadata[filename] = await crawlFilesystem.determineFileType(filename) 107 | } 108 | const file = metadata[filename] 109 | 110 | let shouldUnpack 111 | switch (file.type) { 112 | case 'directory': 113 | if (options.unpackDir) { 114 | shouldUnpack = isUnpackedDir(path.relative(src, filename), options.unpackDir, unpackDirs) 115 | } else { 116 | shouldUnpack = false 117 | } 118 | filesystem.insertDirectory(filename, shouldUnpack) 119 | break 120 | case 'file': 121 | shouldUnpack = false 122 | if (options.unpack) { 123 | shouldUnpack = minimatch(filename, options.unpack, { matchBase: true }) 124 | } 125 | if (!shouldUnpack && options.unpackDir) { 126 | const dirName = path.relative(src, path.dirname(filename)) 127 | shouldUnpack = isUnpackedDir(dirName, options.unpackDir, unpackDirs) 128 | } 129 | files.push({ filename: filename, unpack: shouldUnpack }) 130 | return filesystem.insertFile(filename, shouldUnpack, file, options) 131 | case 'link': 132 | filesystem.insertLink(filename) 133 | break 134 | } 135 | return Promise.resolve() 136 | } 137 | 138 | const insertsDone = async function () { 139 | await fs.mkdirp(path.dirname(dest)) 140 | return disk.writeFilesystem(dest, filesystem, files, metadata) 141 | } 142 | 143 | const names = filenamesSorted.slice() 144 | 145 | const next = async function (name) { 146 | if (!name) { return insertsDone() } 147 | 148 | await handleFile(name) 149 | return next(names.shift()) 150 | } 151 | 152 | return next(names.shift()) 153 | } 154 | 155 | module.exports.statFile = function (archive, filename, followLinks) { 156 | const filesystem = disk.readFilesystemSync(archive) 157 | return filesystem.getFile(filename, followLinks) 158 | } 159 | 160 | module.exports.getRawHeader = function (archive) { 161 | return disk.readArchiveHeaderSync(archive) 162 | } 163 | 164 | module.exports.listPackage = function (archive, options) { 165 | return disk.readFilesystemSync(archive).listFiles(options) 166 | } 167 | 168 | module.exports.extractFile = function (archive, filename) { 169 | const filesystem = disk.readFilesystemSync(archive) 170 | return disk.readFileSync(filesystem, filename, filesystem.getFile(filename)) 171 | } 172 | 173 | module.exports.extractAll = function (archive, dest) { 174 | const filesystem = disk.readFilesystemSync(archive) 175 | const filenames = filesystem.listFiles() 176 | 177 | // under windows just extract links as regular files 178 | const followLinks = process.platform === 'win32' 179 | 180 | // create destination directory 181 | fs.mkdirpSync(dest) 182 | 183 | const extractionErrors = [] 184 | for (const fullPath of filenames) { 185 | // Remove leading slash 186 | const filename = fullPath.substr(1) 187 | const destFilename = path.join(dest, filename) 188 | const file = filesystem.getFile(filename, followLinks) 189 | if (file.files) { 190 | // it's a directory, create it and continue with the next entry 191 | fs.mkdirpSync(destFilename) 192 | } else if (file.link) { 193 | // it's a symlink, create a symlink 194 | const linkSrcPath = path.dirname(path.join(dest, file.link)) 195 | const linkDestPath = path.dirname(destFilename) 196 | const relativePath = path.relative(linkDestPath, linkSrcPath) 197 | // try to delete output file, because we can't overwrite a link 198 | try { 199 | fs.unlinkSync(destFilename) 200 | } catch {} 201 | const linkTo = path.join(relativePath, path.basename(file.link)) 202 | fs.symlinkSync(linkTo, destFilename) 203 | } else { 204 | // it's a file, try to extract it 205 | try { 206 | const content = disk.readFileSync(filesystem, filename, file) 207 | fs.writeFileSync(destFilename, content) 208 | if (file.executable) { 209 | fs.chmodSync(destFilename, '755') 210 | } 211 | } catch (e) { 212 | extractionErrors.push(e) 213 | } 214 | } 215 | } 216 | if (extractionErrors.length) { 217 | throw new Error( 218 | 'Unable to extract some files:\n\n' + 219 | extractionErrors.map(error => error.stack).join('\n\n')) 220 | } 221 | } 222 | 223 | module.exports.uncache = function (archive) { 224 | return disk.uncacheFilesystem(archive) 225 | } 226 | 227 | module.exports.uncacheAll = function () { 228 | disk.uncacheAll() 229 | } 230 | -------------------------------------------------------------------------------- /asar_modules/node_modules/fs.realpath/old.js: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | var pathModule = require('path'); 23 | var isWindows = process.platform === 'win32'; 24 | var fs = require('fs'); 25 | 26 | // JavaScript implementation of realpath, ported from node pre-v6 27 | 28 | var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG); 29 | 30 | function rethrow() { 31 | // Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and 32 | // is fairly slow to generate. 33 | var callback; 34 | if (DEBUG) { 35 | var backtrace = new Error; 36 | callback = debugCallback; 37 | } else 38 | callback = missingCallback; 39 | 40 | return callback; 41 | 42 | function debugCallback(err) { 43 | if (err) { 44 | backtrace.message = err.message; 45 | err = backtrace; 46 | missingCallback(err); 47 | } 48 | } 49 | 50 | function missingCallback(err) { 51 | if (err) { 52 | if (process.throwDeprecation) 53 | throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs 54 | else if (!process.noDeprecation) { 55 | var msg = 'fs: missing callback ' + (err.stack || err.message); 56 | if (process.traceDeprecation) 57 | console.trace(msg); 58 | else 59 | console.error(msg); 60 | } 61 | } 62 | } 63 | } 64 | 65 | function maybeCallback(cb) { 66 | return typeof cb === 'function' ? cb : rethrow(); 67 | } 68 | 69 | var normalize = pathModule.normalize; 70 | 71 | // Regexp that finds the next partion of a (partial) path 72 | // result is [base_with_slash, base], e.g. ['somedir/', 'somedir'] 73 | if (isWindows) { 74 | var nextPartRe = /(.*?)(?:[\/\\]+|$)/g; 75 | } else { 76 | var nextPartRe = /(.*?)(?:[\/]+|$)/g; 77 | } 78 | 79 | // Regex to find the device root, including trailing slash. E.g. 'c:\\'. 80 | if (isWindows) { 81 | var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/; 82 | } else { 83 | var splitRootRe = /^[\/]*/; 84 | } 85 | 86 | exports.realpathSync = function realpathSync(p, cache) { 87 | // make p is absolute 88 | p = pathModule.resolve(p); 89 | 90 | if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { 91 | return cache[p]; 92 | } 93 | 94 | var original = p, 95 | seenLinks = {}, 96 | knownHard = {}; 97 | 98 | // current character position in p 99 | var pos; 100 | // the partial path so far, including a trailing slash if any 101 | var current; 102 | // the partial path without a trailing slash (except when pointing at a root) 103 | var base; 104 | // the partial path scanned in the previous round, with slash 105 | var previous; 106 | 107 | start(); 108 | 109 | function start() { 110 | // Skip over roots 111 | var m = splitRootRe.exec(p); 112 | pos = m[0].length; 113 | current = m[0]; 114 | base = m[0]; 115 | previous = ''; 116 | 117 | // On windows, check that the root exists. On unix there is no need. 118 | if (isWindows && !knownHard[base]) { 119 | fs.lstatSync(base); 120 | knownHard[base] = true; 121 | } 122 | } 123 | 124 | // walk down the path, swapping out linked pathparts for their real 125 | // values 126 | // NB: p.length changes. 127 | while (pos < p.length) { 128 | // find the next part 129 | nextPartRe.lastIndex = pos; 130 | var result = nextPartRe.exec(p); 131 | previous = current; 132 | current += result[0]; 133 | base = previous + result[1]; 134 | pos = nextPartRe.lastIndex; 135 | 136 | // continue if not a symlink 137 | if (knownHard[base] || (cache && cache[base] === base)) { 138 | continue; 139 | } 140 | 141 | var resolvedLink; 142 | if (cache && Object.prototype.hasOwnProperty.call(cache, base)) { 143 | // some known symbolic link. no need to stat again. 144 | resolvedLink = cache[base]; 145 | } else { 146 | var stat = fs.lstatSync(base); 147 | if (!stat.isSymbolicLink()) { 148 | knownHard[base] = true; 149 | if (cache) cache[base] = base; 150 | continue; 151 | } 152 | 153 | // read the link if it wasn't read before 154 | // dev/ino always return 0 on windows, so skip the check. 155 | var linkTarget = null; 156 | if (!isWindows) { 157 | var id = stat.dev.toString(32) + ':' + stat.ino.toString(32); 158 | if (seenLinks.hasOwnProperty(id)) { 159 | linkTarget = seenLinks[id]; 160 | } 161 | } 162 | if (linkTarget === null) { 163 | fs.statSync(base); 164 | linkTarget = fs.readlinkSync(base); 165 | } 166 | resolvedLink = pathModule.resolve(previous, linkTarget); 167 | // track this, if given a cache. 168 | if (cache) cache[base] = resolvedLink; 169 | if (!isWindows) seenLinks[id] = linkTarget; 170 | } 171 | 172 | // resolve the link, then start over 173 | p = pathModule.resolve(resolvedLink, p.slice(pos)); 174 | start(); 175 | } 176 | 177 | if (cache) cache[original] = p; 178 | 179 | return p; 180 | }; 181 | 182 | 183 | exports.realpath = function realpath(p, cache, cb) { 184 | if (typeof cb !== 'function') { 185 | cb = maybeCallback(cache); 186 | cache = null; 187 | } 188 | 189 | // make p is absolute 190 | p = pathModule.resolve(p); 191 | 192 | if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { 193 | return process.nextTick(cb.bind(null, null, cache[p])); 194 | } 195 | 196 | var original = p, 197 | seenLinks = {}, 198 | knownHard = {}; 199 | 200 | // current character position in p 201 | var pos; 202 | // the partial path so far, including a trailing slash if any 203 | var current; 204 | // the partial path without a trailing slash (except when pointing at a root) 205 | var base; 206 | // the partial path scanned in the previous round, with slash 207 | var previous; 208 | 209 | start(); 210 | 211 | function start() { 212 | // Skip over roots 213 | var m = splitRootRe.exec(p); 214 | pos = m[0].length; 215 | current = m[0]; 216 | base = m[0]; 217 | previous = ''; 218 | 219 | // On windows, check that the root exists. On unix there is no need. 220 | if (isWindows && !knownHard[base]) { 221 | fs.lstat(base, function(err) { 222 | if (err) return cb(err); 223 | knownHard[base] = true; 224 | LOOP(); 225 | }); 226 | } else { 227 | process.nextTick(LOOP); 228 | } 229 | } 230 | 231 | // walk down the path, swapping out linked pathparts for their real 232 | // values 233 | function LOOP() { 234 | // stop if scanned past end of path 235 | if (pos >= p.length) { 236 | if (cache) cache[original] = p; 237 | return cb(null, p); 238 | } 239 | 240 | // find the next part 241 | nextPartRe.lastIndex = pos; 242 | var result = nextPartRe.exec(p); 243 | previous = current; 244 | current += result[0]; 245 | base = previous + result[1]; 246 | pos = nextPartRe.lastIndex; 247 | 248 | // continue if not a symlink 249 | if (knownHard[base] || (cache && cache[base] === base)) { 250 | return process.nextTick(LOOP); 251 | } 252 | 253 | if (cache && Object.prototype.hasOwnProperty.call(cache, base)) { 254 | // known symbolic link. no need to stat again. 255 | return gotResolvedLink(cache[base]); 256 | } 257 | 258 | return fs.lstat(base, gotStat); 259 | } 260 | 261 | function gotStat(err, stat) { 262 | if (err) return cb(err); 263 | 264 | // if not a symlink, skip to the next path part 265 | if (!stat.isSymbolicLink()) { 266 | knownHard[base] = true; 267 | if (cache) cache[base] = base; 268 | return process.nextTick(LOOP); 269 | } 270 | 271 | // stat & read the link if not read before 272 | // call gotTarget as soon as the link target is known 273 | // dev/ino always return 0 on windows, so skip the check. 274 | if (!isWindows) { 275 | var id = stat.dev.toString(32) + ':' + stat.ino.toString(32); 276 | if (seenLinks.hasOwnProperty(id)) { 277 | return gotTarget(null, seenLinks[id], base); 278 | } 279 | } 280 | fs.stat(base, function(err) { 281 | if (err) return cb(err); 282 | 283 | fs.readlink(base, function(err, target) { 284 | if (!isWindows) seenLinks[id] = target; 285 | gotTarget(err, target); 286 | }); 287 | }); 288 | } 289 | 290 | function gotTarget(err, target, base) { 291 | if (err) return cb(err); 292 | 293 | var resolvedLink = pathModule.resolve(previous, target); 294 | if (cache) cache[base] = resolvedLink; 295 | gotResolvedLink(resolvedLink); 296 | } 297 | 298 | function gotResolvedLink(resolvedLink) { 299 | // resolve the link, then start over 300 | p = pathModule.resolve(resolvedLink, p.slice(pos)); 301 | start(); 302 | } 303 | }; 304 | -------------------------------------------------------------------------------- /asar_modules/node_modules/commander/typings/index.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for commander 2 | // Original definitions by: Alan Agius , Marcelo Dezem , vvakame , Jules Randolph 3 | 4 | declare namespace commander { 5 | 6 | interface CommanderError extends Error { 7 | code: string; 8 | exitCode: number; 9 | message: string; 10 | nestedError?: string; 11 | } 12 | type CommanderErrorConstructor = new (exitCode: number, code: string, message: string) => CommanderError; 13 | 14 | interface Option { 15 | flags: string; 16 | required: boolean; // A value must be supplied when the option is specified. 17 | optional: boolean; // A value is optional when the option is specified. 18 | mandatory: boolean; // The option must have a value after parsing, which usually means it must be specified on command line. 19 | bool: boolean; 20 | short?: string; 21 | long: string; 22 | description: string; 23 | } 24 | type OptionConstructor = new (flags: string, description?: string) => Option; 25 | 26 | interface ParseOptions { 27 | from: 'node' | 'electron' | 'user'; 28 | } 29 | 30 | interface Command { 31 | [key: string]: any; // options as properties 32 | 33 | args: string[]; 34 | 35 | commands: Command[]; 36 | 37 | /** 38 | * Set the program version to `str`. 39 | * 40 | * This method auto-registers the "-V, --version" flag 41 | * which will print the version number when passed. 42 | * 43 | * You can optionally supply the flags and description to override the defaults. 44 | */ 45 | version(str: string, flags?: string, description?: string): this; 46 | 47 | /** 48 | * Define a command, implemented using an action handler. 49 | * 50 | * @remarks 51 | * The command description is supplied using `.description`, not as a parameter to `.command`. 52 | * 53 | * @example 54 | * ```ts 55 | * program 56 | * .command('clone [destination]') 57 | * .description('clone a repository into a newly created directory') 58 | * .action((source, destination) => { 59 | * console.log('clone command called'); 60 | * }); 61 | * ``` 62 | * 63 | * @param nameAndArgs - command name and arguments, args are `` or `[optional]` and last may also be `variadic...` 64 | * @param opts - configuration options 65 | * @returns new command 66 | */ 67 | command(nameAndArgs: string, opts?: CommandOptions): ReturnType; 68 | /** 69 | * Define a command, implemented in a separate executable file. 70 | * 71 | * @remarks 72 | * The command description is supplied as the second parameter to `.command`. 73 | * 74 | * @example 75 | * ```ts 76 | * program 77 | * .command('start ', 'start named service') 78 | * .command('stop [service]', 'stop named serice, or all if no name supplied'); 79 | * ``` 80 | * 81 | * @param nameAndArgs - command name and arguments, args are `` or `[optional]` and last may also be `variadic...` 82 | * @param description - description of executable command 83 | * @param opts - configuration options 84 | * @returns `this` command for chaining 85 | */ 86 | command(nameAndArgs: string, description: string, opts?: commander.ExecutableCommandOptions): this; 87 | 88 | /** 89 | * Factory routine to create a new unattached command. 90 | * 91 | * See .command() for creating an attached subcommand, which uses this routine to 92 | * create the command. You can override createCommand to customise subcommands. 93 | */ 94 | createCommand(name?: string): Command; 95 | 96 | /** 97 | * Add a prepared subcommand. 98 | * 99 | * See .command() for creating an attached subcommand which inherits settings from its parent. 100 | * 101 | * @returns `this` command for chaining 102 | */ 103 | addCommand(cmd: Command, opts?: CommandOptions): this; 104 | 105 | /** 106 | * Define argument syntax for command. 107 | * 108 | * @returns `this` command for chaining 109 | */ 110 | arguments(desc: string): this; 111 | 112 | /** 113 | * Register callback to use as replacement for calling process.exit. 114 | */ 115 | exitOverride(callback?: (err: CommanderError) => never|void): this; 116 | 117 | /** 118 | * Register callback `fn` for the command. 119 | * 120 | * @example 121 | * program 122 | * .command('help') 123 | * .description('display verbose help') 124 | * .action(function() { 125 | * // output help here 126 | * }); 127 | * 128 | * @returns `this` command for chaining 129 | */ 130 | action(fn: (...args: any[]) => void | Promise): this; 131 | 132 | /** 133 | * Define option with `flags`, `description` and optional 134 | * coercion `fn`. 135 | * 136 | * The `flags` string should contain both the short and long flags, 137 | * separated by comma, a pipe or space. The following are all valid 138 | * all will output this way when `--help` is used. 139 | * 140 | * "-p, --pepper" 141 | * "-p|--pepper" 142 | * "-p --pepper" 143 | * 144 | * @example 145 | * // simple boolean defaulting to false 146 | * program.option('-p, --pepper', 'add pepper'); 147 | * 148 | * --pepper 149 | * program.pepper 150 | * // => Boolean 151 | * 152 | * // simple boolean defaulting to true 153 | * program.option('-C, --no-cheese', 'remove cheese'); 154 | * 155 | * program.cheese 156 | * // => true 157 | * 158 | * --no-cheese 159 | * program.cheese 160 | * // => false 161 | * 162 | * // required argument 163 | * program.option('-C, --chdir ', 'change the working directory'); 164 | * 165 | * --chdir /tmp 166 | * program.chdir 167 | * // => "/tmp" 168 | * 169 | * // optional argument 170 | * program.option('-c, --cheese [type]', 'add cheese [marble]'); 171 | * 172 | * @returns `this` command for chaining 173 | */ 174 | option(flags: string, description?: string, defaultValue?: string | boolean): this; 175 | option(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean): this; 176 | option(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): this; 177 | 178 | /** 179 | * Define a required option, which must have a value after parsing. This usually means 180 | * the option must be specified on the command line. (Otherwise the same as .option().) 181 | * 182 | * The `flags` string should contain both the short and long flags, separated by comma, a pipe or space. 183 | */ 184 | requiredOption(flags: string, description?: string, defaultValue?: string | boolean): this; 185 | requiredOption(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean): this; 186 | requiredOption(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): this; 187 | 188 | /** 189 | * Whether to store option values as properties on command object, 190 | * or store separately (specify false). In both cases the option values can be accessed using .opts(). 191 | * 192 | * @returns `this` command for chaining 193 | */ 194 | storeOptionsAsProperties(value?: boolean): this; 195 | 196 | /** 197 | * Whether to pass command to action handler, 198 | * or just the options (specify false). 199 | * 200 | * @returns `this` command for chaining 201 | */ 202 | passCommandToAction(value?: boolean): this; 203 | 204 | /** 205 | * Allow unknown options on the command line. 206 | * 207 | * @param [arg] if `true` or omitted, no error will be thrown for unknown options. 208 | * @returns `this` command for chaining 209 | */ 210 | allowUnknownOption(arg?: boolean): this; 211 | 212 | /** 213 | * Parse `argv`, setting options and invoking commands when defined. 214 | * 215 | * The default expectation is that the arguments are from node and have the application as argv[0] 216 | * and the script being run in argv[1], with user parameters after that. 217 | * 218 | * Examples: 219 | * 220 | * program.parse(process.argv); 221 | * program.parse(); // implicitly use process.argv and auto-detect node vs electron conventions 222 | * program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0] 223 | * 224 | * @returns `this` command for chaining 225 | */ 226 | parse(argv?: string[], options?: ParseOptions): this; 227 | 228 | /** 229 | * Parse `argv`, setting options and invoking commands when defined. 230 | * 231 | * Use parseAsync instead of parse if any of your action handlers are async. Returns a Promise. 232 | * 233 | * The default expectation is that the arguments are from node and have the application as argv[0] 234 | * and the script being run in argv[1], with user parameters after that. 235 | * 236 | * Examples: 237 | * 238 | * program.parseAsync(process.argv); 239 | * program.parseAsync(); // implicitly use process.argv and auto-detect node vs electron conventions 240 | * program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0] 241 | * 242 | * @returns Promise 243 | */ 244 | parseAsync(argv?: string[], options?: ParseOptions): Promise; 245 | 246 | /** 247 | * Parse options from `argv` removing known options, 248 | * and return argv split into operands and unknown arguments. 249 | * 250 | * @example 251 | * argv => operands, unknown 252 | * --known kkk op => [op], [] 253 | * op --known kkk => [op], [] 254 | * sub --unknown uuu op => [sub], [--unknown uuu op] 255 | * sub -- --unknown uuu op => [sub --unknown uuu op], [] 256 | */ 257 | parseOptions(argv: string[]): commander.ParseOptionsResult; 258 | 259 | /** 260 | * Return an object containing options as key-value pairs 261 | */ 262 | opts(): { [key: string]: any }; 263 | 264 | /** 265 | * Set the description. 266 | * 267 | * @returns `this` command for chaining 268 | */ 269 | description(str: string, argsDescription?: {[argName: string]: string}): this; 270 | /** 271 | * Get the description. 272 | */ 273 | description(): string; 274 | 275 | /** 276 | * Set an alias for the command. 277 | * 278 | * You may call more than once to add multiple aliases. Only the first alias is shown in the auto-generated help. 279 | * 280 | * @returns `this` command for chaining 281 | */ 282 | alias(alias: string): this; 283 | /** 284 | * Get alias for the command. 285 | */ 286 | alias(): string; 287 | 288 | /** 289 | * Set aliases for the command. 290 | * 291 | * Only the first alias is shown in the auto-generated help. 292 | * 293 | * @returns `this` command for chaining 294 | */ 295 | aliases(aliases: string[]): this; 296 | /** 297 | * Get aliases for the command. 298 | */ 299 | aliases(): string[]; 300 | 301 | /** 302 | * Set the command usage. 303 | * 304 | * @returns `this` command for chaining 305 | */ 306 | usage(str: string): this; 307 | /** 308 | * Get the command usage. 309 | */ 310 | usage(): string; 311 | 312 | /** 313 | * Set the name of the command. 314 | * 315 | * @returns `this` command for chaining 316 | */ 317 | name(str: string): this; 318 | /** 319 | * Get the name of the command. 320 | */ 321 | name(): string; 322 | 323 | /** 324 | * Output help information for this command. 325 | * 326 | * When listener(s) are available for the helpLongFlag 327 | * those callbacks are invoked. 328 | */ 329 | outputHelp(cb?: (str: string) => string): void; 330 | 331 | /** 332 | * Return command help documentation. 333 | */ 334 | helpInformation(): string; 335 | 336 | /** 337 | * You can pass in flags and a description to override the help 338 | * flags and help description for your command. 339 | */ 340 | helpOption(flags?: string, description?: string): this; 341 | 342 | /** 343 | * Output help information and exit. 344 | */ 345 | help(cb?: (str: string) => string): never; 346 | 347 | /** 348 | * Add a listener (callback) for when events occur. (Implemented using EventEmitter.) 349 | * 350 | * @example 351 | * program 352 | * .on('--help', () -> { 353 | * console.log('See web site for more information.'); 354 | * }); 355 | */ 356 | on(event: string | symbol, listener: (...args: any[]) => void): this; 357 | } 358 | type CommandConstructor = new (name?: string) => Command; 359 | 360 | interface CommandOptions { 361 | noHelp?: boolean; // old name for hidden 362 | hidden?: boolean; 363 | isDefault?: boolean; 364 | } 365 | interface ExecutableCommandOptions extends CommandOptions { 366 | executableFile?: string; 367 | } 368 | 369 | interface ParseOptionsResult { 370 | operands: string[]; 371 | unknown: string[]; 372 | } 373 | 374 | interface CommanderStatic extends Command { 375 | program: Command; 376 | Command: CommandConstructor; 377 | Option: OptionConstructor; 378 | CommanderError: CommanderErrorConstructor; 379 | } 380 | 381 | } 382 | 383 | // Declaring namespace AND global 384 | // eslint-disable-next-line no-redeclare 385 | declare const commander: commander.CommanderStatic; 386 | export = commander; 387 | --------------------------------------------------------------------------------