diff --git a/config.schema.json b/config.schema.json index 9c9e5d5..c2d407c 100644 --- a/config.schema.json +++ b/config.schema.json @@ -15,11 +15,29 @@ "default": "CloudflaredTunnel", "required": true }, + "domain": { + "type": "string", + "title": "Domain", + "description": "The domain of the self specified tunnel.", + "required": false + }, + "token": { + "type": "string", + "title": "token", + "description": "The token to use for the self specified tunnel.", + "required": false, + "condition": { + "functionBody": "return (!model.url || (!model.protocol && !model.hostname && !model.port));" + } + }, "acceptCloudflareNotice": { "type": "boolean", "title": "Auto Start Tunnel Install", "required": true, - "description": "Automatically start the Cloudflared Tunnel install process." + "description": "Automatically start the Cloudflared Tunnel install process.", + "condition": { + "functionBody": "return (!model.token && !model.domain);" + } }, "url": { "type": "string", @@ -35,7 +53,9 @@ "format": "uri", "patternErrorMessage": "URL must start with http:// or https://", "validationMessage": "URL must start with http:// or https://", - "validationKeywords": ["pattern"], + "validationKeywords": [ + "pattern" + ], "validation": { "pattern": "^https?://" } @@ -48,11 +68,15 @@ "oneOf": [ { "title": "HTTP", - "enum": ["http"] + "enum": [ + "http" + ] }, { "title": "HTTPS", - "enum": ["https"] + "enum": [ + "https" + ] } ], "description": "The protocol to use for the tunnel. If you are using a URL, you do not need to specify the protocol, hostname, or port.", @@ -73,7 +97,9 @@ "validationMessage": "Hostname must be specified if not using a URL", "pattern": "^(?!\\s*$).+", "patternErrorMessage": "Hostname must be specified if not using a URL", - "validationKeywords": ["pattern"], + "validationKeywords": [ + "pattern" + ], "condition": { "functionBody": "return (!model.url);" } @@ -87,7 +113,10 @@ "minimum": 1, "maximum": 65535, "validationMessage": "Port must be between 1 and 65535", - "validationKeywords": ["minimum", "maximum"], + "validationKeywords": [ + "minimum", + "maximum" + ], "validation": { "minimum": 1, "maximum": 65535, @@ -118,28 +147,45 @@ "oneOf": [ { "title": "Default Logging", - "enum": [""] + "enum": [ + "" + ] }, { "title": "Standard Logging", - "enum": ["standard"] + "enum": [ + "standard" + ] }, { "title": "No Logging", - "enum": ["none"] + "enum": [ + "none" + ] }, { "title": "Debug Logging", - "enum": ["debug"] + "enum": [ + "debug" + ] } ] } }, - "dependentRequired": { - "protocol": ["hostname", "port"], - "hostname": ["protocol", "port"], - "port": ["protocol", "hostname"] - } + "dependentRequired": { + "protocol": [ + "hostname", + "port" + ], + "hostname": [ + "protocol", + "port" + ], + "port": [ + "protocol", + "hostname" + ] + } }, "layout": [ { @@ -148,6 +194,8 @@ "expandable": true, "expanded": false, "items": [ + "domain", + "token", "acceptCloudflareNotice", "url", "protocol", @@ -166,4 +214,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 6161c3e..fc65f8c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,15 +20,14 @@ "license": "ISC", "dependencies": { "@homebridge/plugin-ui-utils": "^1.0.3", + "node-cloudflared-tunnel": "^1.0.10", "untun": "^0.1.3" }, "devDependencies": { "@eslint/js": "^9.6.0", "@stylistic/eslint-plugin": "^2.3.0", - "@types/eslint__js": "^8.42.3", "@types/node": "^20.14.9", "eslint": "^9.6.0", - "globals": "^15.7.0", "homebridge": "^1.8.3", "homebridge-config-ui-x": "4.56.4", "nodemon": "^3.1.4", @@ -145,19 +144,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/@eslint/eslintrc/node_modules/globals": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", - "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/@eslint/js": { "version": "9.6.0", "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.6.0.tgz", @@ -1813,16 +1799,6 @@ "@types/json-schema": "*" } }, - "node_modules/@types/eslint__js": { - "version": "8.42.3", - "resolved": "https://registry.npmjs.org/@types/eslint__js/-/eslint__js-8.42.3.tgz", - "integrity": "sha512-alfG737uhmPdnvkrLdZLcEKJ/B8s9Y4hrZ+YAdzUeoArBlSUERA2E87ROfOaS4jd/C45fzOoZzidLc1IPwLqOw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/eslint": "*" - } - }, "node_modules/@types/estree": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", @@ -3124,6 +3100,12 @@ "node": ">= 0.8" } }, + "node_modules/command-exists": { + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/command-exists/-/command-exists-1.2.9.tgz", + "integrity": "sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w==", + "license": "MIT" + }, "node_modules/commander": { "version": "12.1.0", "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz", @@ -4738,9 +4720,9 @@ } }, "node_modules/globals": { - "version": "15.7.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-15.7.0.tgz", - "integrity": "sha512-ivatRXWwKC6ImcdKO7dOwXuXR5XFrdwo45qFwD7D0qOkEPzzJdLXC3BHceBdyrPOD3p1suPaWi4Y4NMm2D++AQ==", + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", "dev": true, "license": "MIT", "engines": { @@ -6752,6 +6734,15 @@ "node": ">= 8.0.0" } }, + "node_modules/node-cloudflared-tunnel": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/node-cloudflared-tunnel/-/node-cloudflared-tunnel-1.0.10.tgz", + "integrity": "sha512-QBTH4bcTePgiwYdK5vYZhZl7GNr3Pqnj5V3Tg1w5HvnK4VhLZe5BUuhqKvzzCA604yhoD2I1ATdnOl6axSJu/w==", + "license": "MIT", + "dependencies": { + "command-exists": "^1.2.9" + } + }, "node_modules/node-fetch": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", diff --git a/package.json b/package.json index 426c9bf..775ee41 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "displayName": "Cloudflared Tunnel", "name": "homebridge-cloudflared-tunnel", - "version": "1.0.3", + "version": "1.1.0", "description": "The Cloudflared Tunnel plugin allows you to run a Cloudflare-Tunnel for exposing your homebridge instance for remote access.", "author": { "name": "donavanbecker", @@ -51,15 +51,14 @@ ], "dependencies": { "@homebridge/plugin-ui-utils": "^1.0.3", - "untun": "^0.1.3" + "untun": "^0.1.3", + "node-cloudflared-tunnel": "^1.0.10" }, "devDependencies": { "@eslint/js": "^9.6.0", "@stylistic/eslint-plugin": "^2.3.0", - "@types/eslint__js": "^8.42.3", "@types/node": "^20.14.9", "eslint": "^9.6.0", - "globals": "^15.7.0", "homebridge": "^1.8.3", "homebridge-config-ui-x": "4.56.4", "nodemon": "^3.1.4", diff --git a/src/custom.d.ts b/src/custom.d.ts new file mode 100644 index 0000000..da9dff3 --- /dev/null +++ b/src/custom.d.ts @@ -0,0 +1,5 @@ +/* Copyright(C) 2023-2024, donavanbecker (https://github.com/donavanbecker). All rights reserved. + * + * custom.d.ts: homebridge-cloudflared-tunnel platform class. + */ +declare module 'node-cloudflared-tunnel'; diff --git a/src/homebridge-ui/public/index.html b/src/homebridge-ui/public/index.html index 1c5c661..e62400c 100644 --- a/src/homebridge-ui/public/index.html +++ b/src/homebridge-ui/public/index.html @@ -1,8 +1,7 @@
+ alt="homebridge-cloudflared-tunnel logo" style="width: 40%" />