Module supertokens_python.recipe.passwordless.interfaces

Expand source code
# Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.
#
# This software is licensed under the Apache License, Version 2.0 (the
# "License") as published by the Apache Software Foundation.
#
# You may not use this file except in compliance with the License. You may
# obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# 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. See the
# License for the specific language governing permissions and limitations
# under the License.
from abc import ABC, abstractmethod
from typing import Any, Dict, List, Union

from supertokens_python.framework import BaseRequest, BaseResponse
from supertokens_python.recipe.session import SessionContainer
from typing_extensions import Literal

from .types import DeviceType, User
from .utils import PasswordlessConfig


class CreateCodeResult(ABC):
    def __init__(
            self,
            status: Literal['OK'],
            pre_auth_session_id: str,
            code_id: str,
            device_id: str,
            user_input_code: str,
            link_code: str,
            code_life_time: int,
            time_created: int
    ):
        self.status = status
        self.pre_auth_session_id = pre_auth_session_id
        self.code_id = code_id
        self.device_id = device_id
        self.user_input_code = user_input_code
        self.link_code = link_code
        self.code_life_time = code_life_time
        self.time_created = time_created


class CreateCodeOkResult(CreateCodeResult):
    def __init__(self, pre_auth_session_id: str, code_id: str, device_id: str,
                 user_input_code: str, link_code: str, code_life_time: int, time_created: int):
        super().__init__('OK', pre_auth_session_id, code_id, device_id, user_input_code, link_code, code_life_time,
                         time_created)


class CreateNewCodeForDeviceResult(ABC):
    def __init__(self,
                 status: Literal['OK', 'RESTART_FLOW_ERROR', 'USER_INPUT_CODE_ALREADY_USED_ERROR'],
                 pre_auth_session_id: Union[str, None] = None,
                 code_id: Union[str, None] = None,
                 device_id: Union[str, None] = None,
                 user_input_code: Union[str, None] = None,
                 link_code: Union[str, None] = None,
                 code_life_time: Union[int, None] = None,
                 time_created: Union[int, None] = None
                 ):
        self.status = status
        self.pre_auth_session_id = pre_auth_session_id
        self.code_id = code_id
        self.device_id = device_id
        self.user_input_code = user_input_code
        self.link_code = link_code
        self.code_life_time = code_life_time
        self.time_created = time_created
        self.is_ok = False
        self.is_restart_flow_error = False
        self.is_user_input_code_already_used_error = False


class CreateNewCodeForDeviceOkResult(CreateNewCodeForDeviceResult):
    def __init__(self,
                 pre_auth_session_id: str,
                 code_id: str,
                 device_id: str,
                 user_input_code: str,
                 link_code: str,
                 code_life_time: int,
                 time_created: int
                 ):
        super().__init__(
            'OK',
            pre_auth_session_id,
            code_id,
            device_id,
            user_input_code,
            link_code,
            code_life_time,
            time_created
        )
        self.is_ok = True


class CreateNewCodeForDeviceRestartFlowErrorResult(
        CreateNewCodeForDeviceResult):
    def __init__(self):
        super().__init__('RESTART_FLOW_ERROR')
        self.is_restart_flow_error = True


class CreateNewCodeForDeviceUserInputCodeAlreadyUsedErrorResult(
        CreateNewCodeForDeviceResult):
    def __init__(self):
        super().__init__('USER_INPUT_CODE_ALREADY_USED_ERROR')
        self.is_user_input_code_already_used_error = True


class ConsumeCodeResult(ABC):
    def __init__(self,
                 status: Literal['OK',
                                 'INCORRECT_USER_INPUT_CODE_ERROR',
                                 'EXPIRED_USER_INPUT_CODE_ERROR',
                                 'RESTART_FLOW_ERROR'],
                 created_new_user: Union[bool, None] = None,
                 user: Union[User, None] = None,
                 failed_code_input_attempt_count: Union[int, None] = None,
                 maximum_code_input_attempts: Union[int, None] = None
                 ):
        self.status: Literal['OK',
                             'INCORRECT_USER_INPUT_CODE_ERROR',
                             'EXPIRED_USER_INPUT_CODE_ERROR',
                             'RESTART_FLOW_ERROR'] = status
        self.created_new_user: Union[bool, None] = created_new_user
        self.user: Union[User, None] = user
        self.failed_code_input_attempt_count: Union[int, None] = failed_code_input_attempt_count
        self.maximum_code_input_attempts: Union[int, None] = maximum_code_input_attempts
        self.is_ok: bool = False
        self.is_incorrect_user_input_code_error: bool = False
        self.is_expired_user_input_code_error: bool = False
        self.is_restart_flow_error: bool = False


class ConsumeCodeOkResult(ConsumeCodeResult):
    def __init__(self, created_new_user: bool, user: User):
        super().__init__('OK', created_new_user=created_new_user, user=user)
        self.is_ok = True


class ConsumeCodeIncorrectUserInputCodeErrorResult(ConsumeCodeResult):
    def __init__(self, failed_code_input_attempt_count: int,
                 maximum_code_input_attempts: int):
        super().__init__('INCORRECT_USER_INPUT_CODE_ERROR',
                         failed_code_input_attempt_count=failed_code_input_attempt_count,
                         maximum_code_input_attempts=maximum_code_input_attempts)
        self.is_incorrect_user_input_code_error = True


class ConsumeCodeExpiredUserInputCodeErrorResult(ConsumeCodeResult):
    def __init__(self, failed_code_input_attempt_count: int,
                 maximum_code_input_attempts: int):
        super().__init__('EXPIRED_USER_INPUT_CODE_ERROR',
                         failed_code_input_attempt_count=failed_code_input_attempt_count,
                         maximum_code_input_attempts=maximum_code_input_attempts)
        self.is_expired_user_input_code_error = True


class ConsumeCodeRestartFlowErrorResult(ConsumeCodeResult):
    def __init__(self):
        super().__init__('RESTART_FLOW_ERROR')
        self.is_restart_flow_error = True


class UpdateUserResult(ABC):
    def __init__(self, status: Literal['OK', 'UNKNOWN_USER_ID_ERROR',
                 'EMAIL_ALREADY_EXISTS_ERROR', 'PHONE_NUMBER_ALREADY_EXISTS_ERROR']):
        self.status = status


class DeleteUserInfoResult(ABC):
    def __init__(self, status: Literal['OK', 'UNKNOWN_USER_ID_ERROR']):
        self.status = status
        self.is_ok = False
        self.is_unknown_user_id_error = False


class DeleteUserInfoOkResult(DeleteUserInfoResult):
    def __init__(self):
        super().__init__('OK')
        self.is_ok = True


class DeleteUserInfoUnknownUserIdErrorResult(DeleteUserInfoResult):
    def __init__(self):
        super().__init__('UNKNOWN_USER_ID_ERROR')
        self.is_unknown_user_id_error = True


class UpdateUserOkResult(UpdateUserResult):
    def __init__(self):
        super().__init__('OK')


class UpdateUserUnknownUserIdErrorResult(UpdateUserResult):
    def __init__(self):
        super().__init__('UNKNOWN_USER_ID_ERROR')


