uiprotect 0.3.10__tar.gz → 0.4.1__tar.gz

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.

Potentially problematic release.


This version of uiprotect might be problematic. Click here for more details.

Files changed (36) hide show
  1. {uiprotect-0.3.10 → uiprotect-0.4.1}/PKG-INFO +1 -1
  2. {uiprotect-0.3.10 → uiprotect-0.4.1}/pyproject.toml +1 -1
  3. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/api.py +17 -9
  4. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/data/bootstrap.py +2 -3
  5. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/data/websocket.py +1 -2
  6. {uiprotect-0.3.10 → uiprotect-0.4.1}/LICENSE +0 -0
  7. {uiprotect-0.3.10 → uiprotect-0.4.1}/README.md +0 -0
  8. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/__init__.py +0 -0
  9. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/__main__.py +0 -0
  10. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/cli/__init__.py +0 -0
  11. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/cli/backup.py +0 -0
  12. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/cli/base.py +0 -0
  13. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/cli/cameras.py +0 -0
  14. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/cli/chimes.py +0 -0
  15. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/cli/doorlocks.py +0 -0
  16. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/cli/events.py +0 -0
  17. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/cli/lights.py +0 -0
  18. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/cli/liveviews.py +0 -0
  19. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/cli/nvr.py +0 -0
  20. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/cli/sensors.py +0 -0
  21. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/cli/viewers.py +0 -0
  22. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/data/__init__.py +0 -0
  23. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/data/base.py +0 -0
  24. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/data/convert.py +0 -0
  25. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/data/devices.py +0 -0
  26. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/data/nvr.py +0 -0
  27. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/data/types.py +0 -0
  28. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/data/user.py +0 -0
  29. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/exceptions.py +0 -0
  30. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/py.typed +0 -0
  31. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/release_cache.json +0 -0
  32. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/stream.py +0 -0
  33. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/test_util/__init__.py +0 -0
  34. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/test_util/anonymize.py +0 -0
  35. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/utils.py +0 -0
  36. {uiprotect-0.3.10 → uiprotect-0.4.1}/src/uiprotect/websocket.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uiprotect
3
- Version: 0.3.10
3
+ Version: 0.4.1
4
4
  Summary: Python API for Unifi Protect (Unofficial)
5
5
  Home-page: https://github.com/uilibs/uiprotect
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "uiprotect"
3
- version = "0.3.10"
3
+ version = "0.4.1"
4
4
  description = "Python API for Unifi Protect (Unofficial)"
5
5
  authors = ["UI Protect Maintainers <ui@koston.org>"]
6
6
  license = "MIT"
@@ -16,7 +16,6 @@ from ipaddress import IPv4Address, IPv6Address
16
16
  from pathlib import Path
17
17
  from typing import Any, Literal, cast
18
18
  from urllib.parse import urljoin
19
- from uuid import UUID
20
19
 
21
20
  import aiofiles
22
21
  import aiohttp
@@ -162,6 +161,7 @@ class BaseApiClient:
162
161
  _last_token_cookie_decode: dict[str, Any] | None = None
163
162
  _session: aiohttp.ClientSession | None = None
164
163
  _loaded_session: bool = False
164
+ _cookiename = "TOKEN"
165
165
 
166
166
  headers: dict[str, str] | None = None
167
167
  _websocket: Websocket | None = None
@@ -205,6 +205,10 @@ class BaseApiClient:
205
205
 
206
206
  self._update_url()
207
207
 
208
+ def _update_cookiename(self, cookie: SimpleCookie) -> None:
209
+ if "UOS_TOKEN" in cookie:
210
+ self._cookiename = "UOS_TOKEN"
211
+
208
212
  def _update_url(self) -> None:
209
213
  """Updates the url after changing _host or _port."""
210
214
  if self._port != 443:
@@ -476,7 +480,6 @@ class BaseApiClient:
476
480
  response = await self.request("post", url=url, json=auth)
477
481
  self.set_header("cookie", response.headers.get("set-cookie", ""))
478
482
  self._is_authenticated = True
479
- await self._update_last_token_cookie(response)
480
483
  _LOGGER.debug("Authenticated successfully!")
481
484
 
482
485
  async def _update_last_token_cookie(self, response: aiohttp.ClientResponse) -> None:
@@ -489,9 +492,10 @@ class BaseApiClient:
489
492
  ):
490
493
  self.set_header("x-csrf-token", csrf_token)
491
494
  await self._update_last_token_cookie(response)
