@danhachuel/thunderbolt 0.5.2 → 0.5.3
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.
- package/app/main.py +1 -1
- package/hermes_ui/canva_auth.py +12 -3
- package/package.json +1 -1
package/app/main.py
CHANGED
|
@@ -7199,7 +7199,7 @@ def _render_media_provider_card(settings: dict[str, Any], cards: list[dict[str,
|
|
|
7199
7199
|
state = create_state()
|
|
7200
7200
|
st.session_state[f"canva_verifier_{card_id}"] = verifier
|
|
7201
7201
|
st.session_state[f"canva_state_{card_id}"] = state
|
|
7202
|
-
st.session_state[f"canva_authorization_url_{card_id}"] = authorization_url(client_id, redirect_uri,
|
|
7202
|
+
st.session_state[f"canva_authorization_url_{card_id}"] = authorization_url(client_id, redirect_uri, state=state, code_challenge=challenge)
|
|
7203
7203
|
authorization_link = str(st.session_state.get(f"canva_authorization_url_{card_id}") or "")
|
|
7204
7204
|
if authorization_link:
|
|
7205
7205
|
st.markdown(f"[Abrir autorização Canva]({authorization_link})")
|
package/hermes_ui/canva_auth.py
CHANGED
|
@@ -13,6 +13,13 @@ AUTHORIZE_URL = "https://www.canva.com/api/oauth/authorize"
|
|
|
13
13
|
TOKEN_URL = "https://api.canva.com/rest/v1/oauth/token"
|
|
14
14
|
_PKCE_MIN_LENGTH = 43
|
|
15
15
|
_PKCE_MAX_LENGTH = 128
|
|
16
|
+
CANVA_OAUTH_SCOPES = (
|
|
17
|
+
"asset:read",
|
|
18
|
+
"asset:write",
|
|
19
|
+
"design:meta:read",
|
|
20
|
+
"design:content:read",
|
|
21
|
+
"design:content:write",
|
|
22
|
+
)
|
|
16
23
|
|
|
17
24
|
|
|
18
25
|
def _b64(value: bytes) -> str:
|
|
@@ -47,13 +54,15 @@ def create_state() -> str:
|
|
|
47
54
|
return _b64(secrets.token_bytes(48))
|
|
48
55
|
|
|
49
56
|
|
|
50
|
-
def authorization_url(client_id: str, redirect_uri: str, scope: str, state: str, code_challenge: str) -> str:
|
|
57
|
+
def authorization_url(client_id: str, redirect_uri: str, scope: str | list[str] | tuple[str, ...] | None = None, state: str = "", code_challenge: str = "") -> str:
|
|
51
58
|
if not code_challenge or code_challenge == "<CODE_CHALLENGE>":
|
|
52
59
|
raise ValueError("Não é permitido iniciar Canva com code_challenge placeholder.")
|
|
60
|
+
scope_value = CANVA_OAUTH_SCOPES if scope is None else scope
|
|
61
|
+
scope_string = " ".join(scope_value) if isinstance(scope_value, (list, tuple)) else " ".join(str(scope_value or "").split())
|
|
53
62
|
params = {
|
|
54
63
|
"code_challenge": code_challenge,
|
|
55
|
-
"code_challenge_method": "
|
|
56
|
-
"scope":
|
|
64
|
+
"code_challenge_method": "s256",
|
|
65
|
+
"scope": scope_string,
|
|
57
66
|
"response_type": "code",
|
|
58
67
|
"client_id": str(client_id).strip(),
|
|
59
68
|
"state": str(state).strip(),
|
package/package.json
CHANGED