class UpdateUserEmailAlreadyExistsErrorResult(UpdateUserResult):
    def __init__(self):
        super().__init__('EMAIL_ALREADY_EXISTS_ERROR')


class UpdateUserPhoneNumberAlreadyExistsErrorResult(UpdateUserResult):
    def __init__(self):
        super().__init__('PHONE_NUMBER_ALREADY_EXISTS_ERROR')


class RevokeAllCodesResult(ABC):
    def __init__(self, status: Literal['OK']):
        self.status = status


class RevokeAllCodesOkResult(RevokeAllCodesResult):
    def __init__(self):
        super().__init__('OK')


class RevokeCodeResult(ABC):
    def __init__(self, status: Literal['OK']):
        self.status = status


class RevokeCodeOkResult(RevokeCodeResult):
    def __init__(self):
        super().__init__('OK')


class RecipeInterface(ABC):
    def __init__(self):
        pass

    @abstractmethod
    async def create_code(self,
                          email: Union[None, str],
                          phone_number: Union[None, str],
                          user_input_code: Union[None, str],
                          user_context: Dict[str, Any]) -> CreateCodeResult:
        pass

    @abstractmethod
    async def create_new_code_for_device(self,
                                         device_id: str,
                                         user_input_code: Union[str, None],
                                         user_context: Dict[str, Any]) -> CreateNewCodeForDeviceResult:
        pass

    @abstractmethod
    async def consume_code(self,
                           pre_auth_session_id: str,
                           user_input_code: Union[str, None],
                           device_id: Union[str, None],
                           link_code: Union[str, None],
                           user_context: Dict[str, Any]) -> ConsumeCodeResult:
        pass

    @abstractmethod
    async def get_user_by_id(self, user_id: str, user_context: Dict[str, Any]) -> Union[User, None]:
        pass

    @abstractmethod
    async def get_user_by_email(self, email: str, user_context: Dict[str, Any]) -> Union[User, None]:
        pass

    @abstractmethod
    async def get_user_by_phone_number(self, phone_number: str, user_context: Dict[str, Any]) -> Union[User, None]:
        pass

    @abstractmethod
    async def update_user(self, user_id: str,
                          email: Union[str, None], phone_number: Union[str, None], user_context: Dict[str, Any]) -> UpdateUserResult:
        pass

    @abstractmethod
    async def delete_email_for_user(self, user_id: str, user_context: Dict[str, Any]) -> DeleteUserInfoResult:
        pass

    @abstractmethod
    async def delete_phone_number_for_user(self, user_id: str, user_context: Dict[str, Any]) -> DeleteUserInfoResult:
        pass

    @abstractmethod
    async def revoke_all_codes(self,
                               email: Union[str, None], phone_number: Union[str, None], user_context: Dict[str, Any]) -> RevokeAllCodesResult:
        pass

    @abstractmethod
    async def revoke_code(self, code_id: str, user_context: Dict[str, Any]) -> RevokeCodeResult:
        pass

    @abstractmethod
    async def list_codes_by_email(self, email: str, user_context: Dict[str, Any]) -> List[DeviceType]:
        pass

    @abstractmethod
    async def list_codes_by_phone_number(self, phone_number: str, user_context: Dict[str, Any]) -> List[DeviceType]:
        pass

    @abstractmethod
    async def list_codes_by_device_id(self, device_id: str, user_context: Dict[str, Any]) -> Union[DeviceType, None]:
        pass

    @abstractmethod
    async def list_codes_by_pre_auth_session_id(self, pre_auth_session_id: str,
                                                user_context: Dict[str, Any]) -> Union[DeviceType, None]:
        pass


class APIOptions:
    def __init__(self, request: BaseRequest, response: BaseResponse, recipe_id: str,
                 config: PasswordlessConfig, recipe_implementation: RecipeInterface):
        self.request = request
        self.response = response
        self.recipe_id = recipe_id
        self.config = config
        self.recipe_implementation = recipe_implementation


class CreateCodePostResponse(ABC):
    def __init__(
        self,
        status: Literal['OK', 'GENERAL_ERROR'],
        device_id: Union[str, None] = None,
        pre_auth_session_id: Union[str, None] = None,
        flow_type: Union[None, Literal['USER_INPUT_CODE', 'MAGIC_LINK',
                                       'USER_INPUT_CODE_AND_MAGIC_LINK']] = None,
        message: Union[str, None] = None
    ):
        self.status = status
        self.device_id = device_id
        self.pre_auth_session_id = pre_auth_session_id
        self.flow_type = flow_type
        self.message = message
        self.is_ok = False
        self.is_general_error = False

    @abstractmethod
    def to_json(self) -> Dict[str, Any]:
        pass


class CreateCodePostOkResponse(CreateCodePostResponse):
    def __init__(
            self,
            device_id: str,
            pre_auth_session_id: str,
            flow_type: Literal['USER_INPUT_CODE', 'MAGIC_LINK', 'USER_INPUT_CODE_AND_MAGIC_LINK']):
        super().__init__(
            status='OK',
            device_id=device_id,
            pre_auth_session_id=pre_auth_session_id,
            flow_type=flow_type
        )
        self.is_ok = True

    def to_json(self):
        return {
            'status': self.status,
            'deviceId': self.device_id,
            'preAuthSessionId': self.pre_auth_session_id,
            'flowType': self.flow_type
        }


class CreateCodePostGeneralErrorResponse(CreateCodePostResponse):
    def __init__(
            self,
            message: str):
        super().__init__(
            status='GENERAL_ERROR',
            message=message
        )
        self.is_general_error = True

    def to_json(self):
        return {
            'status': self.status,
            'message': self.message
        }


class ResendCodePostResponse(ABC):
    def __init__(
        self,
        status: Literal['OK', 'GENERAL_ERROR', 'RESTART_FLOW_ERROR'],
        message: Union[str, None] = None
    ):
        self.status = status
        self.message = message
        self.is_ok = False
        self.is_general_error = False
        self.is_restart_flow_error = False

    @abstractmethod
    def to_json(self) -> Dict[str, Any]:
        pass


class ResendCodePostOkResponse(ResendCodePostResponse):
    def __init__(self):
        super().__init__(status='OK')
        self.is_ok = True

    def to_json(self):
        return {
            'status': self.status
        }


class ResendCodePostRestartFlowErrorResponse(ResendCodePostResponse):
    def __init__(self):
        super().__init__(
            status='RESTART_FLOW_ERROR'
        )
        self.is_restart_flow_error = True

    def to_json(self):
        return {
            'status': self.status
        }


class ResendCodePostGeneralErrorResponse(ResendCodePostResponse):
    def __init__(self, message: str):
        super().__init__(status='GENERAL_ERROR', message=message)
        self.is_general_error = True

    def to_json(self):
        return {
            'status': self.status,
            'message': self.message
        }


