homebridge-unifi-protect 4.4.3 → 4.4.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.
@@ -1,555 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __importDefault = (this && this.__importDefault) || function (mod) {
22
- return (mod && mod.__esModule) ? mod : { "default": mod };
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.ProtectApi = void 0;
26
- /* Copyright(C) 2021, HJD (https://github.com/hjdhjd). All rights reserved.
27
- *
28
- * protect-api.ts: Our UniFi Protect API implementation.
29
- */
30
- const settings_1 = require("./settings");
31
- const node_fetch_1 = __importStar(require("node-fetch"));
32
- const https_1 = __importDefault(require("https"));
33
- const abort_controller_1 = require("abort-controller");
34
- const ws_1 = __importDefault(require("ws"));
35
- const util_1 = __importDefault(require("util"));
36
- /*
37
- * The UniFi Protect API is largely undocumented and has been reverse engineered mostly through
38
- * the web interface, and trial and error.
39
- *
40
- * Here's how the UniFi Protect API works:
41
- *
42
- * 1. Login to the UniFi Protect NVR device and acquire security credentials for further calls to the API.
43
- *
44
- * 2. Enumerate the list of UniFi Protect devices by calling the bootstrap URL. This
45
- * contains almost everything you would want to know about this particular UniFi Protect NVR
46
- * installation.
47
- *
48
- * Those are the basics and gets us up and running.
49
- */
50
- class ProtectApi {
51
- // Initialize this instance with our login information.
52
- constructor(platform, nvrAddress, username, password) {
53
- this.apiErrorCount = 0;
54
- this.apiLastSuccess = 0;
55
- this.debug = platform.debug.bind(platform);
56
- this.log = platform.log;
57
- this.nvrAddress = nvrAddress;
58
- this.username = username;
59
- this.password = password;
60
- this.clearLoginCredentials();
61
- }
62
- // Identify which NVR device type we're logging into and acquire a CSRF token if needed.
63
- async acquireToken() {
64
- // We only need to acquire a token if we aren't already logged in, or we don't already have a token,
65
- // or don't know which device type we're on.
66
- if (this.loggedIn || this.headers.has("X-CSRF-Token") || this.headers.has("Authorization")) {
67
- return true;
68
- }
69
- // UniFi OS has cross-site request forgery protection built into it's web management UI.
70
- // We use this fact to fingerprint it by connecting directly to the supplied NVR address
71
- // and see ifing there's a CSRF token waiting for us.
72
- const response = await this.fetch("https://" + this.nvrAddress, { method: "GET" }, false);
73
- if (response === null || response === void 0 ? void 0 : response.ok) {
74
- const csrfToken = response.headers.get("X-CSRF-Token");
75
- // We found a token.
76
- if (csrfToken) {
77
- this.headers.set("X-CSRF-Token", csrfToken);
78
- // UniFi OS has support for keepalive. Let's take advantage of that and reduce the workload on controllers.
79
- this.httpsAgent = new https_1.default.Agent({ keepAlive: true, maxFreeSockets: 5, maxSockets: 10, rejectUnauthorized: false, timeout: 60 * 1000 });
80
- return true;
81
- }
82
- }
83
- // Couldn't deduce what type of NVR device we were connecting to.
84
- return false;
85
- }
86
- // Log into UniFi Protect.
87
- async login() {
88
- const now = Date.now();
89
- // Is it time to renew our credentials?
90
- if (now > (this.loginAge + (settings_1.PROTECT_LOGIN_REFRESH_INTERVAL * 1000))) {
91
- this.loggedIn = false;
92
- this.headers = new node_fetch_1.Headers();
93
- this.headers.set("Content-Type", "application/json");
94
- }
95
- // If we're already logged in, and it's not time to renew our credentials, we're done.
96
- if (this.loggedIn) {
97
- return true;
98
- }
99
- // Make sure we have a token, or get one if needed.
100
- if (!(await this.acquireToken())) {
101
- return false;
102
- }
103
- // Log us in.
104
- const response = await this.fetch(this.authUrl(), {
105
- body: JSON.stringify({ password: this.password, username: this.username }),
106
- method: "POST"
107
- });
108
- if (!(response === null || response === void 0 ? void 0 : response.ok)) {
109
- return false;
110
- }
111
- // We're logged in.
112
- this.loggedIn = true;
113
- this.loginAge = now;
114
- // Configure headers.
115
- const csrfToken = response.headers.get("X-CSRF-Token");
116
- const cookie = response.headers.get("Set-Cookie");
117
- if (csrfToken && cookie && this.headers.has("X-CSRF-Token")) {
118
- this.headers.set("Cookie", cookie);
119
- this.headers.set("X-CSRF-Token", csrfToken);
120
- return true;
121
- }
122
- // Clear out our login credentials and reset for another try.
123
- this.clearLoginCredentials();
124
- return false;
125
- }
126
- // Get our UniFi Protect NVR configuration.
127
- async bootstrapProtect() {
128
- // Log us in if needed.
129
- if (!(await this.login())) {
130
- return false;
131
- }
132
- const response = await this.fetch(this.bootstrapUrl(), { method: "GET" });
133
- if (!(response === null || response === void 0 ? void 0 : response.ok)) {
134
- this.log.error("%s: Unable to retrieve NVR configuration information from UniFi Protect. Will retry again later.", this.getNvrName());
135
- // Clear out our login credentials and reset for another try.
136
- this.clearLoginCredentials();
137
- return false;
138
- }
139
- // Now let's get our NVR configuration information.
140
- let data = null;
141
- try {
142
- data = await response.json();
143
- }
144
- catch (error) {
145
- data = null;
146
- this.log.error("%s: Unable to parse response from UniFi Protect. Will retry again later.", this.getNvrName());
147
- }
148
- // No camera information returned.
149
- if (!(data === null || data === void 0 ? void 0 : data.cameras)) {
150
- this.log.error("%s: Unable to retrieve camera information from UniFi Protect. Will retry again later.", this.getNvrName());
151
- // Clear out our login credentials and reset for another try.
152
- this.clearLoginCredentials();
153
- return false;
154
- }
155
- // On launch, let the user know we made it.
156
- const firstRun = this.bootstrap ? false : true;
157
- this.bootstrap = data;
158
- if (firstRun) {
159
- this.log.info("%s: Connected to the Protect controller API (address: %s mac: %s).", this.getNvrName(), data.nvr.host, data.nvr.mac);
160
- }
161
- // Capture the bootstrap if we're debugging.
162
- this.debug(util_1.default.inspect(this.bootstrap, { colors: true, depth: null, sorted: true }));
163
- // Check for admin user privileges or role changes.
164
- this.checkAdminUserStatus(firstRun);
165
- // We're good. Now connect to the event listener API.
166
- return this.launchUpdatesListener();
167
- }
168
- // Connect to the realtime update events API.
169
- async launchUpdatesListener() {
170
- var _a, _b, _c;
171
- // Log us in if needed.
172
- if (!(await this.login())) {
173
- return false;
174
- }
175
- // If we already have a listener, we're already all set.
176
- if (this.eventListener) {
177
- return true;
178
- }
179
- const params = new URLSearchParams({ lastUpdateId: (_b = (_a = this.bootstrap) === null || _a === void 0 ? void 0 : _a.lastUpdateId) !== null && _b !== void 0 ? _b : "" });
180
- this.debug("Update listener: %s", this.updatesUrl() + "?" + params.toString());
181
- try {
182
- const ws = new ws_1.default(this.updatesUrl() + "?" + params.toString(), {
183
- headers: {
184
- Cookie: (_c = this.headers.get("Cookie")) !== null && _c !== void 0 ? _c : ""
185
- },
186
- rejectUnauthorized: false
187
- });
188
- if (!ws) {
189
- this.log.error("Unable to connect to the realtime update events API. Will retry again later.");
190
- this.eventListener = null;
191
- this.eventListenerConfigured = false;
192
- return false;
193
- }
194
- this.eventListener = ws;
195
- // Setup our heartbeat to ensure we can revive our connection if needed.
196
- this.eventListener.on("message", this.heartbeatEventListener.bind(this));
197
- this.eventListener.on("open", this.heartbeatEventListener.bind(this));
198
- this.eventListener.on("ping", this.heartbeatEventListener.bind(this));
199
- this.eventListener.on("close", () => {
200
- clearTimeout(this.eventHeartbeatTimer);
201
- });
202
- this.eventListener.on("error", (error) => {
203
- var _a;
204
- // If we're closing before fully established it's because we're shutting down the API - ignore it.
205
- if (error.message !== "WebSocket was closed before the connection was established") {
206
- this.log.error("%s: %s", this.getNvrName(), error);
207
- }
208
- (_a = this.eventListener) === null || _a === void 0 ? void 0 : _a.terminate();
209
- this.eventListener = null;
210
- this.eventListenerConfigured = false;
211
- });
212
- this.log.info("%s: Connected to the UniFi realtime update events API.", this.getNvrName());
213
- }
214
- catch (error) {
215
- this.log.error("%s: Error connecting to the realtime update events API: %s", this.getNvrName(), error);
216
- }
217
- return true;
218
- }
219
- // Get the list of UniFi Protect devices associated with a NVR.
220
- async refreshDevices() {
221
- var _a, _b;
222
- // Refresh the configuration from the NVR.
223
- if (!(await this.bootstrapProtect())) {
224
- return false;
225
- }
226
- this.debug(util_1.default.inspect(this.bootstrap, { colors: true, depth: null, sorted: true }));
227
- const newDeviceList = (_a = this.bootstrap) === null || _a === void 0 ? void 0 : _a.cameras;
228
- // Notify the user about any new devices that we've discovered.
229
- if (newDeviceList) {
230
- for (const newDevice of newDeviceList) {
231
- // We already know about this device.
232
- if ((_b = this.Cameras) === null || _b === void 0 ? void 0 : _b.some((x) => x.mac === newDevice.mac)) {
233
- continue;
234
- }
235
- // We only want to discover managed devices.
236
- if (!newDevice.isManaged) {
237
- continue;
238
- }
239
- // We've discovered a new device.
240
- this.log.info("%s: Discovered %s: %s.", this.getNvrName(), newDevice.modelKey, this.getDeviceName(newDevice, newDevice.name, true));
241
- this.debug(util_1.default.inspect(newDevice, { colors: true, depth: null, sorted: true }));
242
- }
243
- }
244
- // Notify the user about any devices that have disappeared.
245
- if (this.Cameras) {
246
- for (const existingDevice of this.Cameras) {
247
- // This device still is visible.
248
- if (newDeviceList === null || newDeviceList === void 0 ? void 0 : newDeviceList.some((x) => x.mac === existingDevice.mac)) {
249
- continue;
250
- }
251
- // We've had a device disappear.
252
- this.debug("%s: Detected %s removal.", this.getFullName(existingDevice), existingDevice.modelKey);
253
- this.debug(util_1.default.inspect(existingDevice, { colors: true, depth: null, sorted: true }));
254
- }
255
- }
256
- // Save the updated list of devices.
257
- this.Cameras = newDeviceList;
258
- return true;
259
- }
260
- // Validate if all RTSP channels enabled on all cameras.
261
- isAllRtspConfigured() {
262
- var _a, _b;
263
- // Look for any cameras with any non-RTSP enabled channels.
264
- return ((_b = (_a = this.bootstrap) === null || _a === void 0 ? void 0 : _a.cameras) === null || _b === void 0 ? void 0 : _b.some(camera => { var _a; return (_a = camera.channels) === null || _a === void 0 ? void 0 : _a.some(channel => !channel.isRtspEnabled); })) ? true : false;
265
- }
266
- // Check admin privileges.
267
- checkAdminUserStatus(firstRun = false) {
268
- var _a, _b;
269
- if (!((_a = this.bootstrap) === null || _a === void 0 ? void 0 : _a.users)) {
270
- return false;
271
- }
272
- // Save our prior state so we can detect role changes without having to restart.
273
- const oldAdminStatus = this.isAdminUser;
274
- // Find this user.
275
- const user = (_b = this.bootstrap) === null || _b === void 0 ? void 0 : _b.users.find((x) => { var _a; return x.id === ((_a = this.bootstrap) === null || _a === void 0 ? void 0 : _a.authUserId); });
276
- if (!(user === null || user === void 0 ? void 0 : user.allPermissions)) {
277
- return false;
278
- }
279
- // Let's figure out this user's permissions.
280
- let newAdminStatus = false;
281
- for (const entry of user.allPermissions) {
282
- // Each permission line exists as: permissiontype:permissions:scope.
283
- const permType = entry.split(":");
284
- // We only care about camera permissions.
285
- if (permType[0] !== "camera") {
286
- continue;
287
- }
288
- // Get the individual permissions.
289
- const permissions = permType[1].split(",");
290
- // We found our administrative privileges - we're done.
291
- if (permissions.indexOf("write") !== -1) {
292
- newAdminStatus = true;
293
- break;
294
- }
295
- }
296
- this.isAdminUser = newAdminStatus;
297
- // Only admin users can activate RTSP streams. Inform the user on startup, or if we detect a role change.
298
- if (firstRun && !this.isAdminUser) {
299
- this.log.info("%s: The user '%s' requires the Administrator role in order to automatically configure camera RTSP streams.", this.getNvrName(), this.username);
300
- }
301
- else if (!firstRun && (oldAdminStatus !== this.isAdminUser)) {
302
- this.log.info("%s: Detected a role change for user '%s': the Administrator role has been %s.", this.getNvrName(), this.username, this.isAdminUser ? "enabled" : "disabled");
303
- }
304
- return true;
305
- }
306
- // Enable RTSP stream support on an attached Protect device.
307
- async enableRtsp(device) {
308
- var _a;
309
- // Log us in if needed.
310
- if (!(await this.login())) {
311
- return null;
312
- }
313
- // Only admin users can activate RTSP streams.
314
- if (!this.isAdminUser) {
315
- return null;
316
- }
317
- // At the moment, we only know about camera devices.
318
- if (device.modelKey !== "camera") {
319
- return null;
320
- }
321
- // Do we have any non-RTSP enabled channels? If not, we're done.
322
- if (!((_a = device.channels) === null || _a === void 0 ? void 0 : _a.some(channel => !channel.isRtspEnabled))) {
323
- return device;
324
- }
325
- // Enable RTSP on all available channels.
326
- device.channels = device.channels.map((channel) => {
327
- channel.isRtspEnabled = true;
328
- return channel;
329
- });
330
- // Update Protect with the new configuration.
331
- const response = await this.fetch(this.camerasUrl() + "/" + device.id, {
332
- body: JSON.stringify({ channels: device.channels }),
333
- method: "PATCH"
334
- }, true, false);
335
- // Since we took responsibility for interpreting the outcome of the fetch, we need to check for
336
- // errors for ourself.
337
- if (!response || !(response === null || response === void 0 ? void 0 : response.ok)) {
338
- this.apiErrorCount++;
339
- if ((response === null || response === void 0 ? void 0 : response.status) === 403) {
340
- this.log.error("%s: Insufficient privileges to enable RTSP on all channels. Please ensure this username has the Administrator role assigned in UniFi Protect.", this.getFullName(device));
341
- }
342
- else {
343
- this.log.error("%s: Unable to enable RTSP on all channels: %s.", this.getFullName(device), response === null || response === void 0 ? void 0 : response.status);
344
- }
345
- // We still return our camera object if there is at least one RTSP channel enabled.
346
- return device;
347
- }
348
- // Since we have taken responsibility for decoding response types, we need to reset our API backoff count.
349
- this.apiErrorCount = 0;
350
- this.apiLastSuccess = Date.now();
351
- // Everything worked, save the new channel array.
352
- return await response.json();
353
- }
354
- // Update a camera object.
355
- async updateCamera(device, payload) {
356
- // No device object, we're done.
357
- if (!device) {
358
- return null;
359
- }
360
- // Log us in if needed.
361
- if (!(await this.login())) {
362
- return null;
363
- }
364
- // Only admin users can show messages on doorbells.
365
- if (!this.isAdminUser) {
366
- return null;
367
- }
368
- this.debug("%s: %s", this.getFullName(device), util_1.default.inspect(payload, { colors: true, depth: null, sorted: true }));
369
- // Update Protect with the new configuration.
370
- const response = await this.fetch(this.camerasUrl() + "/" + device.id, {
371
- body: JSON.stringify(payload),
372
- method: "PATCH"
373
- });
374
- if (!(response === null || response === void 0 ? void 0 : response.ok)) {
375
- this.log.error("%s: Unable to configure the camera: %s.", this.getFullName(device), response === null || response === void 0 ? void 0 : response.status);
376
- return null;
377
- }
378
- // We successfully set the message, return the updated device object.
379
- return await response.json();
380
- }
381
- // Utility to generate a nicely formatted NVR string.
382
- getNvrName() {
383
- var _a;
384
- // Our NVR string, if it exists, appears as:
385
- // NVR [NVR Type].
386
- // Otherwise, we appear as NVRaddress.
387
- if ((_a = this.bootstrap) === null || _a === void 0 ? void 0 : _a.nvr) {
388
- return this.bootstrap.nvr.name + " [" + this.bootstrap.nvr.type + "]";
389
- }
390
- else {
391
- return this.nvrAddress;
392
- }
393
- }
394
- // Utility to generate a nicely formatted device string.
395
- getDeviceName(camera, name = camera === null || camera === void 0 ? void 0 : camera.name, cameraInfo = false) {
396
- // Validate our inputs.
397
- if (!camera) {
398
- return "";
399
- }
400
- // A completely enumerated device will appear as:
401
- // Camera [Camera Type] (address: IP address, mac: MAC address).
402
- return name + " [" + camera.type + "]" +
403
- (cameraInfo ? " (address: " + camera.host + " mac: " + camera.mac + ")" : "");
404
- }
405
- // Utility to generate a nicely formatted NVR and device string.
406
- getFullName(camera) {
407
- const cameraName = this.getDeviceName(camera);
408
- // Returns: NVR [NVR Type] Camera [Camera Type]
409
- return this.getNvrName() + (cameraName.length > 0 ? " " + cameraName : "");
410
- }
411
- // Return the URL to directly access cameras, adjusting for Protect NVR variants.
412
- camerasUrl() {
413
- // Boostrapping a UniFi OS device is done through: https://protect-nvr-ip/proxy/protect/api/cameras/CAMERAID.
414
- return "https://" + this.nvrAddress + "/proxy/protect/api/cameras";
415
- }
416
- // Return the right authentication URL, depending on which Protect NVR platform we are using.
417
- authUrl() {
418
- // Authenticating a UniFi OS device is done through: https://protect-nvr-ip/api/auth/login.
419
- return "https://" + this.nvrAddress + "/api/auth/login";
420
- }
421
- // Return the right bootstrap URL, depending on which Protect NVR platform we are using.
422
- bootstrapUrl() {
423
- // Boostrapping a UniFi OS device is done through: https://protect-nvr-ip/proxy/protect/api/bootstrap.
424
- return "https://" + this.nvrAddress + "/proxy/protect/api/bootstrap";
425
- }
426
- // Return the realtime system events API URL.
427
- systemUrl() {
428
- return "wss://" + this.nvrAddress + "/api/ws/system";
429
- }
430
- // Return the realtime update events API URL.
431
- updatesUrl() {
432
- return "wss://" + this.nvrAddress + "/proxy/protect/ws/updates";
433
- }
434
- // Utility to check the heartbeat of our listener.
435
- heartbeatEventListener() {
436
- // Clear out our last timer and set a new one.
437
- clearTimeout(this.eventHeartbeatTimer);
438
- // We use terminate() to immediately destroy the connection, instead of close(), which waits for the close timer.
439
- this.eventHeartbeatTimer = setTimeout(() => {
440
- var _a;
441
- (_a = this.eventListener) === null || _a === void 0 ? void 0 : _a.terminate();
442
- this.eventListener = null;
443
- this.eventListenerConfigured = false;
444
- }, settings_1.PROTECT_EVENTS_HEARTBEAT_INTERVAL * 1000);
445
- }
446
- // Utility to clear out old login credentials or attempts.
447
- clearLoginCredentials() {
448
- var _a, _b;
449
- this.isAdminUser = false;
450
- this.loggedIn = false;
451
- this.loginAge = 0;
452
- this.bootstrap = null;
453
- // Shutdown any event listeners, if we have them.
454
- (_a = this.eventListener) === null || _a === void 0 ? void 0 : _a.terminate();
455
- this.eventListener = null;
456
- this.eventListenerConfigured = false;
457
- // Initialize the headers we need.
458
- this.headers = new node_fetch_1.Headers();
459
- this.headers.set("Content-Type", "application/json");
460
- // We want the initial agent to be connection-agnostic, except for certificate validate since Protect uses self-signed certificates.
461
- // and we want to disable TLS validation, at a minimum. We want to take advantage of the fact that it supports keepalives to reduce
462
- // workloads, but we deal with that elsewhere in acquireToken.
463
- (_b = this.httpsAgent) === null || _b === void 0 ? void 0 : _b.destroy();
464
- this.httpsAgent = new https_1.default.Agent({ rejectUnauthorized: false });
465
- }
466
- // Utility to let us streamline error handling and return checking from the Protect API.
467
- async fetch(url, options = { method: "GET" }, logErrors = true, decodeResponse = true) {
468
- let response;
469
- const controller = new abort_controller_1.AbortController();
470
- // Ensure API responsiveness and guard against hung connections.
471
- const timeout = setTimeout(() => {
472
- controller.abort();
473
- }, 1000 * settings_1.PROTECT_API_TIMEOUT);
474
- options.agent = this.httpsAgent;
475
- options.headers = this.headers;
476
- options.signal = controller.signal;
477
- try {
478
- const now = Date.now();
479
- // Throttle this after PROTECT_API_ERROR_LIMIT attempts.
480
- if (this.apiErrorCount >= settings_1.PROTECT_API_ERROR_LIMIT) {
481
- // Let the user know we've got an API problem.
482
- if (this.apiErrorCount === settings_1.PROTECT_API_ERROR_LIMIT) {
483
- this.log.info("%s: Throttling API calls due to errors with the %s previous attempts. I'll retry again in %s minutes.", this.getNvrName(), this.apiErrorCount, settings_1.PROTECT_API_RETRY_INTERVAL / 60);
484
- this.apiErrorCount++;
485
- this.apiLastSuccess = now;
486
- return null;
487
- }
488
- // Throttle our API calls.
489
- if ((this.apiLastSuccess + (settings_1.PROTECT_API_RETRY_INTERVAL * 1000)) > now) {
490
- return null;
491
- }
492
- // Inform the user that we're out of the penalty box and try again.
493
- this.log.info("%s: Resuming connectivity to the UniFi Protect API after throttling for %s minutes.", this.getNvrName(), settings_1.PROTECT_API_RETRY_INTERVAL / 60);
494
- this.apiErrorCount = 0;
495
- }
496
- response = await (0, node_fetch_1.default)(url, options);
497
- // The caller will sort through responses instead of us.
498
- if (!decodeResponse) {
499
- return response;
500
- }
501
- // Bad username and password.
502
- if (response.status === 401) {
503
- this.log.error("Invalid login credentials given. Please check your login and password.");
504
- this.apiErrorCount++;
505
- return null;
506
- }
507
- // Insufficient privileges.
508
- if (response.status === 403) {
509
- this.apiErrorCount++;
510
- this.log.error("Insufficient privileges for this user. Please check the roles assigned to this user and ensure it has sufficient privileges.");
511
- return null;
512
- }
513
- // Some other unknown error occurred.
514
- if (!response.ok) {
515
- this.apiErrorCount++;
516
- this.log.error("API access error: %s - %s", response.status, response.statusText);
517
- return null;
518
- }
519
- this.apiLastSuccess = Date.now();
520
- this.apiErrorCount = 0;
521
- return response;
522
- }
523
- catch (error) {
524
- this.apiErrorCount++;
525
- if (error instanceof node_fetch_1.AbortError) {
526
- this.log.error("%s: Controller API connection terminated because it was taking too long. This error can usually be safely ignored.", this.getNvrName());
527
- return null;
528
- }
529
- if (error instanceof node_fetch_1.FetchError) {
530
- switch (error.code) {
531
- case "ECONNREFUSED":
532
- this.log.error("%s: Controller API connection refused.", this.getNvrName());
533
- break;
534
- case "ECONNRESET":
535
- this.log.error("%s: Controller API connection reset.", this.getNvrName());
536
- break;
537
- case "ENOTFOUND":
538
- this.log.error("%s: Hostname or IP address not found. Please ensure the address you configured for this UniFi Protect controller is correct.", this.getNvrName());
539
- break;
540
- default:
541
- if (logErrors) {
542
- this.log.error(error.message);
543
- }
544
- }
545
- }
546
- return null;
547
- }
548
- finally {
549
- // Clear out our response timeout if needed.
550
- clearTimeout(timeout);
551
- }
552
- }
553
- }
554
- exports.ProtectApi = ProtectApi;
555
- //# sourceMappingURL=protect-api.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"protect-api.js","sourceRoot":"","sources":["../src/protect-api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;GAGG;AACH,yCAMoB;AASpB,yDAAwG;AACxG,kDAAqC;AACrC,uDAAmD;AAGnD,4CAA2B;AAC3B,gDAAwB;AAExB;;;;;;;;;;;;;GAaG;AAEH,MAAa,UAAU;IAmBrB,uDAAuD;IACvD,YAAY,QAAyB,EAAE,UAAkB,EAAE,QAAgB,EAAE,QAAgB;QAC3F,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3C,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;QACxB,IAAI,CAAC,UA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AAY,uBAAU,EAAE;gBAC9B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,oHAAoH,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;gBACxJ,OAAO,IAAI,CAAC;aACb;YAED,IAAG,KAAK,YAAY,uBAAU,EAAE;gBAE9B,QAAO,KAAK,CAAC,IAAI,EAAE;oBACjB,KAAK,cAAc;wBACjB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,wCAAwC,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;wBAC5E,MAAM;oBAER,KAAK,YAAY;wBACf,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,sCAAsC,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;wBAC1E,MAAM;oBAER,KAAK,WAAW;wBACd,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,8HAA8H,EAC3I,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;wBACrB,MAAM;oBAER;wBACE,IAAG,SAAS,EAAE;4BACZ,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;yBAC/B;iBACJ;aACF;YAED,OAAO,IAAI,CAAC;SAEb;gBAAS;YAER,4CAA4C;YAC5C,YAAY,CAAC,OAAO,CAAC,CAAC;SACvB;IACH,CAAC;CACF;AAnpBD,gCAmpBC"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=protect-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"protect-types.js","sourceRoot":"","sources":["../src/protect-types.ts"],"names":[],"mappings":""}