uiprotect 0.4.0__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.
- {uiprotect-0.4.0 → uiprotect-0.4.1}/PKG-INFO +1 -1
- {uiprotect-0.4.0 → uiprotect-0.4.1}/pyproject.toml +1 -1
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/api.py +15 -6
- {uiprotect-0.4.0 → uiprotect-0.4.1}/LICENSE +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/README.md +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/__init__.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/__main__.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/cli/__init__.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/cli/backup.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/cli/base.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/cli/cameras.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/cli/chimes.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/cli/doorlocks.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/cli/events.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/cli/lights.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/cli/liveviews.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/cli/nvr.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/cli/sensors.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/cli/viewers.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/data/__init__.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/data/base.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/data/bootstrap.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/data/convert.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/data/devices.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/data/nvr.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/data/types.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/data/user.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/data/websocket.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/exceptions.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/py.typed +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/release_cache.json +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/stream.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/test_util/__init__.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/test_util/anonymize.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/utils.py +0 -0
- {uiprotect-0.4.0 → uiprotect-0.4.1}/src/uiprotect/websocket.py +0 -0
|
@@ -161,6 +161,7 @@ class BaseApiClient:
|
|
|
161
161
|
_last_token_cookie_decode: dict[str, Any] | None = None
|
|
162
162
|
_session: aiohttp.ClientSession | None = None
|
|
163
163
|
_loaded_session: bool = False
|
|
164
|
+
_cookiename = "TOKEN"
|
|
164
165
|
|
|
165
166
|
headers: dict[str, str] | None = None
|
|
166
167
|
_websocket: Websocket | None = None
|
|
@@ -204,6 +205,10 @@ class BaseApiClient:
|
|
|
204
205
|
|
|
205
206
|
self._update_url()
|
|
206
207
|
|
|
208
|
+
def _update_cookiename(self, cookie: SimpleCookie) -> None:
|
|
209
|
+
if "UOS_TOKEN" in cookie:
|
|
210
|
+
self._cookiename = "UOS_TOKEN"
|
|
211
|
+
|
|
207
212
|
def _update_url(self) -> None:
|
|
208
213
|
"""Updates the url after changing _host or _port."""
|
|
209
214
|
if self._port != 443:
|
|
@@ -475,7 +480,6 @@ class BaseApiClient:
|
|
|
475
480
|
response = await self.request("post", url=url, json=auth)
|
|
476
481
|
self.set_header("cookie", response.headers.get("set-cookie", ""))
|
|
477
482
|
self._is_authenticated = True
|
|
478
|
-
await self._update_last_token_cookie(response)
|
|
479
483
|
_LOGGER.debug("Authenticated successfully!")
|
|
480
484
|
|
|
481
485
|
async def _update_last_token_cookie(self, response: aiohttp.ClientResponse) -> None:
|
|
@@ -488,9 +492,10 @@ class BaseApiClient:
|
|
|
488
492
|
):
|
|
489
493
|
self.set_header("x-csrf-token", csrf_token)
|
|
490
494
|
await self._update_last_token_cookie(response)
|
|
495
|
+
self._update_cookiename(response.cookies)
|
|
491
496
|
|
|
492
497
|
if (
|
|
493
|
-
token_cookie := response.cookies.get(
|
|
498
|
+
token_cookie := response.cookies.get(self._cookiename)
|
|
494
499
|
) and token_cookie != self._last_token_cookie:
|
|
495
500
|
self._last_token_cookie = token_cookie
|
|
496
501
|
if self.store_sessions:
|
|
@@ -520,6 +525,7 @@ class BaseApiClient:
|
|
|
520
525
|
config["sessions"] = config.get("sessions", {})
|
|
521
526
|
config["sessions"][session_hash] = {
|
|
522
527
|
"metadata": dict(cookie),
|
|
528
|
+
"cookiename": self._cookiename,
|
|
523
529
|
"value": cookie.value,
|
|
524
530
|
"csrf": self.headers.get("x-csrf-token") if self.headers else None,
|
|
525
531
|
}
|
|
@@ -561,12 +567,15 @@ class BaseApiClient:
|
|
|
561
567
|
return None
|
|
562
568
|
|
|
563
569
|
cookie = SimpleCookie()
|
|
564
|
-
|
|
570
|
+
cookie_name = session.get("cookiename")
|
|
571
|
+
if cookie_name is None:
|
|
572
|
+
return None
|
|
573
|
+
cookie[cookie_name] = session.get("value")
|
|
565
574
|
for key, value in session.get("metadata", {}).items():
|
|
566
|
-
cookie[
|
|
575
|
+
cookie[cookie_name][key] = value
|
|
567
576
|
|
|
568
|
-
cookie_value = _COOKIE_RE.sub("", str(cookie[
|
|
569
|
-
self._last_token_cookie = cookie[
|
|
577
|
+
cookie_value = _COOKIE_RE.sub("", str(cookie[cookie_name]))
|
|
578
|
+
self._last_token_cookie = cookie[cookie_name]
|
|
570
579
|
self._last_token_cookie_decode = None
|
|
571
580
|
self._is_authenticated = True
|
|
572
581
|
self.set_header("cookie", cookie_value)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|