class ConsumeCodePostResponse(ABC):
    def __init__(
        self,
        status: Literal[
            'OK',
            'GENERAL_ERROR',
            'RESTART_FLOW_ERROR',
            'INCORRECT_USER_INPUT_CODE_ERROR',
            'EXPIRED_USER_INPUT_CODE_ERROR'
        ],
        created_new_user: Union[bool, None] = None,
        user: Union[User, None] = None,
        session: Union[SessionContainer, None] = None,
        message: Union[str, None] = None,
        failed_code_input_attempt_count: Union[int, None] = None,
        maximum_code_input_attempts: Union[int, None] = None
    ):
        self.status: Literal[
            'OK',
            'GENERAL_ERROR',
            'RESTART_FLOW_ERROR',
            'INCORRECT_USER_INPUT_CODE_ERROR',
            'EXPIRED_USER_INPUT_CODE_ERROR'
        ] = status
        self.session: Union[SessionContainer, None] = session
        self.created_new_user: Union[bool, None] = created_new_user
        self.user: Union[User, None] = user
        self.failed_code_input_attempt_count: Union[int, None] = failed_code_input_attempt_count
        self.maximum_code_input_attempts: Union[int, None] = maximum_code_input_attempts
        self.message: Union[str, None] = message
        self.is_ok: bool = False
        self.is_general_error: bool = False
        self.is_restart_flow_error: bool = False
        self.is_incorrect_user_input_code_error: bool = False
        self.is_expired_user_input_code_error: bool = False

    @abstractmethod
    def to_json(self) -> Dict[str, Any]:
        pass


class ConsumeCodePostOkResponse(ConsumeCodePostResponse):
    def __init__(self, created_new_user: bool, user: User, session: SessionContainer):
        super().__init__(
            status='OK',
            created_new_user=created_new_user,
            user=user,
            session=session)
        self.is_ok = True

    def to_json(self):
        if self.user is None:
            raise Exception("Should never come here")
        user = {
            'id': self.user.user_id,
            'time_joined': self.user.time_joined
        }
        if self.user.email is not None:
            user = {
                **user,
                'email': self.user.email
            }
        if self.user.phone_number is not None:
            user = {
                **user,
                'phoneNumber': self.user.phone_number
            }
        return {
            'status': self.status,
            'createdNewUser': self.created_new_user,
            'user': user
        }


class ConsumeCodePostRestartFlowErrorResponse(ConsumeCodePostResponse):
    def __init__(self):
        super().__init__(
            status='RESTART_FLOW_ERROR'
        )
        self.is_restart_flow_error = True

    def to_json(self):
        return {
            'status': self.status
        }


class ConsumeCodePostGeneralErrorResponse(ConsumeCodePostResponse):
    def __init__(
            self,
            message: str):
        super().__init__(
            status='GENERAL_ERROR',
            message=message
        )
        self.is_general_error = True

    def to_json(self):
        return {
            'status': self.status,
            'message': self.message
        }


class ConsumeCodePostIncorrectUserInputCodeErrorResponse(
        ConsumeCodePostResponse):
    def __init__(
            self,
            failed_code_input_attempt_count: int,
            maximum_code_input_attempts: int):
        super().__init__(
            status='INCORRECT_USER_INPUT_CODE_ERROR',
            failed_code_input_attempt_count=failed_code_input_attempt_count,
            maximum_code_input_attempts=maximum_code_input_attempts
        )
        self.is_incorrect_user_input_code_error = True

    def to_json(self):
        return {
            'status': self.status,
            'failedCodeInputAttemptCount': self.failed_code_input_attempt_count,
            'maximumCodeInputAttempts': self.maximum_code_input_attempts
        }


class ConsumeCodePostExpiredUserInputCodeErrorResponse(
        ConsumeCodePostResponse):
    def __init__(
            self,
            failed_code_input_attempt_count: int,
            maximum_code_input_attempts: int):
        super().__init__(
            status='EXPIRED_USER_INPUT_CODE_ERROR',
            failed_code_input_attempt_count=failed_code_input_attempt_count,
            maximum_code_input_attempts=maximum_code_input_attempts
        )
        self.is_expired_user_input_code_error = True

    def to_json(self):
        return {
            'status': self.status,
            'failedCodeInputAttemptCount': self.failed_code_input_attempt_count,
            'maximumCodeInputAttempts': self.maximum_code_input_attempts
        }


class PhoneNumberExistsGetResponse(ABC):
    def __init__(
        self,
        status: Literal['OK'],
        exists: bool
    ):
        self.status = status
        self.exists = exists

    def to_json(self):
        return {
            'status': self.status,
            'exists': self.exists
        }


class PhoneNumberExistsGetOkResponse(PhoneNumberExistsGetResponse):
    def __init__(self, exists: bool):
        super().__init__(status='OK', exists=exists)


class EmailExistsGetResponse(ABC):
    def __init__(
        self,
        status: Literal['OK'],
        exists: bool
    ):
        self.status = status
        self.exists = exists

    def to_json(self):
        return {
            'status': self.status,
            'exists': self.exists
        }


class EmailExistsGetOkResponse(EmailExistsGetResponse):
    def __init__(self, exists: bool):
        super().__init__(status='OK', exists=exists)


class APIInterface:
    def __init__(self):
        self.disable_create_code_post = False
        self.disable_resend_code_post = False
        self.disable_consume_code_post = False
        self.disable_email_exists_get = False
        self.disable_phone_number_exists_get = False

    @abstractmethod
    async def create_code_post(self,
                               email: Union[str, None],
                               phone_number: Union[str, None],
                               api_options: APIOptions,
                               user_context: Dict[str, Any]) -> CreateCodePostResponse:
        pass

    @abstractmethod
    async def resend_code_post(self,
                               device_id: str,
                               pre_auth_session_id: str,
                               api_options: APIOptions,
                               user_context: Dict[str, Any]) -> ResendCodePostResponse:
        pass

    @abstractmethod
    async def consume_code_post(self,
                                pre_auth_session_id: str,
                                user_input_code: Union[str, None],
                                device_id: Union[str, None],
                                link_code: Union[str, None],
                                api_options: APIOptions,
                                user_context: Dict[str, Any]) -> ConsumeCodePostResponse:
        pass

    @abstractmethod
    async def email_exists_get(self,
                               email: str,
                               api_options: APIOptions,
                               user_context: Dict[str, Any]) -> EmailExistsGetResponse:
        pass

    @abstractmethod
    async def phone_number_exists_get(self,
                                      phone_number: str,
                                      api_options: APIOptions,
                                      user_context: Dict[str, Any]) -> PhoneNumberExistsGetResponse:
        pass

Classes

