pixelarraythirdparty 1.1.3__tar.gz → 1.1.4__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.
Files changed (22) hide show
  1. {pixelarraythirdparty-1.1.3 → pixelarraythirdparty-1.1.4}/PKG-INFO +1 -1
  2. {pixelarraythirdparty-1.1.3 → pixelarraythirdparty-1.1.4}/pixelarraythirdparty/__init__.py +1 -1
  3. {pixelarraythirdparty-1.1.3 → pixelarraythirdparty-1.1.4}/pixelarraythirdparty/unified_login/unified_login.py +83 -0
  4. {pixelarraythirdparty-1.1.3 → pixelarraythirdparty-1.1.4}/pixelarraythirdparty.egg-info/PKG-INFO +1 -1
  5. {pixelarraythirdparty-1.1.3 → pixelarraythirdparty-1.1.4}/pyproject.toml +1 -1
  6. {pixelarraythirdparty-1.1.3 → pixelarraythirdparty-1.1.4}/LICENSE +0 -0
  7. {pixelarraythirdparty-1.1.3 → pixelarraythirdparty-1.1.4}/MANIFEST.in +0 -0
  8. {pixelarraythirdparty-1.1.3 → pixelarraythirdparty-1.1.4}/pixelarraythirdparty/client.py +0 -0
  9. {pixelarraythirdparty-1.1.3 → pixelarraythirdparty-1.1.4}/pixelarraythirdparty/cron/__init__.py +0 -0
  10. {pixelarraythirdparty-1.1.3 → pixelarraythirdparty-1.1.4}/pixelarraythirdparty/cron/cron.py +0 -0
  11. {pixelarraythirdparty-1.1.3 → pixelarraythirdparty-1.1.4}/pixelarraythirdparty/order/__init__.py +0 -0
  12. {pixelarraythirdparty-1.1.3 → pixelarraythirdparty-1.1.4}/pixelarraythirdparty/order/order.py +0 -0
  13. {pixelarraythirdparty-1.1.3 → pixelarraythirdparty-1.1.4}/pixelarraythirdparty/product/__init__.py +0 -0
  14. {pixelarraythirdparty-1.1.3 → pixelarraythirdparty-1.1.4}/pixelarraythirdparty/product/product.py +0 -0
  15. {pixelarraythirdparty-1.1.3 → pixelarraythirdparty-1.1.4}/pixelarraythirdparty/unified_login/__init__.py +0 -0
  16. {pixelarraythirdparty-1.1.3 → pixelarraythirdparty-1.1.4}/pixelarraythirdparty/user/__init__.py +0 -0
  17. {pixelarraythirdparty-1.1.3 → pixelarraythirdparty-1.1.4}/pixelarraythirdparty/user/user.py +0 -0
  18. {pixelarraythirdparty-1.1.3 → pixelarraythirdparty-1.1.4}/pixelarraythirdparty.egg-info/SOURCES.txt +0 -0
  19. {pixelarraythirdparty-1.1.3 → pixelarraythirdparty-1.1.4}/pixelarraythirdparty.egg-info/dependency_links.txt +0 -0
  20. {pixelarraythirdparty-1.1.3 → pixelarraythirdparty-1.1.4}/pixelarraythirdparty.egg-info/requires.txt +0 -0
  21. {pixelarraythirdparty-1.1.3 → pixelarraythirdparty-1.1.4}/pixelarraythirdparty.egg-info/top_level.txt +0 -0
  22. {pixelarraythirdparty-1.1.3 → pixelarraythirdparty-1.1.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pixelarraythirdparty
3
- Version: 1.1.3
3
+ Version: 1.1.4
4
4
  Summary: PixelArray 第三方微服务客户端
5
5
  Author-email: Lu qi <qi.lu@pixelarrayai.com>
6
6
  License-Expression: MIT
@@ -11,7 +11,7 @@ PixelArray 第三方微服务客户端
11
11
  - unified_login: 统一登录模块
12
12
  """
13
13
 
14
- __version__ = "1.1.3"
14
+ __version__ = "1.1.4"
15
15
  __author__ = "Lu qi"
16
16
  __email__ = "qi.lu@pixelarrayai.com"
17
17
 
@@ -376,3 +376,86 @@ class DouyinLogin(AsyncClient):
376
376
  await asyncio.sleep(interval)
377
377
 
378
378
  return {}, False
379
+
380
+
381
+ class GitLabLogin(AsyncClient):
382
+ """
383
+ GitLab OAuth2 登录客户端
384
+
385
+ 使用示例:
386
+ ```
387
+ gitlab = GitLabLogin(api_key="your_api_key")
388
+ user_info, success = await gitlab.login()
389
+ ```
390
+ """
391
+
392
+ def __init__(self, api_key: str):
393
+ super().__init__(api_key)
394
+
395
+ async def _get_auth_url(self) -> Tuple[Optional[Dict[str, str]], bool]:
396
+ data, success = await self._request(
397
+ "POST", "/api/unified-login/gitlab/auth-url"
398
+ )
399
+ if not success:
400
+ return None, False
401
+ auth_url = data.get("auth_url")
402
+ if not auth_url:
403
+ return None, False
404
+ return data, True
405
+
406
+ async def login(self, timeout: int = 180) -> Tuple[Dict, bool]:
407
+ """
408
+ 仿 Supabase CLI 的一键登录流程:打开浏览器完成授权,
409
+ 终端端轮询等待登录结果
410
+
411
+ :param timeout: 等待用户完成授权的超时时间(秒)
412
+ """
413
+ auth_data, success = await self._get_auth_url()
414
+ if not success or not auth_data:
415
+ return {}, False
416
+
417
+ auth_url = auth_data.get("auth_url")
418
+ state = auth_data.get("state") or self._extract_state(auth_url)
419
+
420
+ if not auth_url or not state:
421
+ return {}, False
422
+
423
+ webbrowser.open(auth_url, new=2)
424
+
425
+ return await self._wait_for_gitlab_login(state, timeout)
426
+
427
+ def _extract_state(self, auth_url: Optional[str]) -> Optional[str]:
428
+ if not auth_url:
429
+ return None
430
+ try:
431
+ parsed = urllib.parse.urlparse(auth_url)
432
+ query = urllib.parse.parse_qs(parsed.query)
433
+ values = query.get("state")
434
+ if values:
435
+ return values[0]
436
+ except Exception:
437
+ return None
438
+ return None
439
+
440
+ async def _wait_for_gitlab_login(
441
+ self, state: str, timeout: int
442
+ ) -> Tuple[Dict, bool]:
443
+ interval = 2
444
+ total_checks = max(1, timeout // interval) if timeout > 0 else 1
445
+
446
+ for _ in range(total_checks):
447
+ status, response = await self._request_raw(
448
+ "POST",
449
+ "/api/unified-login/gitlab/wait-login",
450
+ json={"state": state},
451
+ )
452
+
453
+ if status == 200 and response.get("success") is True:
454
+ return response.get("data", {}), True
455
+
456
+ if status in (400, 408):
457
+ break
458
+
459
+ await asyncio.sleep(interval)
460
+
461
+ return {}, False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pixelarraythirdparty
3
- Version: 1.1.3
3
+ Version: 1.1.4
4
4
  Summary: PixelArray 第三方微服务客户端
5
5
  Author-email: Lu qi <qi.lu@pixelarrayai.com>
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pixelarraythirdparty"
7
- version = "1.1.3"
7
+ version = "1.1.4"
8
8
  authors = [
9
9
  {name = "Lu qi", email = "qi.lu@pixelarrayai.com"},
10
10
  ]