# Copyright (C) 2023-2024 Cochise Ruhulessin
#
# All rights reserved. No warranty, explicit or implicit, provided. In
# no event shall the author(s) be liable for any claim or damages.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
from typing import Annotated
from typing import TypeAlias

import pydantic

from canonical.lib.types import HTTPResourceLocator


AuthorizationCode: TypeAlias = Annotated[
    str | None,
    pydantic.Field(
        title="Authorization Code",
        description=(
            "The authorization code generated by the authorization "
            "server."
        )
    )
]

Issuer: TypeAlias = Annotated[
    HTTPResourceLocator | None,
    pydantic.Field(
        title="Issuer Identifier",
        description=(
            "The iss parameter value is the issuer identifier of the authorization "
            "server which created the authorization responsed. Its value **must** "
            "be a URL that uses the `https` scheme without any query or fragment "
            "components. If the authorization server provides metadata, the "
            "value of the parameter `iss` **must** be identical to the "
            "authorization server metadata value `issuer`."
        )
    )
]

State: TypeAlias = Annotated[
    str | None,
    pydantic.Field(
        title="State",
        description=(
            "An opaque value used by the client to maintain state between the "
            "request and callback.  The authorization server includes this "
            "value when redirecting the user-agent back to the client.  The "
            "parameter **should** be used for preventing cross-site request "
            "forgery"
        )
    )
]