class APIInterface
Expand source code
class APIInterface:
    def __init__(self):
        self.disable_create_code_post = False
        self.disable_resend_code_post = False
        self.disable_consume_code_post = False
        self.disable_email_exists_get = False
        self.disable_phone_number_exists_get = False

    @abstractmethod
    async def create_code_post(self,
                               email: Union[str, None],
                               phone_number: Union[str, None],
                               api_options: APIOptions,
                               user_context: Dict[str, Any]) -> CreateCodePostResponse:
        pass

    @abstractmethod
    async def resend_code_post(self,
                               device_id: str,
                               pre_auth_session_id: str,
                               api_options: APIOptions,
                               user_context: Dict[str, Any]) -> ResendCodePostResponse:
        pass

    @abstractmethod
    async def consume_code_post(self,
                                pre_auth_session_id: str,
                                user_input_code: Union[str, None],
                                device_id: Union[str, None],
                                link_code: Union[str, None],
                                api_options: APIOptions,
                                user_context: Dict[str, Any]) -> ConsumeCodePostResponse:
        pass

    @abstractmethod
    async def email_exists_get(self,
                               email: str,
                               api_options: APIOptions,
                               user_context: Dict[str, Any]) -> EmailExistsGetResponse:
        pass

    @abstractmethod
    async def phone_number_exists_get(self,
                                      phone_number: str,
                                      api_options: APIOptions,
                                      user_context: Dict[str, Any]) -> PhoneNumberExistsGetResponse:
        pass

Subclasses

Methods

async def consume_code_post(self, pre_auth_session_id: str, user_input_code: Optional[str], device_id: Optional[str], link_code: Optional[str], api_options: APIOptions, user_context: Dict[str, Any]) ‑> ConsumeCodePostResponse
Expand source code
@abstractmethod
async def consume_code_post(self,
                            pre_auth_session_id: str,
                            user_input_code: Union[str, None],
                            device_id: Union[str, None],
                            link_code: Union[str, None],
                            api_options: APIOptions,
                            user_context: Dict[str, Any]) -> ConsumeCodePostResponse:
    pass
async def create_code_post(self, email: Optional[str], phone_number: Optional[str], api_options: APIOptions, user_context: Dict[str, Any]) ‑> CreateCodePostResponse
Expand source code
@abstractmethod
async def create_code_post(self,
                           email: Union[str, None],
                           phone_number: Union[str, None],
                           api_options: APIOptions,
                           user_context: Dict[str, Any]) -> CreateCodePostResponse:
    pass
async def email_exists_get(self, email: str, api_options: APIOptions, user_context: Dict[str, Any]) ‑> EmailExistsGetResponse
Expand source code
@abstractmethod
async def email_exists_get(self,
                           email: str,
                           api_options: APIOptions,
                           user_context: Dict[str, Any]) -> EmailExistsGetResponse:
    pass
async def phone_number_exists_get(self, phone_number: str, api_options: APIOptions, user_context: Dict[str, Any]) ‑> PhoneNumberExistsGetResponse
Expand source code
@abstractmethod
async def phone_number_exists_get(self,
                                  phone_number: str,
                                  api_options: APIOptions,
                                  user_context: Dict[str, Any]) -> PhoneNumberExistsGetResponse:
    pass
async def resend_code_post(self, device_id: str, pre_auth_session_id: str, api_options: APIOptions, user_context: Dict[str, Any]) ‑> ResendCodePostResponse
Expand source code
@abstractmethod
async def resend_code_post(self,
                           device_id: str,
                           pre_auth_session_id: str,
                           api_options: APIOptions,
                           user_context: Dict[str, Any]) -> ResendCodePostResponse:
    pass
class APIOptions (request: BaseRequest, response: BaseResponse, recipe_id: str, config: PasswordlessConfig, recipe_implementation: RecipeInterface)
Expand source code
class APIOptions:
    def __init__(self, request: BaseRequest, response: BaseResponse, recipe_id: str,
                 config: PasswordlessConfig, recipe_implementation: RecipeInterface):
        self.request = request
        self.response = response
        self.recipe_id = recipe_id
        self.config = config
        self.recipe_implementation = recipe_implementation
class ConsumeCodeExpiredUserInputCodeErrorResult (failed_code_input_attempt_count: int, maximum_code_input_attempts: int)

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class ConsumeCodeExpiredUserInputCodeErrorResult(ConsumeCodeResult):
    def __init__(self, failed_code_input_attempt_count: int,
                 maximum_code_input_attempts: int):
        super().__init__('EXPIRED_USER_INPUT_CODE_ERROR',
                         failed_code_input_attempt_count=failed_code_input_attempt_count,
                         maximum_code_input_attempts=maximum_code_input_attempts)
        self.is_expired_user_input_code_error = True

Ancestors

class ConsumeCodeIncorrectUserInputCodeErrorResult (failed_code_input_attempt_count: int, maximum_code_input_attempts: int)

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class ConsumeCodeIncorrectUserInputCodeErrorResult(ConsumeCodeResult):
    def __init__(self, failed_code_input_attempt_count: int,
                 maximum_code_input_attempts: int):
        super().__init__('INCORRECT_USER_INPUT_CODE_ERROR',
                         failed_code_input_attempt_count=failed_code_input_attempt_count,
                         maximum_code_input_attempts=maximum_code_input_attempts)
        self.is_incorrect_user_input_code_error = True

Ancestors

class ConsumeCodeOkResult (created_new_user: bool, user: User)

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class ConsumeCodeOkResult(ConsumeCodeResult):
    def __init__(self, created_new_user: bool, user: User):
        super().__init__('OK', created_new_user=created_new_user, user=user)
        self.is_ok = True

Ancestors

class ConsumeCodePostExpiredUserInputCodeErrorResponse (failed_code_input_attempt_count: int, maximum_code_input_attempts: int)

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class ConsumeCodePostExpiredUserInputCodeErrorResponse(
        ConsumeCodePostResponse):
    def __init__(
            self,
            failed_code_input_attempt_count: int,
            maximum_code_input_attempts: int):
        super().__init__(
            status='EXPIRED_USER_INPUT_CODE_ERROR',
            failed_code_input_attempt_count=failed_code_input_attempt_count,
            maximum_code_input_attempts=maximum_code_input_attempts
        )
        self.is_expired_user_input_code_error = True

    def to_json(self):
        return {
            'status': self.status,
            'failedCodeInputAttemptCount': self.failed_code_input_attempt_count,
            'maximumCodeInputAttempts': self.maximum_code_input_attempts
        }

Ancestors

Methods

def to_json(self)
Expand source code
def to_json(self):
    return {
        'status': self.status,
        'failedCodeInputAttemptCount': self.failed_code_input_attempt_count,
        'maximumCodeInputAttempts': self.maximum_code_input_attempts
    }
class ConsumeCodePostGeneralErrorResponse (message: str)

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class ConsumeCodePostGeneralErrorResponse(ConsumeCodePostResponse):
    def __init__(
            self,
            message: str):
        super().__init__(
            status='GENERAL_ERROR',
            message=message
        )
        self.is_general_error = True

    def to_json(self):
        return {
            'status': self.status,
            'message': self.message
        }

Ancestors

Methods

def to_json(self)
Expand source code
def to_json(self):
    return {
        'status': self.status,
        'message': self.message
    }
class ConsumeCodePostIncorrectUserInputCodeErrorResponse (failed_code_input_attempt_count: int, maximum_code_input_attempts: int)

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class ConsumeCodePostIncorrectUserInputCodeErrorResponse(
        ConsumeCodePostResponse):
    def __init__(
            self,
            failed_code_input_attempt_count: int,
            maximum_code_input_attempts: int):
        super().__init__(
            status='INCORRECT_USER_INPUT_CODE_ERROR',
            failed_code_input_attempt_count=failed_code_input_attempt_count,
            maximum_code_input_attempts=maximum_code_input_attempts
        )
        self.is_incorrect_user_input_code_error = True

    def to_json(self):
        return {
            'status': self.status,
            'failedCodeInputAttemptCount': self.failed_code_input_attempt_count,
            'maximumCodeInputAttempts': self.maximum_code_input_attempts
        }

Ancestors

Methods

def to_json(self)
Expand source code
def to_json(self):
    return {
        'status': self.status,
        'failedCodeInputAttemptCount': self.failed_code_input_attempt_count,
        'maximumCodeInputAttempts': self.maximum_code_input_attempts
    }
class ConsumeCodePostOkResponse (created_new_user: bool, user: User, session: SessionContainer)

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class ConsumeCodePostOkResponse(ConsumeCodePostResponse):
    def __init__(self, created_new_user: bool, user: User, session: SessionContainer):
        super().__init__(
            status='OK',
            created_new_user=created_new_user,
            user=user,
            session=session)
        self.is_ok = True

    def to_json(self):
        if self.user is None:
            raise Exception("Should never come here")
        user = {
            'id': self.user.user_id,
            'time_joined': self.user.time_joined
        }
        if self.user.email is not None:
            user = {
                **user,
                'email': self.user.email
            }
        if self.user.phone_number is not None:
            user = {
                **user,
                'phoneNumber': self.user.phone_number
            }
        return {
            'status': self.status,
            'createdNewUser': self.created_new_user,
            'user': user
        }

Ancestors

Methods

def to_json(self)
Expand source code
def to_json(self):
    if self.user is None:
        raise Exception("Should never come here")
    user = {
        'id': self.user.user_id,
        'time_joined': self.user.time_joined
    }
    if self.user.email is not None:
        user = {
            **user,
            'email': self.user.email
        }
    if self.user.phone_number is not None:
        user = {
            **user,
            'phoneNumber': self.user.phone_number
        }
    return {
        'status': self.status,
        'createdNewUser': self.created_new_user,
        'user': user
    }
class ConsumeCodePostResponse (status: Literal['OK', 'GENERAL_ERROR', 'RESTART_FLOW_ERROR', 'INCORRECT_USER_INPUT_CODE_ERROR', 'EXPIRED_USER_INPUT_CODE_ERROR'], created_new_user: Optional[bool] = None, user: Optional[User] = None, session: Optional[SessionContainer] = None, message: Optional[str] = None, failed_code_input_attempt_count: Optional[int] = None, maximum_code_input_attempts: Optional[int] = None)

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class ConsumeCodePostResponse(ABC):
    def __init__(
        self,
        status: Literal[
            'OK',
            'GENERAL_ERROR',
            'RESTART_FLOW_ERROR',
            'INCORRECT_USER_INPUT_CODE_ERROR',
            'EXPIRED_USER_INPUT_CODE_ERROR'
        ],
        created_new_user: Union[bool, None] = None,
        user: Union[User, None] = None,
        session: Union[SessionContainer, None] = None,
        message: Union[str, None] = None,
        failed_code_input_attempt_count: Union[int, None] = None,
        maximum_code_input_attempts: Union[int, None] = None
    ):
        self.status: Literal[
            'OK',
            'GENERAL_ERROR',
            'RESTART_FLOW_ERROR',
            'INCORRECT_USER_INPUT_CODE_ERROR',
            'EXPIRED_USER_INPUT_CODE_ERROR'
        ] = status
        self.session: Union[SessionContainer, None] = session
        self.created_new_user: Union[bool, None] = created_new_user
        self.user: Union[User, None] = user
        self.failed_code_input_attempt_count: Union[int, None] = failed_code_input_attempt_count
        self.maximum_code_input_attempts: Union[int, None] = maximum_code_input_attempts
        self.message: Union[str, None] = message
        self.is_ok: bool = False
        self.is_general_error: bool = False
        self.is_restart_flow_error: bool = False
        self.is_incorrect_user_input_code_error: bool = False
        self.is_expired_user_input_code_error: bool = False

    @abstractmethod
    def to_json(self) -> Dict[str, Any]:
        pass

Ancestors

  • abc.ABC

Subclasses

Methods

def to_json(self) ‑> Dict[str, Any]
Expand source code
@abstractmethod
def to_json(self) -> Dict[str, Any]:
    pass
class ConsumeCodePostRestartFlowErrorResponse

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class ConsumeCodePostRestartFlowErrorResponse(ConsumeCodePostResponse):
    def __init__(self):
        super().__init__(
            status='RESTART_FLOW_ERROR'
        )
        self.is_restart_flow_error = True

    def to_json(self):
        return {
            'status': self.status
        }

Ancestors

Methods

def to_json(self)
Expand source code
def to_json(self):
    return {
        'status': self.status
    }
class ConsumeCodeRestartFlowErrorResult

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class ConsumeCodeRestartFlowErrorResult(ConsumeCodeResult):
    def __init__(self):
        super().__init__('RESTART_FLOW_ERROR')
        self.is_restart_flow_error = True

Ancestors

class ConsumeCodeResult (status: Literal['OK', 'INCORRECT_USER_INPUT_CODE_ERROR', 'EXPIRED_USER_INPUT_CODE_ERROR', 'RESTART_FLOW_ERROR'], created_new_user: Optional[bool] = None, user: Optional[User] = None, failed_code_input_attempt_count: Optional[int] = None, maximum_code_input_attempts: Optional[int] = None)

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class ConsumeCodeResult(ABC):
    def __init__(self,
                 status: Literal['OK',
                                 'INCORRECT_USER_INPUT_CODE_ERROR',
                                 'EXPIRED_USER_INPUT_CODE_ERROR',
                                 'RESTART_FLOW_ERROR'],
                 created_new_user: Union[bool, None] = None,
                 user: Union[User, None] = None,
                 failed_code_input_attempt_count: Union[int, None] = None,
                 maximum_code_input_attempts: Union[int, None] = None
                 ):
        self.status: Literal['OK',
                             'INCORRECT_USER_INPUT_CODE_ERROR',
                             'EXPIRED_USER_INPUT_CODE_ERROR',
                             'RESTART_FLOW_ERROR'] = status
        self.created_new_user: Union[bool, None] = created_new_user
        self.user: Union[User, None] = user
        self.failed_code_input_attempt_count: Union[int, None] = failed_code_input_attempt_count
        self.maximum_code_input_attempts: Union[int, None] = maximum_code_input_attempts
        self.is_ok: bool = False
        self.is_incorrect_user_input_code_error: bool = False
        self.is_expired_user_input_code_error: bool = False
        self.is_restart_flow_error: bool = False

Ancestors

  • abc.ABC

Subclasses

class CreateCodeOkResult (pre_auth_session_id: str, code_id: str, device_id: str, user_input_code: str, link_code: str, code_life_time: int, time_created: int)

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class CreateCodeOkResult(CreateCodeResult):
    def __init__(self, pre_auth_session_id: str, code_id: str, device_id: str,
                 user_input_code: str, link_code: str, code_life_time: int, time_created: int):
        super().__init__('OK', pre_auth_session_id, code_id, device_id, user_input_code, link_code, code_life_time,
                         time_created)

