cloud: send server id and friendly name

This commit is contained in:
Koushik Dutta
2024-02-22 18:42:06 -08:00
parent 3a6b244a4a
commit a05bcd6ce4
3 changed files with 24 additions and 17 deletions

View File

@@ -1,18 +1,18 @@
{
"name": "@scrypted/cloud",
"version": "0.2.6",
"version": "0.2.7",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@scrypted/cloud",
"version": "0.2.6",
"version": "0.2.7",
"dependencies": {
"@eneris/push-receiver": "^3.1.5",
"@scrypted/common": "file:../../common",
"@scrypted/sdk": "file:../../sdk",
"bpmux": "^8.2.1",
"cloudflared": "^0.5.1",
"cloudflared": "^0.4.0",
"exponential-backoff": "^3.1.1",
"http-proxy": "^1.18.1",
"nat-upnp": "file:./external/node-nat-upnp"
@@ -6232,9 +6232,8 @@
"version": "1.1.1",
"dependencies": {
"async": "^3.2.5",
"axios": "^1.6.7",
"ip": "^2.0.1",
"xml2js": "~0.6.2"
"xml2js": "^0.6.2"
}
},
"node_modules/@eneris/push-receiver": {
@@ -6378,9 +6377,9 @@
}
},
"node_modules/cloudflared": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/cloudflared/-/cloudflared-0.5.1.tgz",
"integrity": "sha512-DQ33z5dBrE32xrHRyA35CtE8WcDgOzefR0/x/gVVa2jSKc54vRTIDwNQXCbXcet3sv2DOVtLWUbdcjxbCYK+OQ==",
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/cloudflared/-/cloudflared-0.4.0.tgz",
"integrity": "sha512-dVw3FcpL2LdpiVN6al0S3yG/hLCuwzPZ608a3173EfqWPQVf1v5MdQwQuzaqaB2LZ6nhi5rVRqIBRUjCyrz0JQ==",
"hasInstallScript": true,
"bin": {
"cloudflared": "lib/cloudflared.js"

View File

@@ -42,7 +42,7 @@
"@scrypted/common": "file:../../common",
"@scrypted/sdk": "file:../../sdk",
"bpmux": "^8.2.1",
"cloudflared": "^0.5.1",
"cloudflared": "^0.4.0",
"exponential-backoff": "^3.1.1",
"http-proxy": "^1.18.1",
"nat-upnp": "file:./external/node-nat-upnp"
@@ -53,5 +53,5 @@
"@types/nat-upnp": "^1.1.5",
"@types/node": "^20.11.19"
},
"version": "0.2.6"
"version": "0.2.7"
}

View File

@@ -155,7 +155,7 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
json: true,
},
cloudflareEnabled: {
group: 'Advanced',
group: 'Cloudflare',
title: 'Cloudflare',
type: 'boolean',
description: 'Optional: Create a Cloudflare Tunnel to this server at a random domain name. Providing a Cloudflare token will allow usage of a custom domain name.',
@@ -163,7 +163,7 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
onPut: () => deviceManager.requestRestart(),
},
cloudflaredTunnelToken: {
group: 'Advanced',
group: 'Cloudflare',
title: 'Cloudflare Tunnel Token',
description: 'Optional: Enter the Cloudflare token from the Cloudflare Dashbaord to track and manage the tunnel remotely.',
onPut: () => {
@@ -171,14 +171,20 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
},
},
cloudflaredTunnelUrl: {
group: 'Advanced',
group: 'Cloudflare',
title: 'Cloudflare Tunnel URL',
description: 'Cloudflare Tunnel URL is a randomized cloud connection, unless a Cloudflare Tunnel Token is provided.',
readonly: true,
mapGet: () => this.cloudflareTunnel || 'Unavailable',
},
serverName: {
group: 'Connection',
title: 'Server Name',
description: 'The name of this server. This is used to identify this server in the Scrypted Cloud.',
persistedDefaultValue: os.hostname()?.split('.')[0] || 'Scrypted Server',
},
register: {
group: 'Advanced',
group: 'Connection',
title: 'Register',
type: 'button',
onPut: () => {
@@ -187,7 +193,7 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
description: 'Register server with Scrypted Cloud.',
},
testPortForward: {
group: 'Advanced',
group: 'Connection',
title: 'Test Port Forward',
type: 'button',
onPut: () => this.testPortForward(),
@@ -246,7 +252,7 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
this.storageSettings.settings.securePort.onGet = async () => {
return {
group: this.storageSettings.values.forwardingMode === 'Disabled' ? 'Advanced' : undefined,
group: this.storageSettings.values.forwardingMode === 'Disabled' ? 'Cloudflare' : undefined,
title: this.storageSettings.values.forwardingMode === 'Disabled' ? 'Cloudflare Port' : 'Forward Port',
}
};
@@ -582,6 +588,7 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
upnp_port,
registration_id,
server_id: this.storageSettings.values.serverId,
server_name: this.storageSettings.values.serverName,
sender_id: DEFAULT_SENDER_ID,
registration_secret,
hostname,
@@ -705,8 +712,9 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
async getOauthUrl(): Promise<string> {
const args = qsstringify({
hostname: os.hostname(),
registration_id: await this.manager.registrationId,
server_id: this.storageSettings.values.serverId,
server_name: this.storageSettings.values.serverName,
sender_id: DEFAULT_SENDER_ID,
redirect_uri: `https://${SCRYPTED_SERVER}/web/oauth/callback`,
})