495
+ self._update_cookiename(response.cookies)
492
496
 
493
497
  if (
494
- token_cookie := response.cookies.get("TOKEN")
498
+ token_cookie := response.cookies.get(self._cookiename)
495
499
  ) and token_cookie != self._last_token_cookie:
496
500
  self._last_token_cookie = token_cookie
497
501
  if self.store_sessions:
@@ -521,6 +525,7 @@ class BaseApiClient:
521
525
  config["sessions"] = config.get("sessions", {})
522
526
  config["sessions"][session_hash] = {
523
527
  "metadata": dict(cookie),
528
+ "cookiename": self._cookiename,
524
529
  "value": cookie.value,
525
530
  "csrf": self.headers.get("x-csrf-token") if self.headers else None,
526
531
  }
@@ -562,12 +567,15 @@ class BaseApiClient:
562
567
  return None
563
568
 
564
569
  cookie = SimpleCookie()
565
- cookie["TOKEN"] = session.get("value")
570
+ cookie_name = session.get("cookiename")
571
+ if cookie_name is None:
572
+ return None
573
+ cookie[cookie_name] = session.get("value")
566
574
  for key, value in session.get("metadata", {}).items():
567
- cookie["TOKEN"][key] = value
575
+ cookie[cookie_name][key] = value
568
576
 
569
- cookie_value = _COOKIE_RE.sub("", str(cookie["TOKEN"]))
570
- self._last_token_cookie = cookie["TOKEN"]
577
+ cookie_value = _COOKIE_RE.sub("", str(cookie[cookie_name]))
578
+ self._last_token_cookie = cookie[cookie_name]
571
579
  self._last_token_cookie_decode = None
572
580
  self._is_authenticated = True
573
581
  self.set_header("cookie", cookie_value)
@@ -647,7 +655,7 @@ class BaseApiClient:
647
655
  def _process_ws_message(self, msg: aiohttp.WSMessage) -> None:
648
656
  raise NotImplementedError
649
657
 
650
- def _get_last_update_id(self) -> UUID | None:
658
+ def _get_last_update_id(self) -> str | None:
651
659
  raise NotImplementedError
652
660
 
653
661
 
@@ -833,7 +841,7 @@ class ProtectApiClient(BaseApiClient):
833
841
  except Exception:
834
842
  _LOGGER.exception("Exception while running subscription handler")
835
843
 
836
- def _get_last_update_id(self) -> UUID | None:
844
+ def _get_last_update_id(self) -> str | None:
837
845
  if self._bootstrap is None:
838
846
  return None
839
847
  return self._bootstrap.last_update_id
@@ -8,7 +8,6 @@ from copy import deepcopy
8
8
  from dataclasses import dataclass
9
9
  from datetime import datetime
10
10
  from typing import Any, cast
11
- from uuid import UUID
12
11
 
13
12
  from aiohttp.client_exceptions import ServerDisconnectedError
14
13
 
@@ -179,7 +178,7 @@ class Bootstrap(ProtectBaseObject):
179
178
  sensors: dict[str, Sensor]
180
179
  doorlocks: dict[str, Doorlock]
181
180
  chimes: dict[str, Chime]
182
- last_update_id: UUID
181
+ last_update_id: str
183
182
 
184
183
  # TODO:
185
184
  # schedules
@@ -546,7 +545,7 @@ class Bootstrap(ProtectBaseObject):
546
545
 
547
546
  action, data = self._get_frame_data(packet)
548
547
  if action["newUpdateId"] is not None:
549
- self.last_update_id = UUID(action["newUpdateId"])
548
+ self.last_update_id = action["newUpdateId"]
550
549
 
551
550
  if action["modelKey"] not in ModelType.values():
552
551
  _LOGGER.debug("Unknown model type: %s", action["modelKey"])
@@ -8,7 +8,6 @@ import struct
8
8
  import zlib
9
9
  from dataclasses import dataclass
10
10
  from typing import TYPE_CHECKING, Any
11
- from uuid import UUID
12
11
 
13
12
  import orjson
14
13
 
@@ -40,7 +39,7 @@ class WSAction(str, enum.Enum):
40
39
  @dataclass
41
40
  class WSSubscriptionMessage:
42
41
  action: WSAction
43
- new_update_id: UUID
42
+ new_update_id: str
44
43
  changed_data: dict[str, Any]
45
44
  new_obj: ProtectModelWithId | None = None
46
45
  old_obj: ProtectModelWithId | None = None
File without changes
File without changes