Ancestors

class CreateCodePostGeneralErrorResponse (message: str)

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class CreateCodePostGeneralErrorResponse(CreateCodePostResponse):
    def __init__(
            self,
            message: str):
        super().__init__(
            status='GENERAL_ERROR',
            message=message
        )
        self.is_general_error = True

    def to_json(self):
        return {
            'status': self.status,
            'message': self.message
        }

Ancestors

Methods

def to_json(self)
Expand source code
def to_json(self):
    return {
        'status': self.status,
        'message': self.message
    }
class CreateCodePostOkResponse (device_id: str, pre_auth_session_id: str, flow_type: Literal['USER_INPUT_CODE', 'MAGIC_LINK', 'USER_INPUT_CODE_AND_MAGIC_LINK'])

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class CreateCodePostOkResponse(CreateCodePostResponse):
    def __init__(
            self,
            device_id: str,
            pre_auth_session_id: str,
            flow_type: Literal['USER_INPUT_CODE', 'MAGIC_LINK', 'USER_INPUT_CODE_AND_MAGIC_LINK']):
        super().__init__(
            status='OK',
            device_id=device_id,
            pre_auth_session_id=pre_auth_session_id,
            flow_type=flow_type
        )
        self.is_ok = True

    def to_json(self):
        return {
            'status': self.status,
            'deviceId': self.device_id,
            'preAuthSessionId': self.pre_auth_session_id,
            'flowType': self.flow_type
        }

Ancestors

Methods

def to_json(self)
Expand source code
def to_json(self):
    return {
        'status': self.status,
        'deviceId': self.device_id,
        'preAuthSessionId': self.pre_auth_session_id,
        'flowType': self.flow_type
    }
class CreateCodePostResponse (status: Literal['OK', 'GENERAL_ERROR'], device_id: Optional[str] = None, pre_auth_session_id: Optional[str] = None, flow_type: Optional[None] = None, message: Optional[str] = None)

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class CreateCodePostResponse(ABC):
    def __init__(
        self,
        status: Literal['OK', 'GENERAL_ERROR'],
        device_id: Union[str, None] = None,
        pre_auth_session_id: Union[str, None] = None,
        flow_type: Union[None, Literal['USER_INPUT_CODE', 'MAGIC_LINK',
                                       'USER_INPUT_CODE_AND_MAGIC_LINK']] = None,
        message: Union[str, None] = None
    ):
        self.status = status
        self.device_id = device_id
        self.pre_auth_session_id = pre_auth_session_id
        self.flow_type = flow_type
        self.message = message
        self.is_ok = False
        self.is_general_error = False

    @abstractmethod
    def to_json(self) -> Dict[str, Any]:
        pass

Ancestors

  • abc.ABC

Subclasses

Methods

def to_json(self) ‑> Dict[str, Any]
Expand source code
@abstractmethod
def to_json(self) -> Dict[str, Any]:
    pass
class CreateCodeResult (status: Literal['OK'], pre_auth_session_id: str, code_id: str, device_id: str, user_input_code: str, link_code: str, code_life_time: int, time_created: int)

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class CreateCodeResult(ABC):
    def __init__(
            self,
            status: Literal['OK'],
            pre_auth_session_id: str,
            code_id: str,
            device_id: str,
            user_input_code: str,
            link_code: str,
            code_life_time: int,
            time_created: int
    ):
        self.status = status
        self.pre_auth_session_id = pre_auth_session_id
        self.code_id = code_id
        self.device_id = device_id
        self.user_input_code = user_input_code
        self.link_code = link_code
        self.code_life_time = code_life_time
        self.time_created = time_created

Ancestors

  • abc.ABC

Subclasses

class CreateNewCodeForDeviceOkResult (pre_auth_session_id: str, code_id: str, device_id: str, user_input_code: str, link_code: str, code_life_time: int, time_created: int)

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class CreateNewCodeForDeviceOkResult(CreateNewCodeForDeviceResult):
    def __init__(self,
                 pre_auth_session_id: str,
                 code_id: str,
                 device_id: str,
                 user_input_code: str,
                 link_code: str,
                 code_life_time: int,
                 time_created: int
                 ):
        super().__init__(
            'OK',
            pre_auth_session_id,
            code_id,
            device_id,
            user_input_code,
            link_code,
            code_life_time,
            time_created
        )
        self.is_ok = True

Ancestors

class CreateNewCodeForDeviceRestartFlowErrorResult

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class CreateNewCodeForDeviceRestartFlowErrorResult(
        CreateNewCodeForDeviceResult):
    def __init__(self):
        super().__init__('RESTART_FLOW_ERROR')
        self.is_restart_flow_error = True

Ancestors

class CreateNewCodeForDeviceResult (status: Literal['OK', 'RESTART_FLOW_ERROR', 'USER_INPUT_CODE_ALREADY_USED_ERROR'], pre_auth_session_id: Optional[str] = None, code_id: Optional[str] = None, device_id: Optional[str] = None, user_input_code: Optional[str] = None, link_code: Optional[str] = None, code_life_time: Optional[int] = None, time_created: Optional[int] = None)

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class CreateNewCodeForDeviceResult(ABC):
    def __init__(self,
                 status: Literal['OK', 'RESTART_FLOW_ERROR', 'USER_INPUT_CODE_ALREADY_USED_ERROR'],
                 pre_auth_session_id: Union[str, None] = None,
                 code_id: Union[str, None] = None,
                 device_id: Union[str, None] = None,
                 user_input_code: Union[str, None] = None,
                 link_code: Union[str, None] = None,
                 code_life_time: Union[int, None] = None,
                 time_created: Union[int, None] = None
                 ):
        self.status = status
        self.pre_auth_session_id = pre_auth_session_id
        self.code_id = code_id
        self.device_id = device_id
        self.user_input_code = user_input_code
        self.link_code = link_code
        self.code_life_time = code_life_time
        self.time_created = time_created
        self.is_ok = False
        self.is_restart_flow_error = False
        self.is_user_input_code_already_used_error = False

Ancestors

  • abc.ABC

Subclasses

class CreateNewCodeForDeviceUserInputCodeAlreadyUsedErrorResult

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class CreateNewCodeForDeviceUserInputCodeAlreadyUsedErrorResult(
        CreateNewCodeForDeviceResult):
    def __init__(self):
        super().__init__('USER_INPUT_CODE_ALREADY_USED_ERROR')
        self.is_user_input_code_already_used_error = True

Ancestors

class DeleteUserInfoOkResult

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class DeleteUserInfoOkResult(DeleteUserInfoResult):
    def __init__(self):
        super().__init__('OK')
        self.is_ok = True

Ancestors

class DeleteUserInfoResult (status: Literal['OK', 'UNKNOWN_USER_ID_ERROR'])

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class DeleteUserInfoResult(ABC):
    def __init__(self, status: Literal['OK', 'UNKNOWN_USER_ID_ERROR']):
        self.status = status
        self.is_ok = False
        self.is_unknown_user_id_error = False

