Skip to content
This repository was archived by the owner on Jun 12, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/belgie-alchemy/src/belgie_alchemy/core/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from uuid import UUID

from belgie_proto.core.account import AccountType
from belgie_proto.core.json import JSONValue # noqa: TC002 - SQLAlchemy evaluates Mapped annotations at runtime.
from belgie_proto.core.oauth_state import OAuthFlowIntent # noqa: TC002 - SQLAlchemy evaluates Mapped annotations.
from brussels.types import DateTimeUTC
from sqlalchemy import JSON, Enum, ForeignKey, Index, Text, UniqueConstraint
from sqlalchemy.dialects.postgresql import ARRAY, CITEXT
Expand Down Expand Up @@ -247,7 +249,7 @@ def nonce(self) -> Mapped[str | None]:
return mapped_column(Text, default=None, kw_only=True)

@declared_attr
def intent(self) -> Mapped[str]:
def intent(self) -> Mapped[OAuthFlowIntent]:
return mapped_column(Text, default="signin", nullable=False, kw_only=True)

@declared_attr
Expand All @@ -263,7 +265,7 @@ def new_user_redirect_url(self) -> Mapped[str | None]:
return mapped_column(Text, default=None, kw_only=True)

@declared_attr
def payload(self) -> Mapped[dict[str, object] | list[object] | str | int | float | bool | None]:
def payload(self) -> Mapped[JSONValue]:
return mapped_column(JSON, default=None, kw_only=True)

@declared_attr
Expand Down
2 changes: 1 addition & 1 deletion packages/belgie-oauth/src/belgie_oauth/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import TYPE_CHECKING, Literal, Protocol, TypedDict, runtime_checkable

from belgie_proto.core.json import JSONObject, JSONScalar, JSONValue
from belgie_proto.core.oauth_state import OAuthFlowIntent

if TYPE_CHECKING:
from datetime import datetime
Expand All @@ -19,7 +20,6 @@
from belgie_oauth._transport import AuthlibOIDCClient


type OAuthFlowIntent = Literal["signin", "link"]
type OAuthResponseMode = Literal["query", "form_post"]
type OAuthSameSite = Literal["lax", "strict", "none"]
type OAuthStateStrategy = Literal["adapter", "cookie"]
Expand Down
3 changes: 2 additions & 1 deletion packages/belgie-proto/src/belgie_proto/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from belgie_proto.core.individual import IndividualProtocol
from belgie_proto.core.json import JSONObject, JSONScalar, JSONValue
from belgie_proto.core.oauth_account import OAuthAccountProtocol
from belgie_proto.core.oauth_state import OAuthStateProtocol
from belgie_proto.core.oauth_state import OAuthFlowIntent, OAuthStateProtocol
from belgie_proto.core.session import SessionProtocol

__all__ = [
Expand All @@ -18,6 +18,7 @@
"JSONScalar",
"JSONValue",
"OAuthAccountProtocol",
"OAuthFlowIntent",
"OAuthStateProtocol",
"SessionProtocol",
]
5 changes: 2 additions & 3 deletions packages/belgie-proto/src/belgie_proto/core/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
from belgie_proto.core.account import AccountAdapterProtocol, AccountProtocol
from belgie_proto.core.individual import IndividualProtocol
from belgie_proto.core.oauth_account import OAuthAccountProtocol
from belgie_proto.core.oauth_state import OAuthStateProtocol
from belgie_proto.core.oauth_state import OAuthFlowIntent, OAuthStateProtocol
from belgie_proto.core.session import SessionProtocol

if TYPE_CHECKING:
from datetime import datetime
from typing import Any, Literal
from uuid import UUID

from belgie_proto.core.connection import DBConnection
Expand Down Expand Up @@ -147,7 +146,7 @@ async def create_oauth_state( # noqa: PLR0913
provider: str | None = None,
code_verifier: str | None = None,
nonce: str | None = None,
intent: Literal["signin", "link"] = "signin",
intent: OAuthFlowIntent = "signin",
redirect_url: str | None = None,
error_redirect_url: str | None = None,
new_user_redirect_url: str | None = None,
Expand Down
13 changes: 10 additions & 3 deletions packages/belgie-proto/src/belgie_proto/core/oauth_state.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Protocol, runtime_checkable
from typing import TYPE_CHECKING, Literal, Protocol, runtime_checkable

type OAuthFlowIntent = Literal["signin", "link"]

if TYPE_CHECKING:
from datetime import datetime
from typing import Literal
from uuid import UUID

from belgie_proto.core.json import JSONValue
Expand All @@ -18,11 +19,17 @@ class OAuthStateProtocol(Protocol):
individual_id: UUID | None
code_verifier: str | None
nonce: str | None
intent: Literal["signin", "link"]
intent: OAuthFlowIntent
redirect_url: str | None
error_redirect_url: str | None
new_user_redirect_url: str | None
payload: JSONValue
request_sign_up: bool
created_at: datetime
expires_at: datetime


__all__ = [
"OAuthFlowIntent",
"OAuthStateProtocol",
]