From 0a9651d7b8ac7afe6f6be4edfcb93ecfa263327f Mon Sep 17 00:00:00 2001 From: Jurgis Sakalauskas Date: Fri, 26 Apr 2024 10:05:01 +0300 Subject: [PATCH] initial commit --- .env.example | 10 +++ .gitignore | 2 + .idea/.gitignore | 8 ++ .idea/modules.xml | 8 ++ .idea/php.xml | 19 +++++ .idea/torr.iml | 8 ++ .idea/vcs.xml | 6 ++ README.md | 7 ++ package-lock.json | 177 ++++++++++++++++++++++++++++++++++++++++++++ package.json | 14 ++++ src/docker.ts | 63 ++++++++++++++++ src/index.ts | 87 ++++++++++++++++++++++ src/settings.ts | 20 +++++ src/transmission.ts | 50 +++++++++++++ tsconfig.json | 109 +++++++++++++++++++++++++++ 15 files changed, 588 insertions(+) create mode 100644 .env.example create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 .idea/modules.xml create mode 100644 .idea/php.xml create mode 100644 .idea/torr.iml create mode 100644 .idea/vcs.xml create mode 100644 README.md create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 src/docker.ts create mode 100644 src/index.ts create mode 100644 src/settings.ts create mode 100644 src/transmission.ts create mode 100644 tsconfig.json diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..d69e381 --- /dev/null +++ b/.env.example @@ -0,0 +1,10 @@ +IP_INFO_URL=https://ipinfo.io +TRANSMISSION_HOST=localhost +TRANSMISSION_PORT=9091 +DOCKER_TRANSMISSION_CWD=/path/to/transmission/docker-compose/yaml/config +DOCKER_TRANSMISSION_SERVICE=transmission +DOCKER_TRANSMISSION_SERVICE_NAME=transmission +ALLOWED_INTERFACES=tun0 +DISALLOWED_COUNTRIES=your_country_code_e_g_LV +DISALLOWED_INTERNAL_IPS=your_internal_ip_e_g_192.168 +DISALLOWED_EXT_IPS=your_external_ip diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..37d7e73 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +.env diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..97ba5df --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 0000000..f324872 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/torr.iml b/.idea/torr.iml new file mode 100644 index 0000000..c956989 --- /dev/null +++ b/.idea/torr.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..23e29b1 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +this is a script for checking and setting a new port forward for transmission-daemon in gluetun network for privatevpn + +npx needs to be installed to run this script +```bash +npm install +npm run start +``` diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..ec8454b --- /dev/null +++ b/package-lock.json @@ -0,0 +1,177 @@ +{ + "name": "torr", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "dependencies": { + "docker-compose": "^0.24.8", + "dotenv": "^16.4.5", + "transmission": "^0.4.10" + }, + "devDependencies": { + "@types/node": "^20.12.7", + "typescript": "^5.4.5" + } + }, + "node_modules/@types/node": { + "version": "20.12.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.7.tgz", + "integrity": "sha512-wq0cICSkRLVaf3UGLMGItu/PtdY7oaXaI/RVU+xliKVOtRna3PRY57ZDfztpDL0n11vfymMUnXv8QwYCO7L1wg==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/async": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", + "dependencies": { + "lodash": "^4.17.14" + } + }, + "node_modules/docker-compose": { + "version": "0.24.8", + "resolved": "https://registry.npmjs.org/docker-compose/-/docker-compose-0.24.8.tgz", + "integrity": "sha512-plizRs/Vf15H+GCVxq2EUvyPK7ei9b/cVesHvjnX4xaXjM9spHe2Ytq0BitndFgvTJ3E3NljPNUEl7BAN43iZw==", + "dependencies": { + "yaml": "^2.2.2" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "node_modules/transmission": { + "version": "0.4.10", + "resolved": "https://registry.npmjs.org/transmission/-/transmission-0.4.10.tgz", + "integrity": "sha512-GXss/sNTuHqgvy7TTE3soF8wuS8BzqZO3HV3mc61tg7vVT5u5Gr5kja82QF23GfGeZjdzFUeJGwJrEHU1DWq8Q==", + "dependencies": { + "async": "^2.1.4", + "yargs": "^1.3.3" + }, + "bin": { + "node-transmission": "bin/node-transmission" + } + }, + "node_modules/typescript": { + "version": "5.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", + "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, + "node_modules/yaml": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.1.tgz", + "integrity": "sha512-pIXzoImaqmfOrL7teGUBt/T7ZDnyeGBWyXQBvOVhLkWLN37GXv8NMLK406UY6dS51JfcQHsmcW5cJ441bHg6Lg==", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/yargs": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-1.3.3.tgz", + "integrity": "sha512-7OGt4xXoWJQh5ulgZ78rKaqY7dNWbjfK+UKxGcIlaM2j7C4fqGchyv8CPvEWdRPrHp6Ula/YU8yGRpYGOHrI+g==" + } + }, + "dependencies": { + "@types/node": { + "version": "20.12.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.7.tgz", + "integrity": "sha512-wq0cICSkRLVaf3UGLMGItu/PtdY7oaXaI/RVU+xliKVOtRna3PRY57ZDfztpDL0n11vfymMUnXv8QwYCO7L1wg==", + "dev": true, + "requires": { + "undici-types": "~5.26.4" + } + }, + "async": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", + "requires": { + "lodash": "^4.17.14" + } + }, + "docker-compose": { + "version": "0.24.8", + "resolved": "https://registry.npmjs.org/docker-compose/-/docker-compose-0.24.8.tgz", + "integrity": "sha512-plizRs/Vf15H+GCVxq2EUvyPK7ei9b/cVesHvjnX4xaXjM9spHe2Ytq0BitndFgvTJ3E3NljPNUEl7BAN43iZw==", + "requires": { + "yaml": "^2.2.2" + } + }, + "dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==" + }, + "lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "transmission": { + "version": "0.4.10", + "resolved": "https://registry.npmjs.org/transmission/-/transmission-0.4.10.tgz", + "integrity": "sha512-GXss/sNTuHqgvy7TTE3soF8wuS8BzqZO3HV3mc61tg7vVT5u5Gr5kja82QF23GfGeZjdzFUeJGwJrEHU1DWq8Q==", + "requires": { + "async": "^2.1.4", + "yargs": "^1.3.3" + } + }, + "typescript": { + "version": "5.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", + "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", + "dev": true + }, + "undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, + "yaml": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.1.tgz", + "integrity": "sha512-pIXzoImaqmfOrL7teGUBt/T7ZDnyeGBWyXQBvOVhLkWLN37GXv8NMLK406UY6dS51JfcQHsmcW5cJ441bHg6Lg==" + }, + "yargs": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-1.3.3.tgz", + "integrity": "sha512-7OGt4xXoWJQh5ulgZ78rKaqY7dNWbjfK+UKxGcIlaM2j7C4fqGchyv8CPvEWdRPrHp6Ula/YU8yGRpYGOHrI+g==" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..2f1b44d --- /dev/null +++ b/package.json @@ -0,0 +1,14 @@ +{ + "scripts": { + "start": "npx ts-node src/index.ts" + }, + "devDependencies": { + "@types/node": "^20.12.7", + "typescript": "^5.4.5" + }, + "dependencies": { + "docker-compose": "^0.24.8", + "dotenv": "^16.4.5", + "transmission": "^0.4.10" + } +} diff --git a/src/docker.ts b/src/docker.ts new file mode 100644 index 0000000..56303c8 --- /dev/null +++ b/src/docker.ts @@ -0,0 +1,63 @@ +import { v2 as compose } from 'docker-compose'; +import { settings } from './settings'; + +type IPInfo = { + ip: string, + hostname: string, + city: string, + region: string, + country: string, + loc: string, + org: string, + postal: string, + timezone: string, +} + +export class DockerContainer { + constructor(private service: string, private cwd: string, private serviceName?: string) { + if (!serviceName) { + this.serviceName = service; + } + } + + async up() { + return compose.upOne(this.service, { cwd: this.cwd }); + } + + async down() { + return compose.downOne(this.service, { cwd: this.cwd }); + } + + async exec(command: string) { + return await compose.exec(this.service, command, { cwd: this.cwd }); + } + + async getState() { + const result = await compose.ps({ cwd: this.cwd, commandOptions: [["--format", "json"]] }); + + return result.data.services.find((service) => service.name === this.serviceName); + } + + async getIpInfo(): Promise { + const { exitCode, out: outRaw } = await this.exec(settings.ipInfoCommand); + if (exitCode !== 0) { + return null; + } + + return JSON.parse(outRaw) as IPInfo; + } + + async getDefaultInterface() { + const { exitCode, out: outRaw } = await this.exec(settings.interfaceCommand); + if (exitCode !== 0) { + return null; + } + + const dataRaw = outRaw.trim().replace(/\n| {2}/g, ' ').split(' '); + + return { + interface: dataRaw[4], + ip: dataRaw[6], + } + } +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..55925f8 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,87 @@ +import { Transmission } from './transmission'; +import { DockerContainer } from './docker'; +import { settings } from './settings'; + +main().then(() => console.log('All done')).catch(console.error); + +async function main() { + console.log('Starting'); + const transmissionClient = new Transmission(settings.transmission); + const transmissionContainer = new DockerContainer( + settings.dockerTransmission.service, + settings.dockerTransmission.cwd, + settings.dockerTransmission.serviceName + ); + + const containerState = await transmissionContainer.getState(); + if (containerState?.state !== 'running') { + console.log('Transmission service is not running'); + return; + } + + console.log(`Gathering info`); + const port = await transmissionClient.getPort(); + console.log(`Port: ${port}`); + const portOpen = await transmissionClient.testPortIfOpen(); + console.log(`Port is open: ${portOpen}`); + const defaultInterface = await transmissionContainer.getDefaultInterface(); + console.log(`Default interface: ${defaultInterface?.interface} Internal ip: ${defaultInterface?.ip}`); + const ipInfo = await transmissionContainer.getIpInfo(); + console.log(`External ip: ${ipInfo?.ip} Country: ${ipInfo?.country}`); + + if (!defaultInterface || !ipInfo) { + console.log('Could not get default interface or ip info'); + return; + } + + const countryOK = !settings.disallowedCountries.some((country) => ipInfo.country.includes(country)); + const internalIpOK = !settings.disallowedIntIps.some((ip) => defaultInterface.ip.includes(ip)); + const externalIpOK = !settings.disallowedExtIps.some((ip) => ipInfo.ip.includes(ip)); + const interfaceOK = settings.allowedInterfaces.some((inter) => defaultInterface.interface.includes(inter)); + + console.log(`Country OK: ${countryOK} Internal IP OK: ${internalIpOK} External IP OK: ${externalIpOK} Interface OK: ${interfaceOK}`); + + if (!countryOK || !internalIpOK || !externalIpOK || !interfaceOK) { + console.log('Shutting down transmission service'); + //await dockerContainer.down(); + return; + } + + if (portOpen) { + console.log(`Port ${port} is open`); + return; + } + + console.log(`Port ${port} is not open. Fetching new port.`); + + //fetch new port + const request = await fetch(`https://connect.pvdatanet.com/v3/Api/port?ip[]=${defaultInterface.ip}`) + const data = await request.json() as {status: string, supported: boolean} + + console.log(`Data received: ${JSON.stringify(data)}`); + + if (!data.status || !data.supported) { + console.log('Could not fetch new port'); + return; + } + + const newPort= Number(data.status.split(" ")[1]); + + if (!newPort) { + console.log('Could not parse new port'); + return; + } + + console.log(`Setting port to ${newPort}`); + await transmissionClient.setPort(newPort); + + console.log('Port set'); + const newPortOpen = await transmissionClient.testPortIfOpen(); + console.log(`Port ${newPort} is open: ${newPortOpen}`); + + if (!newPortOpen) { + console.log('Port is not open, Shutting down transmission service'); + //await dockerContainer.down(); + return; + } +} diff --git a/src/settings.ts b/src/settings.ts new file mode 100644 index 0000000..a809ddd --- /dev/null +++ b/src/settings.ts @@ -0,0 +1,20 @@ +import dotenv from 'dotenv'; +dotenv.config(); + +export const settings = { + ipInfoCommand: `curl ${process.env.IP_INFO_URL ?? 'https://ipinfo.io'}`, + interfaceCommand: 'ip route get 8.8.8.8', + transmission: { + host: process.env.TRANSMISSION_HOST, + port: Number(process.env.TRANSMISSION_PORT), + }, + dockerTransmission: { + cwd: process.env.DOCKER_TRANSMISSION_CWD ?? __dirname, + service: process.env.DOCKER_TRANSMISSION_SERVICE ?? 'transmission', + serviceName: process.env.DOCKER_TRANSMISSION_SERVICE_NAME ?? process.env.DOCKER_TRANSMISSION_SERVICE, + }, + allowedInterfaces: process.env.ALLOWED_INTERFACES?.split(',') ?? [], + disallowedCountries: process.env.DISALLOWED_COUNTRIES?.split(',') ?? [], + disallowedIntIps: process.env.DISALLOWED_INTERNAL_IPS?.split(',') ?? [], + disallowedExtIps: process.env.DISALLOWED_EXT_IPS?.split(',') ?? [], +} as const; diff --git a/src/transmission.ts b/src/transmission.ts new file mode 100644 index 0000000..abe5948 --- /dev/null +++ b/src/transmission.ts @@ -0,0 +1,50 @@ +// @ts-ignore +import TransmissionClient from 'transmission'; + +type TransmissionOptions = { + url?: string; + host?: string; + port?: number; + ssl?: boolean; +} + +export class Transmission { + client: any; + + constructor(transmissionOptions: TransmissionOptions) { + this.client = new TransmissionClient(transmissionOptions); + } + + async getPort(): Promise { + return new Promise((resolve, reject) => { + this.client.session((err: any, arg: any) => { + if (err) { + reject(err); + } + resolve(arg['peer-port']); + }); + }); + } + + async setPort(port: number) { + return new Promise((resolve, reject) => { + this.client.callServer({ "arguments": { "peer-port": port }, "method": "session-set" }, (err: any, arg: any) => { + if (err) { + reject(err); + } + resolve(); + }); + }); + } + + async testPortIfOpen(): Promise { + return new Promise((resolve, reject) => { + this.client.callServer({ "method": "port-test" }, (err: any, arg: any) => { + if (err) { + reject(err); + } + resolve(arg['port-is-open']); + }); + }); + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..e075f97 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,109 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + + /* Modules */ + "module": "commonjs", /* Specify what module code is generated. */ + // "rootDir": "./", /* Specify the root folder within your source files. */ + // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + // "outDir": "./", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + + /* Type Checking */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + } +}