@fastybird/smart-panel-backend 1.1.0-alpha.3 → 1.1.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/common/filters/conflict-exception.filter.d.ts +6 -0
  2. package/dist/common/filters/conflict-exception.filter.js +59 -0
  3. package/dist/common/filters/conflict-exception.filter.js.map +1 -0
  4. package/dist/common/filters/global-error.filter.js +1 -4
  5. package/dist/common/filters/global-error.filter.js.map +1 -1
  6. package/dist/common/filters/global-filters.d.ts +3 -0
  7. package/dist/common/filters/global-filters.js +22 -0
  8. package/dist/common/filters/global-filters.js.map +1 -0
  9. package/dist/common/filters/unprocessable-entity-exception.filter.d.ts +1 -0
  10. package/dist/common/filters/unprocessable-entity-exception.filter.js +15 -3
  11. package/dist/common/filters/unprocessable-entity-exception.filter.js.map +1 -1
  12. package/dist/main.js +2 -7
  13. package/dist/main.js.map +1 -1
  14. package/dist/modules/platform/services/platform.service.d.ts +13 -4
  15. package/dist/modules/platform/services/platform.service.js +57 -35
  16. package/dist/modules/platform/services/platform.service.js.map +1 -1
  17. package/dist/modules/remote-access/dto/update-config.dto.js +5 -0
  18. package/dist/modules/remote-access/dto/update-config.dto.js.map +1 -1
  19. package/dist/modules/remote-access/validators/is-remote-access-url.validator.js +5 -2
  20. package/dist/modules/remote-access/validators/is-remote-access-url.validator.js.map +1 -1
  21. package/dist/modules/system/services/privileged-worker.service.d.ts +10 -0
  22. package/dist/modules/system/services/privileged-worker.service.js +137 -11
  23. package/dist/modules/system/services/privileged-worker.service.js.map +1 -1
  24. package/dist/plugins/devices-shelly-ng/devices-shelly-ng.constants.js +6 -9
  25. package/dist/plugins/devices-shelly-ng/devices-shelly-ng.constants.js.map +1 -1
  26. package/dist/plugins/remote-access-tailscale/controllers/setup.controller.d.ts +1 -0
  27. package/dist/plugins/remote-access-tailscale/controllers/setup.controller.js +26 -10
  28. package/dist/plugins/remote-access-tailscale/controllers/setup.controller.js.map +1 -1
  29. package/dist/plugins/remote-access-tailscale/controllers/status.controller.d.ts +6 -1
  30. package/dist/plugins/remote-access-tailscale/controllers/status.controller.js +28 -3
  31. package/dist/plugins/remote-access-tailscale/controllers/status.controller.js.map +1 -1
  32. package/dist/plugins/remote-access-tailscale/models/status.model.d.ts +19 -0
  33. package/dist/plugins/remote-access-tailscale/models/status.model.js +158 -1
  34. package/dist/plugins/remote-access-tailscale/models/status.model.js.map +1 -1
  35. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.exceptions.d.ts +13 -0
  36. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.exceptions.js +27 -0
  37. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.exceptions.js.map +1 -0
  38. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.openapi.d.ts +2 -2
  39. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.openapi.js +2 -0
  40. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.openapi.js.map +1 -1
  41. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.plugin.js +1 -1
  42. package/dist/plugins/remote-access-tailscale/scripts/tailscale-setup.sh +61 -0
  43. package/dist/plugins/remote-access-tailscale/services/tailscale-cli.service.d.ts +9 -0
  44. package/dist/plugins/remote-access-tailscale/services/tailscale-cli.service.js +12 -0
  45. package/dist/plugins/remote-access-tailscale/services/tailscale-cli.service.js.map +1 -1
  46. package/dist/plugins/remote-access-tailscale/services/tailscale-login.service.d.ts +1 -0
  47. package/dist/plugins/remote-access-tailscale/services/tailscale-login.service.js +23 -2
  48. package/dist/plugins/remote-access-tailscale/services/tailscale-login.service.js.map +1 -1
  49. package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.d.ts +26 -0
  50. package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.js +245 -29
  51. package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.js.map +1 -1
  52. package/dist/plugins/remote-access-tailscale/services/tailscale-serve.service.d.ts +8 -3
  53. package/dist/plugins/remote-access-tailscale/services/tailscale-serve.service.js +39 -12
  54. package/dist/plugins/remote-access-tailscale/services/tailscale-serve.service.js.map +1 -1
  55. package/dist/plugins/remote-access-tailscale/services/tailscale-setup.service.d.ts +14 -5
  56. package/dist/plugins/remote-access-tailscale/services/tailscale-setup.service.js +51 -16
  57. package/dist/plugins/remote-access-tailscale/services/tailscale-setup.service.js.map +1 -1
  58. package/dist/tsconfig.build.tsbuildinfo +1 -1
  59. package/package.json +2 -2
@@ -19,8 +19,10 @@ const config_1 = require("@nestjs/config");
19
19
  const logger_1 = require("../../../common/logger");
20
20
  const config_utils_1 = require("../../../common/utils/config.utils");
21
21
  const remote_access_tailscale_constants_1 = require("../remote-access-tailscale.constants");
22
+ const remote_access_tailscale_exceptions_1 = require("../remote-access-tailscale.exceptions");
22
23
  const tailscale_cli_service_1 = require("./tailscale-cli.service");
23
24
  const tailscale_node_managed_service_1 = require("./tailscale-node-managed.service");
25
+ const ACTIONABLE_REQUIREMENT_CODES = ['operator-granted', 'daemon-active'];
24
26
  function extractJsonObjects(buffer) {
25
27
  const objects = [];
26
28
  let depth = 0;
@@ -96,6 +98,7 @@ let TailscaleLoginService = class TailscaleLoginService {
96
98
  return this.loginInteractively();
97
99
  }
98
100
  async logout() {
101
+ await this.assertActionable();
99
102
  this.stopPendingLogin();
100
103
  try {
101
104
  await this.cli.logout();
@@ -111,9 +114,19 @@ let TailscaleLoginService = class TailscaleLoginService {
111
114
  return this.currentStatus();
112
115
  }
113
116
  async resetPreferences() {
117
+ await this.assertActionable();
114
118
  await this.cli.up(['--reset', ...this.buildManagedFlags()]);
115
119
  return this.currentStatus();
116
120
  }
121
+ async assertActionable() {
122
+ const requirements = await this.nodeManagedService.refreshRequirements('status-read');
123
+ for (const code of ACTIONABLE_REQUIREMENT_CODES) {
124
+ const requirement = requirements.find((candidate) => candidate.code === code);
125
+ if (requirement && !requirement.satisfied) {
126
+ throw new remote_access_tailscale_exceptions_1.TailscaleRequirementUnsatisfiedException(requirement);
127
+ }
128
+ }
129
+ }
117
130
  getPendingInteractiveAuth() {
118
131
  if (!this.pending?.authUrl) {
119
132
  return null;
@@ -132,6 +145,7 @@ let TailscaleLoginService = class TailscaleLoginService {
132
145
  async loginWithAuthKey(authKey) {
133
146
  this.keyedLoginInFlight = true;
134
147
  try {
148
+ await this.assertActionable();
135
149
  const keyFilePath = await this.writeAuthKeyFile(authKey);
136
150
  try {
137
151
  await this.runUpToCompletion([`--auth-key=file:${keyFilePath}`, '--timeout=120s', ...this.buildManagedFlags()], remote_access_tailscale_constants_1.TAILSCALE_LOGIN_AUTH_KEY_TIMEOUT_MS);
@@ -150,9 +164,16 @@ let TailscaleLoginService = class TailscaleLoginService {
150
164
  this.keyedLoginInFlight = false;
151
165
  }
152
166
  }
153
- loginInteractively() {
167
+ async loginInteractively() {
168
+ if (this.pending) {
169
+ return { state: 'pending-auth', authUrl: this.pending.authUrl, qr: this.pending.qr };
170
+ }
171
+ await this.assertActionable();
154
172
  if (this.pending) {
155
- return Promise.resolve({ state: 'pending-auth', authUrl: this.pending.authUrl, qr: this.pending.qr });
173
+ return { state: 'pending-auth', authUrl: this.pending.authUrl, qr: this.pending.qr };
174
+ }
175
+ if (this.keyedLoginInFlight) {
176
+ throw new TailscaleLoginInProgressException('A Tailscale sign-in with an auth key is currently in progress. Wait for it to finish before starting an interactive sign-in.');
156
177
  }
157
178
  const child = this.cli.spawnUp(['--json', '--timeout=10m', ...this.buildManagedFlags()]);
158
179
  child.stderr.resume();
@@ -1 +1 @@
1
- {"version":3,"file":"tailscale-login.service.js","sourceRoot":"","sources":["../../../../src/plugins/remote-access-tailscale/services/tailscale-login.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAqDA,gDA4CC;AAhGD,6CAAyC;AACzC,+CAAiE;AACjE,yCAAiC;AAEjC,2CAA0D;AAC1D,2CAAoE;AAEpE,mDAA+D;AAC/D,qEAAiE;AAEjE,4FAM8C;AAE9C,mEAAiF;AACjF,q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AC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;CACD,CAAA;AAjaY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCASW,2CAAmB;QACJ,4DAA2B;QAC5B,sBAAiB;GAV1C,qBAAqB,CAiajC"}
1
+ {"version":3,"file":"tailscale-login.service.js","sourceRoot":"","sources":["../../../../src/plugins/remote-access-tailscale/services/tailscale-login.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAyDA,gDA4CC;AApGD,6CAAyC;AACzC,+CAAiE;AACjE,yCAAiC;AAEjC,2CAA0D;AAC1D,2CAAoE;AAEpE,mDAA+D;AAC/D,qEAAiE;AAEjE,4FAM8C;AAC9C,8FAAiG;AAEjG,mEAAiF;AACjF,qFAA+E;AAG/E,MAAM,4BAA4B,GAAG,CAAC,kBAAkB,EAAE,eAAe,CAAU,CAAC;AAiCpF,SAAgB,kBAAkB,CAAC,MAAc;IAChD,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;IACf,IAAI,UAAU,GAAG,CAAC,CAAC;IAEnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAEvB,IAAI,QAAQ,EAAE,CAAC;YACd,IAAI,OAAO,EAAE,CAAC;gBACb,OAAO,GAAG,KAAK,CAAC;YACjB,CAAC;iBAAM,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;gBAC1B,OAAO,GAAG,IAAI,CAAC;YAChB,CAAC;iBAAM,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;gBACzB,QAAQ,GAAG,KAAK,CAAC;YA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AAC,CAAC;gBAEpB,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;oBAChB,OAAO,EAAE,CAAC;gBACX,CAAC;qBAAM,CAAC;oBACP,MAAM,CAAC,IAAI,KAAK,CAAC,iCAAiC,IAAI,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC;gBACvE,CAAC;YACF,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;CACD,CAAA;AA3dY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCASW,2CAAmB;QACJ,4DAA2B;QAC5B,sBAAiB;GAV1C,qBAAqB,CA2djC"}
@@ -10,11 +10,17 @@ import { TailscaleCliService } from './tailscale-cli.service';
10
10
  import { TailscaleServeService } from './tailscale-serve.service';
11
11
  import { TailscaleStatusMapperService } from './tailscale-status-mapper.service';
12
12
  export type TailscaleRequirementCode = 'platform-supported' | 'binary-installed' | 'daemon-active' | 'operator-granted' | 'version-supported';
13
+ export interface TailscaleRequirementRemedy {
14
+ commands: string[];
15
+ note: string | null;
16
+ }
13
17
  export interface TailscaleRequirement {
14
18
  code: TailscaleRequirementCode;
15
19
  satisfied: boolean;
16
20
  message: string;
21
+ remedy: TailscaleRequirementRemedy | null;
17
22
  }
23
+ export type TailscaleRequirementRefreshReason = 'start' | 'permission-denied' | 'setup-complete' | 'status-read' | 'periodic';
18
24
  export declare function compareTailscaleVersions(a: string, b: string): number;
19
25
  export declare class TailscaleNodeManagedService extends BaseManagedExtensionService {
20
26
  private readonly cli;
@@ -33,10 +39,16 @@ export declare class TailscaleNodeManagedService extends BaseManagedExtensionSer
33
39
  readonly activationPolicy: "owner-enabled";
34
40
  private pollTimer;
35
41
  private lastStatus;
42
+ private lastError;
36
43
  private pluginConfig;
44
+ private requirementsCache;
45
+ private requirementsRefreshedAt;
46
+ private lastServeConvergeDenied;
37
47
  constructor(cli: TailscaleCliService, mapper: TailscaleStatusMapperService, configService: ConfigService, nestConfigService: NestConfigService, platformService: PlatformService, eventEmitter: EventEmitter2, serveService: TailscaleServeService);
38
48
  start(): Promise<void>;
39
49
  stop(): Promise<void>;
50
+ private isStopFailureTolerated;
51
+ private emitStatus;
40
52
  onConfigChanged(): Promise<ConfigChangeResult>;
41
53
  isHealthy(): Promise<boolean>;
42
54
  factoryReset(): Promise<{
@@ -44,11 +56,25 @@ export declare class TailscaleNodeManagedService extends BaseManagedExtensionSer
44
56
  reason?: string;
45
57
  }>;
46
58
  evaluateRequirements(): Promise<TailscaleRequirement[]>;
59
+ getRequirements(): TailscaleRequirement[];
60
+ refreshRequirements(reason: TailscaleRequirementRefreshReason): Promise<TailscaleRequirement[]>;
61
+ private requirementsSatisfied;
62
+ private evaluateRequirementsLive;
63
+ private unevaluatedRequirement;
64
+ private attachRemedies;
65
+ private finalizeRequirement;
66
+ private buildRemedy;
67
+ private buildInstallRemedy;
68
+ private runSetupScriptPrintPlan;
47
69
  computeStatus(): Promise<RemoteAccessProviderStatus>;
70
+ private computeStatusWithRawStatus;
71
+ private convergeServe;
48
72
  private evaluatePlatformSupported;
49
73
  private evaluateBinaryAndVersion;
50
74
  private evaluateDaemonActive;
51
75
  private evaluateOperatorGranted;
76
+ private evaluateOperatorGrantedViaProbe;
77
+ private buildOperatorRequirement;
52
78
  private getStatusOrNull;
53
79
  private isSystemdUnitActive;
54
80
  private isPollable;
@@ -16,6 +16,7 @@ exports.TailscaleNodeManagedService = void 0;
16
16
  exports.compareTailscaleVersions = compareTailscaleVersions;
17
17
  const node_child_process_1 = require("node:child_process");
18
18
  const os_1 = __importDefault(require("os"));
19
+ const path_1 = require("path");
19
20
  const common_1 = require("@nestjs/common");
20
21
  const config_1 = require("@nestjs/config");
21
22
  const event_emitter_1 = require("@nestjs/event-emitter");
@@ -28,9 +29,15 @@ const platform_service_1 = require("../../../modules/platform/services/platform.
28
29
  const remote_access_constants_1 = require("../../../modules/remote-access/remote-access.constants");
29
30
  const config_model_1 = require("../models/config.model");
30
31
  const remote_access_tailscale_constants_1 = require("../remote-access-tailscale.constants");
32
+ const remote_access_tailscale_exceptions_1 = require("../remote-access-tailscale.exceptions");
31
33
  const tailscale_cli_service_1 = require("./tailscale-cli.service");
32
34
  const tailscale_serve_service_1 = require("./tailscale-serve.service");
33
35
  const tailscale_status_mapper_service_1 = require("./tailscale-status-mapper.service");
36
+ const TAILSCALE_REQUIREMENTS_PERIODIC_REFRESH_MS = 5 * 60 * 1000;
37
+ const TAILSCALE_PRINT_PLAN_TIMEOUT_MS = 2_000;
38
+ const OPERATOR_GRANTED_SATISFIED_MESSAGE = 'The smart-panel operator is granted.';
39
+ const TAILSCALE_DOCUMENTATION_URL = 'https://smart-panel.fastybird.com/docs';
40
+ const TAILSCALE_VENDOR_DOWNLOAD_URL = 'https://tailscale.com/download/linux';
34
41
  function compareTailscaleVersions(a, b) {
35
42
  const toParts = (v) => v.split('.').map((segment) => parseInt(segment, 10) || 0);
36
43
  const partsA = toParts(a);
@@ -60,7 +67,11 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
60
67
  this.activationPolicy = 'owner-enabled';
61
68
  this.pollTimer = null;
62
69
  this.lastStatus = null;
70
+ this.lastError = null;
63
71
  this.pluginConfig = null;
72
+ this.requirementsCache = null;
73
+ this.requirementsRefreshedAt = 0;
74
+ this.lastServeConvergeDenied = false;
64
75
  }
65
76
  async start() {
66
77
  await this.withLock(async () => {
@@ -72,8 +83,8 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
72
83
  const config = this.getPluginConfig();
73
84
  this.logger.log('Starting Tailscale node service');
74
85
  try {
75
- const requirements = await this.evaluateRequirements();
76
- if (requirements.every((requirement) => requirement.satisfied)) {
86
+ const requirements = await this.refreshRequirements('start');
87
+ if (this.requirementsSatisfied(requirements)) {
77
88
  const status = await this.getStatusOrNull();
78
89
  if (status && this.mapper.hasExistingKey(status)) {
79
90
  await this.cli.set(this.buildPreferenceFlags(config));
@@ -82,9 +93,17 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
82
93
  }
83
94
  }
84
95
  catch (error) {
96
+ if (error instanceof tailscale_cli_service_1.TailscaleCliError && error.kind === 'permission-denied') {
97
+ await this.refreshRequirements('permission-denied').catch(() => undefined);
98
+ }
85
99
  this.logger.warn('Failed to bring the Tailscale node up during start; the poller keeps reporting live status.', {
86
100
  message: error instanceof Error ? error.message : String(error),
87
101
  });
102
+ await this.emitStatus().catch((emitError) => {
103
+ this.logger.debug('Failed to emit status after a failed start', {
104
+ message: emitError instanceof Error ? emitError.message : String(emitError),
105
+ });
106
+ });
88
107
  }
89
108
  this.schedulePoll(0);
90
109
  this.state = 'started';
@@ -100,16 +119,41 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
100
119
  this.clearPoll();
101
120
  try {
102
121
  await this.cli.down();
122
+ this.state = 'stopped';
103
123
  }
104
124
  catch (error) {
105
- this.logger.debug('tailscale down failed while stopping (safe to ignore if the node was already down)', {
106
- message: error instanceof Error ? error.message : String(error),
107
- });
125
+ if (await this.isStopFailureTolerated(error)) {
126
+ this.logger.debug('tailscale down failed while stopping (safe to ignore if the node was already down)', {
127
+ message: error instanceof Error ? error.message : String(error),
128
+ });
129
+ this.state = 'stopped';
130
+ }
131
+ else {
132
+ const message = error instanceof Error ? error.message : String(error);
133
+ this.state = 'error';
134
+ this.lastError = message;
135
+ this.logger.error('Failed to stop the Tailscale node service', { message });
136
+ await this.emitStatus();
137
+ throw new remote_access_tailscale_exceptions_1.TailscaleNodeStopFailedException(message);
138
+ }
108
139
  }
109
- this.state = 'stopped';
140
+ await this.emitStatus();
110
141
  this.logger.log('Tailscale node service stopped');
111
142
  });
112
143
  }
144
+ async isStopFailureTolerated(error) {
145
+ if (error instanceof tailscale_cli_service_1.TailscaleCliError &&
146
+ (error.kind === 'needs-login' || error.kind === 'daemon-down' || error.kind === 'not-installed')) {
147
+ return true;
148
+ }
149
+ const status = await this.getStatusOrNull();
150
+ return status?.BackendState === 'Stopped';
151
+ }
152
+ async emitStatus() {
153
+ const status = await this.computeStatus();
154
+ this.lastStatus = status;
155
+ this.eventEmitter.emit(remote_access_constants_1.EventType.PROVIDER_STATUS, status);
156
+ }
113
157
  async onConfigChanged() {
114
158
  const previous = this.pluginConfig;
115
159
  this.pluginConfig = null;
@@ -133,19 +177,22 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
133
177
  return { restartRequired: true };
134
178
  }
135
179
  try {
136
- const requirements = await this.evaluateRequirements();
137
- if (requirements.every((requirement) => requirement.satisfied)) {
180
+ const requirements = await this.refreshRequirements('start');
181
+ if (this.requirementsSatisfied(requirements)) {
138
182
  const status = await this.getStatusOrNull();
139
183
  if (status && this.mapper.hasExistingKey(status)) {
140
184
  await this.cli.set(this.buildPreferenceFlags(next));
141
185
  const port = this.getBackendPort();
142
186
  if (this.mapper.map(status, { port }).state === 'connected') {
143
- await this.serveService.apply(next, port, status);
187
+ await this.convergeServe(next, port, status);
144
188
  }
145
189
  }
146
190
  }
147
191
  }
148
192
  catch (error) {
193
+ if (error instanceof tailscale_cli_service_1.TailscaleCliError && error.kind === 'permission-denied') {
194
+ await this.refreshRequirements('permission-denied').catch(() => undefined);
195
+ }
149
196
  this.logger.warn('Failed to apply changed Tailscale preferences', {
150
197
  message: error instanceof Error ? error.message : String(error),
151
198
  });
@@ -153,6 +200,9 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
153
200
  return { restartRequired: false };
154
201
  }
155
202
  async isHealthy() {
203
+ if (!this.requirementsSatisfied(this.getRequirements())) {
204
+ return false;
205
+ }
156
206
  try {
157
207
  const status = await this.cli.getStatus();
158
208
  return status.BackendState === 'Running' && status.Self?.Online === true;
@@ -175,14 +225,34 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
175
225
  }
176
226
  }
177
227
  async evaluateRequirements() {
228
+ return this.refreshRequirements('status-read');
229
+ }
230
+ getRequirements() {
231
+ return this.requirementsCache ?? [];
232
+ }
233
+ async refreshRequirements(reason) {
234
+ if (reason === 'periodic' &&
235
+ this.requirementsCache &&
236
+ Date.now() - this.requirementsRefreshedAt < TAILSCALE_REQUIREMENTS_PERIODIC_REFRESH_MS) {
237
+ return this.requirementsCache;
238
+ }
239
+ const requirements = await this.evaluateRequirementsLive();
240
+ this.requirementsCache = requirements;
241
+ this.requirementsRefreshedAt = Date.now();
242
+ return requirements;
243
+ }
244
+ requirementsSatisfied(requirements) {
245
+ return requirements.length > 0 && requirements.every((requirement) => requirement.satisfied);
246
+ }
247
+ async evaluateRequirementsLive() {
178
248
  const platform = await this.evaluatePlatformSupported();
179
249
  if (!platform.satisfied) {
180
250
  return [
181
- platform,
182
- { code: 'binary-installed', satisfied: false, message: UNEVALUATED_MESSAGE },
183
- { code: 'daemon-active', satisfied: false, message: UNEVALUATED_MESSAGE },
184
- { code: 'operator-granted', satisfied: false, message: UNEVALUATED_MESSAGE },
185
- { code: 'version-supported', satisfied: false, message: UNEVALUATED_MESSAGE },
251
+ await this.finalizeRequirement(platform),
252
+ this.unevaluatedRequirement('binary-installed'),
253
+ this.unevaluatedRequirement('daemon-active'),
254
+ this.unevaluatedRequirement('operator-granted'),
255
+ this.unevaluatedRequirement('version-supported'),
186
256
  ];
187
257
  }
188
258
  const [{ binary, version }, daemonActive, operatorGranted] = await Promise.all([
@@ -190,41 +260,153 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
190
260
  this.evaluateDaemonActive(),
191
261
  this.evaluateOperatorGranted(),
192
262
  ]);
193
- return [platform, binary, daemonActive, operatorGranted, version];
263
+ return this.attachRemedies([platform, binary, daemonActive, operatorGranted, version]);
264
+ }
265
+ unevaluatedRequirement(code) {
266
+ return { code, satisfied: false, message: UNEVALUATED_MESSAGE, remedy: null };
267
+ }
268
+ async attachRemedies(requirements) {
269
+ let installRemedyPromise = null;
270
+ const getInstallRemedy = () => {
271
+ installRemedyPromise ??= this.buildInstallRemedy();
272
+ return installRemedyPromise;
273
+ };
274
+ return Promise.all(requirements.map((requirement) => this.finalizeRequirement(requirement, getInstallRemedy)));
275
+ }
276
+ async finalizeRequirement(requirement, getInstallRemedy) {
277
+ if (requirement.satisfied) {
278
+ return { ...requirement, remedy: null };
279
+ }
280
+ const remedy = getInstallRemedy && (requirement.code === 'binary-installed' || requirement.code === 'version-supported')
281
+ ? await getInstallRemedy()
282
+ : await this.buildRemedy(requirement.code);
283
+ return { ...requirement, remedy };
284
+ }
285
+ async buildRemedy(code) {
286
+ const serviceUser = os_1.default.userInfo().username;
287
+ switch (code) {
288
+ case 'binary-installed':
289
+ case 'version-supported':
290
+ return this.buildInstallRemedy();
291
+ case 'daemon-active':
292
+ return { commands: ['sudo systemctl enable --now tailscaled'], note: null };
293
+ case 'operator-granted':
294
+ return { commands: [`sudo tailscale set --operator=${serviceUser}`], note: null };
295
+ case 'platform-supported':
296
+ default:
297
+ return { commands: [], note: TAILSCALE_DOCUMENTATION_URL };
298
+ }
299
+ }
300
+ async buildInstallRemedy() {
301
+ try {
302
+ const stdout = await this.runSetupScriptPrintPlan('install');
303
+ const lines = stdout
304
+ .split('\n')
305
+ .map((line) => line.trim())
306
+ .filter((line) => line.length > 0);
307
+ if (lines.length === 0) {
308
+ return { commands: [], note: TAILSCALE_VENDOR_DOWNLOAD_URL };
309
+ }
310
+ return {
311
+ commands: lines.map((line) => (line.includes('|') ? line : `sudo ${line}`)),
312
+ note: null,
313
+ };
314
+ }
315
+ catch (error) {
316
+ this.logger.debug('Failed to build the install remedy from tailscale-setup.sh --print-plan', {
317
+ message: error instanceof Error ? error.message : String(error),
318
+ });
319
+ return { commands: [], note: TAILSCALE_VENDOR_DOWNLOAD_URL };
320
+ }
321
+ }
322
+ runSetupScriptPrintPlan(step) {
323
+ const script = (0, path_1.join)(__dirname, '..', 'scripts', 'tailscale-setup.sh');
324
+ return new Promise((resolve, reject) => {
325
+ (0, node_child_process_1.execFile)('bash', [script, '--print-plan', `--step=${step}`], { timeout: TAILSCALE_PRINT_PLAN_TIMEOUT_MS }, (error, stdout) => {
326
+ if (error) {
327
+ reject(error);
328
+ return;
329
+ }
330
+ resolve(stdout ?? '');
331
+ });
332
+ });
194
333
  }
195
334
  async computeStatus() {
335
+ return (await this.computeStatusWithRawStatus()).status;
336
+ }
337
+ async computeStatusWithRawStatus() {
338
+ if (this.state === 'stopped' || this.state === 'stopping') {
339
+ return { status: this.buildStatus('disconnected', 'The node service is stopped.'), raw: null };
340
+ }
341
+ if (this.state === 'error') {
342
+ return { status: this.buildStatus('error', this.lastError ?? 'The Tailscale node service failed.'), raw: null };
343
+ }
196
344
  const platform = await this.evaluatePlatformSupported();
197
345
  if (!platform.satisfied) {
198
- return this.buildStatus('unsupported', platform.message);
346
+ return { status: this.buildStatus('unsupported', platform.message), raw: null };
199
347
  }
200
348
  try {
201
349
  const status = await this.cli.getStatus();
202
350
  const port = this.getBackendPort();
203
- const mapped = this.mapper.map(status, { port });
204
351
  const postureAdvisories = this.buildPostureAdvisories(status);
352
+ const requirements = await this.refreshRequirements('periodic');
353
+ const operatorRequirement = requirements.find((requirement) => requirement.code === 'operator-granted');
354
+ if (operatorRequirement && !operatorRequirement.satisfied) {
355
+ return {
356
+ status: this.buildStatus('setup-required', operatorRequirement.message, {}, [], [], [
357
+ ...postureAdvisories,
358
+ { code: 'operator-not-granted', severity: 'critical', message: operatorRequirement.message },
359
+ ]),
360
+ raw: status,
361
+ };
362
+ }
363
+ const mapped = this.mapper.map(status, { port });
205
364
  if (mapped.state !== 'connected') {
206
- return this.buildStatus(mapped.state, mapped.message, mapped.details, mapped.proxyAddresses, mapped.endpoints, postureAdvisories);
365
+ return {
366
+ status: this.buildStatus(mapped.state, mapped.message, mapped.details, mapped.proxyAddresses, mapped.endpoints, postureAdvisories),
367
+ raw: status,
368
+ };
207
369
  }
208
370
  const config = this.getPluginConfig();
209
- const serveResult = await this.serveService.apply(config, port, status);
210
- return this.buildStatus(mapped.state, mapped.message, mapped.details, [...mapped.proxyAddresses, ...serveResult.proxyAddresses], [...mapped.endpoints, ...serveResult.endpoints], [...postureAdvisories, ...serveResult.advisories]);
371
+ const serveResult = await this.serveService.read(config, port, status);
372
+ return {
373
+ status: this.buildStatus(mapped.state, mapped.message, mapped.details, [...mapped.proxyAddresses, ...serveResult.proxyAddresses], [...mapped.endpoints, ...serveResult.endpoints], [...postureAdvisories, ...serveResult.advisories]),
374
+ raw: status,
375
+ };
211
376
  }
212
377
  catch (error) {
213
378
  if (error instanceof tailscale_cli_service_1.TailscaleCliError) {
214
379
  switch (error.kind) {
215
380
  case 'not-installed':
216
- return this.buildStatus('not-installed', 'Tailscale is not installed.');
381
+ return { status: this.buildStatus('not-installed', 'Tailscale is not installed.'), raw: null };
217
382
  case 'permission-denied':
218
- return this.buildStatus('setup-required', 'The smart-panel operator has not been granted on tailscaled.');
383
+ return {
384
+ status: this.buildStatus('setup-required', 'The smart-panel operator has not been granted on tailscaled.'),
385
+ raw: null,
386
+ };
219
387
  case 'daemon-down':
220
- return this.buildStatus('setup-required', 'The Tailscale daemon is not running.');
388
+ return { status: this.buildStatus('setup-required', 'The Tailscale daemon is not running.'), raw: null };
221
389
  default:
222
- return this.buildStatus('error', 'Failed to retrieve the Tailscale status.');
390
+ return { status: this.buildStatus('error', 'Failed to retrieve the Tailscale status.'), raw: null };
223
391
  }
224
392
  }
225
393
  throw error;
226
394
  }
227
395
  }
396
+ async convergeServe(config, port, status) {
397
+ const result = await this.serveService.converge(config, port, status);
398
+ if (result.permissionDenied) {
399
+ if (!this.lastServeConvergeDenied) {
400
+ this.lastServeConvergeDenied = true;
401
+ this.logger.warn('Tailscale Serve/Funnel mutation was denied — the smart-panel operator grant may have been revoked.');
402
+ await this.refreshRequirements('permission-denied').catch(() => undefined);
403
+ }
404
+ }
405
+ else {
406
+ this.lastServeConvergeDenied = false;
407
+ }
408
+ return result;
409
+ }
228
410
  async evaluatePlatformSupported() {
229
411
  const platformType = await this.platformService.getPlatformTypeAsync();
230
412
  if (platformType === platform_constants_1.PlatformType.RASPBERRY || platformType === platform_constants_1.PlatformType.GENERIC) {
@@ -291,19 +473,41 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
291
473
  };
292
474
  }
293
475
  async evaluateOperatorGranted() {
476
+ const serviceUser = os_1.default.userInfo().username;
294
477
  try {
295
- await this.cli.getStatus();
296
- return { code: 'operator-granted', satisfied: true, message: 'The smart-panel operator is granted.' };
478
+ const prefs = await this.cli.getPrefs();
479
+ return this.buildOperatorRequirement(prefs.OperatorUser === serviceUser, serviceUser);
297
480
  }
298
481
  catch (error) {
299
482
  if (error instanceof tailscale_cli_service_1.TailscaleCliError) {
300
- if (error.kind === 'permission-denied') {
483
+ if (error.kind === 'daemon-down') {
301
484
  return {
302
485
  code: 'operator-granted',
303
486
  satisfied: false,
304
- message: 'The smart-panel operator has not been granted; run setup again.',
487
+ message: 'Cannot verify the operator grant while tailscaled is not running.',
305
488
  };
306
489
  }
490
+ if (error.kind === 'not-installed') {
491
+ return {
492
+ code: 'operator-granted',
493
+ satisfied: false,
494
+ message: 'Cannot verify the operator grant before Tailscale is installed.',
495
+ };
496
+ }
497
+ }
498
+ return this.evaluateOperatorGrantedViaProbe(serviceUser);
499
+ }
500
+ }
501
+ async evaluateOperatorGrantedViaProbe(serviceUser) {
502
+ try {
503
+ await this.cli.set([`--operator=${serviceUser}`]);
504
+ return this.buildOperatorRequirement(true, serviceUser);
505
+ }
506
+ catch (error) {
507
+ if (error instanceof tailscale_cli_service_1.TailscaleCliError) {
508
+ if (error.kind === 'permission-denied') {
509
+ return this.buildOperatorRequirement(false, serviceUser);
510
+ }
307
511
  if (error.kind === 'daemon-down') {
308
512
  return {
309
513
  code: 'operator-granted',
@@ -322,6 +526,15 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
322
526
  return { code: 'operator-granted', satisfied: false, message: 'Failed to verify the operator grant.' };
323
527
  }
324
528
  }
529
+ buildOperatorRequirement(satisfied, serviceUser) {
530
+ return {
531
+ code: 'operator-granted',
532
+ satisfied,
533
+ message: satisfied
534
+ ? OPERATOR_GRANTED_SATISFIED_MESSAGE
535
+ : `The ${serviceUser} user is not the tailscaled operator. Run Set up, or on the device run \`sudo tailscale set --operator=${serviceUser}\`.`,
536
+ };
537
+ }
325
538
  async getStatusOrNull() {
326
539
  try {
327
540
  return await this.cli.getStatus();
@@ -362,10 +575,13 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
362
575
  }
363
576
  async pollTick() {
364
577
  try {
365
- const status = await this.computeStatus();
578
+ const { status, raw } = await this.computeStatusWithRawStatus();
366
579
  if (!this.isPollable()) {
367
580
  return;
368
581
  }
582
+ if (raw && status.state === 'connected' && this.requirementsSatisfied(this.getRequirements())) {
583
+ await this.convergeServe(this.getPluginConfig(), this.getBackendPort(), raw);
584
+ }
369
585
  if (this.hasStatusChanged(this.lastStatus, status)) {
370
586
  this.lastStatus = status;
371
587
  this.eventEmitter.emit(remote_access_constants_1.EventType.PROVIDER_STATUS, status);