Ancestors

  • abc.ABC

Subclasses

class DeleteUserInfoUnknownUserIdErrorResult

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class DeleteUserInfoUnknownUserIdErrorResult(DeleteUserInfoResult):
    def __init__(self):
        super().__init__('UNKNOWN_USER_ID_ERROR')
        self.is_unknown_user_id_error = True

Ancestors

class EmailExistsGetOkResponse (exists: bool)

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class EmailExistsGetOkResponse(EmailExistsGetResponse):
    def __init__(self, exists: bool):
        super().__init__(status='OK', exists=exists)

Ancestors

class EmailExistsGetResponse (status: Literal['OK'], exists: bool)

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class EmailExistsGetResponse(ABC):
    def __init__(
        self,
        status: Literal['OK'],
        exists: bool
    ):
        self.status = status
        self.exists = exists

    def to_json(self):
        return {
            'status': self.status,
            'exists': self.exists
        }

Ancestors

  • abc.ABC

Subclasses

Methods

def to_json(self)
Expand source code
def to_json(self):
    return {
        'status': self.status,
        'exists': self.exists
    }
class PhoneNumberExistsGetOkResponse (exists: bool)

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class PhoneNumberExistsGetOkResponse(PhoneNumberExistsGetResponse):
    def __init__(self, exists: bool):
        super().__init__(status='OK', exists=exists)

Ancestors

class PhoneNumberExistsGetResponse (status: Literal['OK'], exists: bool)

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class PhoneNumberExistsGetResponse(ABC):
    def __init__(
        self,
        status: Literal['OK'],
        exists: bool
    ):
        self.status = status
        self.exists = exists

    def to_json(self):
        return {
            'status': self.status,
            'exists': self.exists
        }

Ancestors

  • abc.ABC

Subclasses

Methods

def to_json(self)
Expand source code
def to_json(self):
    return {
        'status': self.status,
        'exists': self.exists
    }
class RecipeInterface

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class RecipeInterface(ABC):
    def __init__(self):
        pass

    @abstractmethod
    async def create_code(self,
                          email: Union[None, str],
                          phone_number: Union[None, str],
                          user_input_code: Union[None, str],
                          user_context: Dict[str, Any]) -> CreateCodeResult:
        pass

    @abstractmethod
    async def create_new_code_for_device(self,
                                         device_id: str,
                                         user_input_code: Union[str, None],
                                         user_context: Dict[str, Any]) -> CreateNewCodeForDeviceResult:
        pass

    @abstractmethod
    async def consume_code(self,
                           pre_auth_session_id: str,
                           user_input_code: Union[str, None],
                           device_id: Union[str, None],
                           link_code: Union[str, None],
                           user_context: Dict[str, Any]) -> ConsumeCodeResult:
        pass

    @abstractmethod
    async def get_user_by_id(self, user_id: str, user_context: Dict[str, Any]) -> Union[User, None]:
        pass

    @abstractmethod
    async def get_user_by_email(self, email: str, user_context: Dict[str, Any]) -> Union[User, None]:
        pass

    @abstractmethod
    async def get_user_by_phone_number(self, phone_number: str, user_context: Dict[str, Any]) -> Union[User, None]:
        pass

    @abstractmethod
    async def update_user(self, user_id: str,
                          email: Union[str, None], phone_number: Union[str, None], user_context: Dict[str, Any]) -> UpdateUserResult:
        pass

    @abstractmethod
    async def delete_email_for_user(self, user_id: str, user_context: Dict[str, Any]) -> DeleteUserInfoResult:
        pass

    @abstractmethod
    async def delete_phone_number_for_user(self, user_id: str, user_context: Dict[str, Any]) -> DeleteUserInfoResult:
        pass

    @abstractmethod
    async def revoke_all_codes(self,
                               email: Union[str, None], phone_number: Union[str, None], user_context: Dict[str, Any]) -> RevokeAllCodesResult:
        pass

    @abstractmethod
    async def revoke_code(self, code_id: str, user_context: Dict[str, Any]) -> RevokeCodeResult:
        pass

    @abstractmethod
    async def list_codes_by_email(self, email: str, user_context: Dict[str, Any]) -> List[DeviceType]:
        pass

    @abstractmethod
    async def list_codes_by_phone_number(self, phone_number: str, user_context: Dict[str, Any]) -> List[DeviceType]:
        pass

    @abstractmethod
    async def list_codes_by_device_id(self, device_id: str, user_context: Dict[str, Any]) -> Union[DeviceType, None]:
        pass

    @abstractmethod
    async def list_codes_by_pre_auth_session_id(self, pre_auth_session_id: str,
                                                user_context: Dict[str, Any]) -> Union[DeviceType, None]:
        pass

Ancestors

  • abc.ABC

Subclasses

Methods

async def consume_code(self, pre_auth_session_id: str, user_input_code: Optional[str], device_id: Optional[str], link_code: Optional[str], user_context: Dict[str, Any]) ‑> ConsumeCodeResult
Expand source code
@abstractmethod
async def consume_code(self,
                       pre_auth_session_id: str,
                       user_input_code: Union[str, None],
                       device_id: Union[str, None],
                       link_code: Union[str, None],
                       user_context: Dict[str, Any]) -> ConsumeCodeResult:
    pass
async def create_code(self, email: Optional[str], phone_number: Optional[str], user_input_code: Optional[str], user_context: Dict[str, Any]) ‑> CreateCodeResult
Expand source code
@abstractmethod
async def create_code(self,
                      email: Union[None, str],
                      phone_number: Union[None, str],
                      user_input_code: Union[None, str],
                      user_context: Dict[str, Any]) -> CreateCodeResult:
    pass
async def create_new_code_for_device(self, device_id: str, user_input_code: Optional[str], user_context: Dict[str, Any]) ‑> CreateNewCodeForDeviceResult
Expand source code
@abstractmethod
async def create_new_code_for_device(self,
                                     device_id: str,
                                     user_input_code: Union[str, None],
                                     user_context: Dict[str, Any]) -> CreateNewCodeForDeviceResult:
    pass
async def delete_email_for_user(self, user_id: str, user_context: Dict[str, Any]) ‑> DeleteUserInfoResult
Expand source code
@abstractmethod
async def delete_email_for_user(self, user_id: str, user_context: Dict[str, Any]) -> DeleteUserInfoResult:
    pass
async def delete_phone_number_for_user(self, user_id: str, user_context: Dict[str, Any]) ‑> DeleteUserInfoResult
Expand source code
@abstractmethod
async def delete_phone_number_for_user(self, user_id: str, user_context: Dict[str, Any]) -> DeleteUserInfoResult:
    pass
async def get_user_by_email(self, email: str, user_context: Dict[str, Any]) ‑> Optional[User]
Expand source code
@abstractmethod
async def get_user_by_email(self, email: str, user_context: Dict[str, Any]) -> Union[User, None]:
    pass
