hyperpocket 0.3.6__py3-none-any.whl → 0.3.7__py3-none-any.whl
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.
- hyperpocket/auth/provider.py +1 -0
- hyperpocket/auth/zinc/__init__.py +0 -0
- hyperpocket/auth/zinc/context.py +12 -0
- hyperpocket/auth/zinc/token_context.py +11 -0
- hyperpocket/auth/zinc/token_handler.py +64 -0
- hyperpocket/auth/zinc/token_schema.py +7 -0
- hyperpocket/server/auth/zinc.py +27 -0
- {hyperpocket-0.3.6.dist-info → hyperpocket-0.3.7.dist-info}/METADATA +1 -1
- {hyperpocket-0.3.6.dist-info → hyperpocket-0.3.7.dist-info}/RECORD +11 -5
- {hyperpocket-0.3.6.dist-info → hyperpocket-0.3.7.dist-info}/WHEEL +0 -0
- {hyperpocket-0.3.6.dist-info → hyperpocket-0.3.7.dist-info}/entry_points.txt +0 -0
hyperpocket/auth/provider.py
CHANGED
File without changes
|
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
from hyperpocket.auth.context import AuthContext
|
3
|
+
class ZincAuthContext(AuthContext):
|
4
|
+
_ACCESS_TOKEN_KEY: str = "ZINC_TOKEN"
|
5
|
+
def to_dict(self) -> dict[str, str]:
|
6
|
+
return {
|
7
|
+
self._ACCESS_TOKEN_KEY: self.access_token,
|
8
|
+
}
|
9
|
+
def to_profiled_dict(self, profile: str) -> dict[str, str]:
|
10
|
+
return {
|
11
|
+
f"{profile.upper()}_{self._ACCESS_TOKEN_KEY}": self.access_token,
|
12
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
from hyperpocket.auth.zinc.context import ZincAuthContext
|
2
|
+
from hyperpocket.auth.zinc.token_schema import ZincTokenResponse
|
3
|
+
class ZincTokenAuthContext(ZincAuthContext):
|
4
|
+
@classmethod
|
5
|
+
def from_zinc_token_response(cls, response: ZincTokenResponse):
|
6
|
+
description = f'Zinc Token Context logged in'
|
7
|
+
return cls(
|
8
|
+
access_token=response.access_token,
|
9
|
+
description=description,
|
10
|
+
expires_at=None
|
11
|
+
)
|
@@ -0,0 +1,64 @@
|
|
1
|
+
from typing import Optional
|
2
|
+
from urllib.parse import urljoin, urlencode
|
3
|
+
|
4
|
+
from hyperpocket.auth import AuthProvider
|
5
|
+
from hyperpocket.auth.context import AuthContext
|
6
|
+
from hyperpocket.auth.handler import AuthHandlerInterface, AuthenticateRequest
|
7
|
+
from hyperpocket.auth.zinc.token_context import ZincTokenAuthContext
|
8
|
+
from hyperpocket.auth.zinc.token_schema import ZincTokenResponse, ZincTokenRequest
|
9
|
+
from hyperpocket.config import config
|
10
|
+
from hyperpocket.futures import FutureStore
|
11
|
+
|
12
|
+
|
13
|
+
class ZincTokenAuthHandler(AuthHandlerInterface):
|
14
|
+
name: str = "zinc-token"
|
15
|
+
description: str = "This handler is used to authenticate users using the Zinc token."
|
16
|
+
scoped: bool = False
|
17
|
+
|
18
|
+
_TOKEN_URL: str = urljoin(config().public_base_url + "/", f"{config().callback_url_rewrite_prefix}/auth/token")
|
19
|
+
|
20
|
+
@staticmethod
|
21
|
+
def provider() -> AuthProvider:
|
22
|
+
return AuthProvider.ZINC
|
23
|
+
|
24
|
+
@staticmethod
|
25
|
+
def recommended_scopes() -> set[str]:
|
26
|
+
return set()
|
27
|
+
|
28
|
+
def prepare(self, auth_req: ZincTokenRequest, thread_id: str, profile: str,
|
29
|
+
future_uid: str, *args, **kwargs) -> str:
|
30
|
+
redirect_uri = urljoin(
|
31
|
+
config().public_base_url + "/",
|
32
|
+
f"{config().callback_url_rewrite_prefix}/auth/zinc/token/callback",
|
33
|
+
)
|
34
|
+
url = self._make_auth_url(auth_req=auth_req, redirect_uri=redirect_uri, state=future_uid)
|
35
|
+
FutureStore.create_future(future_uid, data={
|
36
|
+
"redirect_uri": redirect_uri,
|
37
|
+
"thread_id": thread_id,
|
38
|
+
"profile": profile,
|
39
|
+
})
|
40
|
+
|
41
|
+
return f'User needs to authenticate using the following URL: {url}'
|
42
|
+
|
43
|
+
async def authenticate(self, auth_req: ZincTokenRequest, future_uid: str, *args, **kwargs) -> AuthContext:
|
44
|
+
future_data = FutureStore.get_future(future_uid)
|
45
|
+
access_token = await future_data.future
|
46
|
+
|
47
|
+
response = ZincTokenResponse(access_token=access_token)
|
48
|
+
context = ZincTokenAuthContext.from_zinc_token_response(response)
|
49
|
+
|
50
|
+
return context
|
51
|
+
|
52
|
+
async def refresh(self, auth_req: ZincTokenRequest, context: AuthContext, *args, **kwargs) -> AuthContext:
|
53
|
+
raise Exception("Zinc token doesn't support refresh")
|
54
|
+
|
55
|
+
def _make_auth_url(self, auth_req: ZincTokenRequest, redirect_uri: str, state: str):
|
56
|
+
params = {
|
57
|
+
"redirect_uri": redirect_uri,
|
58
|
+
"state": state,
|
59
|
+
}
|
60
|
+
auth_url = f"{self._TOKEN_URL}?{urlencode(params)}"
|
61
|
+
return auth_url
|
62
|
+
|
63
|
+
def make_request(self, auth_scopes: Optional[list[str]] = None, **kwargs) -> ZincTokenRequest:
|
64
|
+
return ZincTokenRequest()
|
@@ -0,0 +1,7 @@
|
|
1
|
+
from typing import List, Optional
|
2
|
+
from pydantic import BaseModel
|
3
|
+
from hyperpocket.auth.schema import AuthenticateRequest, AuthenticateResponse
|
4
|
+
class ZincTokenRequest(AuthenticateRequest):
|
5
|
+
pass
|
6
|
+
class ZincTokenResponse(AuthenticateResponse):
|
7
|
+
access_token: str
|
@@ -0,0 +1,27 @@
|
|
1
|
+
from fastapi import APIRouter
|
2
|
+
from starlette.responses import HTMLResponse
|
3
|
+
from hyperpocket.futures import FutureStore
|
4
|
+
|
5
|
+
zinc_auth_router = APIRouter(
|
6
|
+
prefix="/zinc"
|
7
|
+
)
|
8
|
+
|
9
|
+
|
10
|
+
@zinc_auth_router.get("/oauth2/callback")
|
11
|
+
async def zinc_oauth2_callback(state: str, code: str):
|
12
|
+
try:
|
13
|
+
FutureStore.resolve_future(state, code)
|
14
|
+
except ValueError:
|
15
|
+
return HTMLResponse(content="failed")
|
16
|
+
|
17
|
+
return HTMLResponse(content="success")
|
18
|
+
|
19
|
+
|
20
|
+
@zinc_auth_router.get("/token/callback")
|
21
|
+
async def zinc_token_callback(state: str, token: str):
|
22
|
+
try:
|
23
|
+
FutureStore.resolve_future(state, token)
|
24
|
+
except ValueError:
|
25
|
+
return HTMLResponse(content="failed")
|
26
|
+
|
27
|
+
return HTMLResponse(content="success")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: hyperpocket
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.7
|
4
4
|
Summary: Building AI agent with hyperpocket tool in a flash
|
5
5
|
Project-URL: Homepage, https://vessl-ai.github.io/hyperpocket
|
6
6
|
Project-URL: Repository, https://github.com/vessl-ai/hyperpocket
|
@@ -10,7 +10,7 @@ hyperpocket/auth/README.md,sha256=zn4QqnFZCA_4X3x8Wb6lE3OP5otYxpByZaCiUkBvaNs,11
|
|
10
10
|
hyperpocket/auth/__init__.py,sha256=pO8M6SAuq0EPqi848_Iy650wqaLekx98e3RRnEAM_r0,607
|
11
11
|
hyperpocket/auth/context.py,sha256=m-j2gDYUKBMsiakLHsu9thhM4dYyFiXP0Wp0S_iC0bU,1303
|
12
12
|
hyperpocket/auth/handler.py,sha256=5cusl9ANEyG3gORVFjqh709txC0alw6eKtxgV6wjf6k,6683
|
13
|
-
hyperpocket/auth/provider.py,sha256=
|
13
|
+
hyperpocket/auth/provider.py,sha256=bTJn6Atm4E9nm9vf8Ggudf7-XxAWMOIPo6xiZnGqDvM,2035
|
14
14
|
hyperpocket/auth/schema.py,sha256=pl4oRTNj8PdqQg6UVPWf8ei2uYQ4DtOmmD58cVFMYQw,537
|
15
15
|
hyperpocket/auth/activeloop/README.md,sha256=xp8n0itbY9VNt8XEvCAE4Ealvj4uf_f1uSZyWG4Q5FE,172
|
16
16
|
hyperpocket/auth/activeloop/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -440,6 +440,11 @@ hyperpocket/auth/x/context.py,sha256=5Ur9GI8og49E-8FToKlqR3TtPn6vWAdu1boLqYxJL8k
|
|
440
440
|
hyperpocket/auth/x/oauth2_context.py,sha256=q2HB14WENz2LU7Qe7KkE7-AtsEOtzXIj7n8alykac8M,955
|
441
441
|
hyperpocket/auth/x/oauth2_handler.py,sha256=kEnsbL1YIeIQUlMVPIZYqOswk9_t-sNGiaixj43M1Yc,5634
|
442
442
|
hyperpocket/auth/x/oauth2_schema.py,sha256=PKeaHccpxGLJjEd8RxP2wVcrIPCE-W9HEtP8EMzU4To,401
|
443
|
+
hyperpocket/auth/zinc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
444
|
+
hyperpocket/auth/zinc/context.py,sha256=nsjUnNcOVUB2C3tjN2jT94dWPI9wRagtpyrV452pieY,419
|
445
|
+
hyperpocket/auth/zinc/token_context.py,sha256=CG0aVRO-xEIk39zHLu2-IF46VMrKnKlxg4mqTtv2H-s,449
|
446
|
+
hyperpocket/auth/zinc/token_handler.py,sha256=S0if3Zb8TFRP52XwHpanm_AbthkojLmsnKaeJU8RyxA,2574
|
447
|
+
hyperpocket/auth/zinc/token_schema.py,sha256=18C50Wnr9Vq-YJBS4qzjUotoEJy5zLWqFKK2G7nmcMg,265
|
443
448
|
hyperpocket/auth/zoom/README.md,sha256=xzfcoAiWyFxUdHfOgnXwMXygt_RkaAsaZuCH3ylTcVQ,401
|
444
449
|
hyperpocket/auth/zoom/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
445
450
|
hyperpocket/auth/zoom/context.py,sha256=26S_aMbvtdzXYoXdDNpnHGJ-tmMcOSt0F15cMYwQZaM,423
|
@@ -552,6 +557,7 @@ hyperpocket/server/auth/trello.py,sha256=1T3ez62h8-KMvu2Zj1Tyv2afgqLUbtG2LM4QbIS
|
|
552
557
|
hyperpocket/server/auth/wandb.py,sha256=jfwg-lQVrr5TgEL7QETnaFucDvi057SJvVZlBe7cOqQ,709
|
553
558
|
hyperpocket/server/auth/workiom.py,sha256=0apFB5-3rmcJaQeEl1_XZ_QlsZORdq8kixJBGkTpZ3Y,445
|
554
559
|
hyperpocket/server/auth/x.py,sha256=CYCD_ajBY6Jt04E2bSEBZFRRIUZmNjF2gn6F0ZV5XuA,450
|
560
|
+
hyperpocket/server/auth/zinc.py,sha256=xgVV5lWP6YSEHTCmH0gipG5lh4Wvf716tHTnOvTTj3w,708
|
555
561
|
hyperpocket/server/auth/zoom.py,sha256=kWp4MB4i9FKMA4ZYcj4g4_90Y1ZMEoAQTTjbb0rsMRs,703
|
556
562
|
hyperpocket/server/tool/__init__.py,sha256=khNLe3H2W7WXKQlHjXuuvd9R87eHOAZhDsQmjDcbYsg,210
|
557
563
|
hyperpocket/server/tool/wasm.py,sha256=VJyp6RGsq8llKT_sY6DhV52wsETu-W9bzJ7C9wC17Oo,1698
|
@@ -587,7 +593,7 @@ hyperpocket/util/flatten_json_schema.py,sha256=iuNBEmMSKFtPi-uqo6fb3RWN0koHOAihW
|
|
587
593
|
hyperpocket/util/function_to_model.py,sha256=TXUs-qPbzL8C9-qqpz4Ad4D9MOPP61n_p0iPU6SoBeM,2318
|
588
594
|
hyperpocket/util/get_objects_from_subpackage.py,sha256=4mR_S8eaJSdU68YfCkiXeIcXxb6q7LjFGsY_IHeNIZw,929
|
589
595
|
hyperpocket/util/json_schema_to_model.py,sha256=PqI87pU5dWwcrQWB8eQxRdfgAEvvC1x_DKZnhcsRV-o,3586
|
590
|
-
hyperpocket-0.3.
|
591
|
-
hyperpocket-0.3.
|
592
|
-
hyperpocket-0.3.
|
593
|
-
hyperpocket-0.3.
|
596
|
+
hyperpocket-0.3.7.dist-info/METADATA,sha256=oZuYOmr2Tx0PdrjFsKiptOTJP5eUffygor8VdhNITOU,12958
|
597
|
+
hyperpocket-0.3.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
598
|
+
hyperpocket-0.3.7.dist-info/entry_points.txt,sha256=KpBleaYr0SaENXOa-dFvJ_cvFCHYFEQ4LMl11ShAcBI,61
|
599
|
+
hyperpocket-0.3.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|