async def get_user_by_id(self, user_id: str, user_context: Dict[str, Any]) ‑> Optional[User]
Expand source code
@abstractmethod
async def get_user_by_id(self, user_id: str, user_context: Dict[str, Any]) -> Union[User, None]:
    pass
async def get_user_by_phone_number(self, phone_number: str, user_context: Dict[str, Any]) ‑> Optional[User]
Expand source code
@abstractmethod
async def get_user_by_phone_number(self, phone_number: str, user_context: Dict[str, Any]) -> Union[User, None]:
    pass
async def list_codes_by_device_id(self, device_id: str, user_context: Dict[str, Any]) ‑> Optional[DeviceType]
Expand source code
@abstractmethod
async def list_codes_by_device_id(self, device_id: str, user_context: Dict[str, Any]) -> Union[DeviceType, None]:
    pass
async def list_codes_by_email(self, email: str, user_context: Dict[str, Any]) ‑> List[DeviceType]
Expand source code
@abstractmethod
async def list_codes_by_email(self, email: str, user_context: Dict[str, Any]) -> List[DeviceType]:
    pass
async def list_codes_by_phone_number(self, phone_number: str, user_context: Dict[str, Any]) ‑> List[DeviceType]
Expand source code
@abstractmethod
async def list_codes_by_phone_number(self, phone_number: str, user_context: Dict[str, Any]) -> List[DeviceType]:
    pass
async def list_codes_by_pre_auth_session_id(self, pre_auth_session_id: str, user_context: Dict[str, Any]) ‑> Optional[DeviceType]
Expand source code
@abstractmethod
async def list_codes_by_pre_auth_session_id(self, pre_auth_session_id: str,
                                            user_context: Dict[str, Any]) -> Union[DeviceType, None]:
    pass
async def revoke_all_codes(self, email: Optional[str], phone_number: Optional[str], user_context: Dict[str, Any]) ‑> RevokeAllCodesResult
Expand source code
@abstractmethod
async def revoke_all_codes(self,
                           email: Union[str, None], phone_number: Union[str, None], user_context: Dict[str, Any]) -> RevokeAllCodesResult:
    pass
async def revoke_code(self, code_id: str, user_context: Dict[str, Any]) ‑> RevokeCodeResult
Expand source code
@abstractmethod
async def revoke_code(self, code_id: str, user_context: Dict[str, Any]) -> RevokeCodeResult:
    pass
async def update_user(self, user_id: str, email: Optional[str], phone_number: Optional[str], user_context: Dict[str, Any]) ‑> UpdateUserResult
Expand source code
@abstractmethod
async def update_user(self, user_id: str,
                      email: Union[str, None], phone_number: Union[str, None], user_context: Dict[str, Any]) -> UpdateUserResult:
    pass
class ResendCodePostGeneralErrorResponse (message: str)

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class ResendCodePostGeneralErrorResponse(ResendCodePostResponse):
    def __init__(self, message: str):
        super().__init__(status='GENERAL_ERROR', message=message)
        self.is_general_error = True

    def to_json(self):
        return {
            'status': self.status,
            'message': self.message
        }

Ancestors

Methods

def to_json(self)
Expand source code
def to_json(self):
    return {
        'status': self.status,
        'message': self.message
    }
class ResendCodePostOkResponse

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class ResendCodePostOkResponse(ResendCodePostResponse):
    def __init__(self):
        super().__init__(status='OK')
        self.is_ok = True

    def to_json(self):
        return {
            'status': self.status
        }

Ancestors

Methods

def to_json(self)
Expand source code
def to_json(self):
    return {
        'status': self.status
    }
class ResendCodePostResponse (status: Literal['OK', 'GENERAL_ERROR', 'RESTART_FLOW_ERROR'], message: Optional[str] = None)

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class ResendCodePostResponse(ABC):
    def __init__(
        self,
        status: Literal['OK', 'GENERAL_ERROR', 'RESTART_FLOW_ERROR'],
        message: Union[str, None] = None
    ):
        self.status = status
        self.message = message
        self.is_ok = False
        self.is_general_error = False
        self.is_restart_flow_error = False

    @abstractmethod
    def to_json(self) -> Dict[str, Any]:
        pass

Ancestors

  • abc.ABC

Subclasses

Methods

def to_json(self) ‑> Dict[str, Any]
Expand source code
@abstractmethod
def to_json(self) -> Dict[str, Any]:
    pass
class ResendCodePostRestartFlowErrorResponse

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class ResendCodePostRestartFlowErrorResponse(ResendCodePostResponse):
    def __init__(self):
        super().__init__(
            status='RESTART_FLOW_ERROR'
        )
        self.is_restart_flow_error = True

    def to_json(self):
        return {
            'status': self.status
        }

Ancestors

Methods

def to_json(self)
Expand source code
def to_json(self):
    return {
        'status': self.status
    }
class RevokeAllCodesOkResult

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class RevokeAllCodesOkResult(RevokeAllCodesResult):
    def __init__(self):
        super().__init__('OK')

Ancestors

class RevokeAllCodesResult (status: Literal['OK'])

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class RevokeAllCodesResult(ABC):
    def __init__(self, status: Literal['OK']):
        self.status = status

Ancestors

  • abc.ABC

Subclasses

class RevokeCodeOkResult

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class RevokeCodeOkResult(RevokeCodeResult):
    def __init__(self):
        super().__init__('OK')

Ancestors

class RevokeCodeResult (status: Literal['OK'])

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class RevokeCodeResult(ABC):
    def __init__(self, status: Literal['OK']):
        self.status = status

Ancestors

  • abc.ABC

Subclasses

class UpdateUserEmailAlreadyExistsErrorResult

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class UpdateUserEmailAlreadyExistsErrorResult(UpdateUserResult):
    def __init__(self):
        super().__init__('EMAIL_ALREADY_EXISTS_ERROR')

Ancestors

class UpdateUserOkResult

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class UpdateUserOkResult(UpdateUserResult):
    def __init__(self):
        super().__init__('OK')

Ancestors

class UpdateUserPhoneNumberAlreadyExistsErrorResult

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class UpdateUserPhoneNumberAlreadyExistsErrorResult(UpdateUserResult):
    def __init__(self):
        super().__init__('PHONE_NUMBER_ALREADY_EXISTS_ERROR')

Ancestors

class UpdateUserResult (status: Literal['OK', 'UNKNOWN_USER_ID_ERROR', 'EMAIL_ALREADY_EXISTS_ERROR', 'PHONE_NUMBER_ALREADY_EXISTS_ERROR'])

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class UpdateUserResult(ABC):
    def __init__(self, status: Literal['OK', 'UNKNOWN_USER_ID_ERROR',
                 'EMAIL_ALREADY_EXISTS_ERROR', 'PHONE_NUMBER_ALREADY_EXISTS_ERROR']):
        self.status = status

Ancestors

  • abc.ABC

Subclasses

class UpdateUserUnknownUserIdErrorResult

Helper class that provides a standard way to create an ABC using inheritance.

Expand source code
class UpdateUserUnknownUserIdErrorResult(UpdateUserResult):
    def __init__(self):
        super().__init__('UNKNOWN_USER_ID_ERROR')

Ancestors