Skip to content

Clerk State

reflex_clerk.ClerkState

Bases: State

A Reflex state object representing the current authenticated session and user; use this state to render details about the currently logged in user.

Example
import reflex_clerk as clerk

clerk.signed_in(
    rx.cond(
        ClerkState.user.has_image,
        rx.chakra.avatar(
            src=ClerkState.user.image_url,
            name=ClerkState.user.first_name,
            size="xl",
        ),
    )
)
Example
import reflex_clerk as clerk

clerk.protect(
    rx.fragment("You are logged in as ", clerk.ClerkState.user.first_name),
    fallback=rx.text("You need to sign in first!"),
)
Source code in custom_components/reflex_clerk/lib/clerk_provider.py
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
class ClerkState(rx.State):
    """
    A Reflex state object representing the current authenticated session and user;
    use this state to render details about the currently logged in user.

    Example:
        ```python
        import reflex_clerk as clerk

        clerk.signed_in(
            rx.cond(
                ClerkState.user.has_image,
                rx.chakra.avatar(
                    src=ClerkState.user.image_url,
                    name=ClerkState.user.first_name,
                    size="xl",
                ),
            )
        )
        ```

    Example:
        ```python
        import reflex_clerk as clerk

        clerk.protect(
            rx.fragment("You are logged in as ", clerk.ClerkState.user.first_name),
            fallback=rx.text("You need to sign in first!"),
        )
        ```


    """

    is_signed_in: bool = False
    """
    True if the user is signed in, False otherwise.

    This field is only set to true after server-side validation of the session is complete.
    Check if this is true before returning sensitive user state from other states.

    Example:
        ```python
        rx.cond(
            clerk.ClerkState.is_signed_in,
            rx.text("You are signed in"),
            rx.text("You are signed out")
        )
        ```

        _Consider using [reflex_clerk.signed_in][] and [reflex_clerk.signed_out][] instead
        to render different information based on if the user is signed in or not on the client
        side instead of on the server._

    """

    auth_error: typing.Optional[Exception] = None
    """
    Non-None if the user authentication process failed.

    This should be quite rare, and likely indicates an expired session.
    """

    claims: typing.Optional[JWTClaims] = None
    """
    This field contains the decoded JWT Session claims once server-side validation
    of the session is complete.  You can use
    [Clerk JWT Templates](https://clerk.com/docs/backend-requests/making/jwt-templates)
    to return additional information about the session to this field.
    """

    user_id: typing.Optional[str] = None
    """
    A variable representing the Clerk User ID of the currently logged in user.

    This field is only set to true after server-side validation of the session is complete.
    """

    user: typing.Optional[clerk_response_models.User] = None
    """
    A variable representing the Clerk User of the currently logged in user.

    This field is only set to true after server-side validation of the session is complete,
    and can be disabled for performance reasons using [set_fetch_user_on_auth][reflex_clerk.ClerkState.set_fetch_user_on_auth].
    """

    # static class variables
    _jwt_public_keys: List[typing.Dict[str, str]] = []
    _secret_key: str = None
    _clerk_api_client: ClerkAPIClient = None
    _fetch_user: bool = True

    # noinspection PyPropertyDefinition
    @classmethod
    @property
    def secret_key(cls) -> str:
        if cls._secret_key is None:
            if 'CLERK_SECRET_KEY' in os.environ:
                cls._secret_key = os.environ['CLERK_SECRET_KEY']

        return cls._secret_key

    # noinspection PyPropertyDefinition
    @classmethod
    @property
    def jwt_public_keys(cls) -> typing.List[typing.Dict[str, str]]:
        if not cls._jwt_public_keys:
            if 'CLERK_JWT_PUBLIC_KEYS' in os.environ:
                cls._jwt_public_keys = list(map(json.loads, os.environ['CLERK_JWT_PUBLIC_KEYS'].split(',')))
            if cls.secret_key and cls.clerk_api_client:
                cls._jwt_public_keys = cls._clerk_api_client.get_jwks().dict()['keys']
        return cls._jwt_public_keys

    # noinspection PyPropertyDefinition
    @classmethod
    @property
    def clerk_api_client(cls) -> clerk_client.ClerkAPIClient:
        if cls._clerk_api_client is None:
            cls._clerk_api_client = clerk_client.get_client(cls.secret_key)
        return cls._clerk_api_client

    @classmethod
    def set_fetch_user_on_auth(cls, fetch_user: bool):
        """
        This method is used to control whether the authenticating user should be
        fetched from Clerk upon successful authentication.

        Defaults to true; set this to False if the Clark User object is not being
        used, as it saves a backend call to Clark every time a user authenticates.

        Note:
            Setting this to True only fetches ClerkState.user once at the time of
            user authentication. This implementation doesn't automatically detect
             and update any changes in the underlying user object data, such as
            email address modifications. Therefore, to ensure you have the latest
            user data while logged in, especially if changes have been made, you
            should use the ClerkState.fetch_user reflex event to manually refresh
            the user data.

        Args:
            fetch_user (bool): Indicates whether the user should be fetched.
        """
        cls._fetch_user = fetch_user

    def set_clerk_session(self, token: str) -> None:
        """
        Validates a Clerk session token and optionally fetches the associated
        user object.  This is used internally by reflex_clerk to manage the
        current auth state of users: it is called by the frontend whenever
        the Clerk isSignedIn auth state changes from false to true.

        Args:
            token: A JWT token used to authenticate and authorize the user.
        """
        if not ClerkState._jwt_public_keys:
            print(f"No Clerk JWT public keys found. Skipping Clerk session set.")
            return

        try:
            decoded: JWTClaims = jwt.decode(token, {"keys": ClerkState.jwt_public_keys})
            self.is_signed_in = True
            self.claims = decoded
            self.user_id = decoded.get('sub')

            if self._fetch_user:
                self.fetch_user()

        except JoseError as e:
            self.auth_error = e
            logging.warning(f"Auth error: {e}")

    def clear_clerk_session(self):
        """
        Clears the clerk session by setting the sign-in status to False,
        resetting the claims to None, and clearing any authentication errors.

        This is used internally by reflex_clerk to manage the
        current auth state of users: it is called by the frontend whenever
        the Clerk isSignedIn auth state changes from true to false.


        :param self: The current instance of the class.
        """
        self.is_signed_in = False
        self.claims = None
        self.auth_error = None

    def clear_clerk_auth_error(self):
        """
        Clears the clerk authentication error.

        This method sets the `auth_error` attribute of the current instance to `None`.
        """
        self.auth_error = None

    def fetch_user(self):
        """
        Fetches ClerkState.user from the clerk backend API, using
        ClerkState.user_id.  Use this Reflex event if you want to force
        update the clerk user data after a user logs in (such as after modifying
        their account profile).
        """
        if self.user_id:
            user = self.clerk_api_client.get_user(self.user_id)
            self.set_user(user)

is_signed_in class-attribute instance-attribute

is_signed_in: bool = False

True if the user is signed in, False otherwise.

This field is only set to true after server-side validation of the session is complete. Check if this is true before returning sensitive user state from other states.

Example
rx.cond(
    clerk.ClerkState.is_signed_in,
    rx.text("You are signed in"),
    rx.text("You are signed out")
)

Consider using reflex_clerk.signed_in and reflex_clerk.signed_out instead to render different information based on if the user is signed in or not on the client side instead of on the server.

user class-attribute instance-attribute

user: Optional[User] = None

A variable representing the Clerk User of the currently logged in user.

This field is only set to true after server-side validation of the session is complete, and can be disabled for performance reasons using set_fetch_user_on_auth.

user_id class-attribute instance-attribute

user_id: Optional[str] = None

A variable representing the Clerk User ID of the currently logged in user.

This field is only set to true after server-side validation of the session is complete.

fetch_user

fetch_user()

Fetches ClerkState.user from the clerk backend API, using ClerkState.user_id. Use this Reflex event if you want to force update the clerk user data after a user logs in (such as after modifying their account profile).

Source code in custom_components/reflex_clerk/lib/clerk_provider.py
221
222
223
224
225
226
227
228
229
230
def fetch_user(self):
    """
    Fetches ClerkState.user from the clerk backend API, using
    ClerkState.user_id.  Use this Reflex event if you want to force
    update the clerk user data after a user logs in (such as after modifying
    their account profile).
    """
    if self.user_id:
        user = self.clerk_api_client.get_user(self.user_id)
        self.set_user(user)

set_fetch_user_on_auth classmethod

set_fetch_user_on_auth(fetch_user: bool)

This method is used to control whether the authenticating user should be fetched from Clerk upon successful authentication.

Defaults to true; set this to False if the Clark User object is not being used, as it saves a backend call to Clark every time a user authenticates.

Note

Setting this to True only fetches ClerkState.user once at the time of user authentication. This implementation doesn't automatically detect and update any changes in the underlying user object data, such as email address modifications. Therefore, to ensure you have the latest user data while logged in, especially if changes have been made, you should use the ClerkState.fetch_user reflex event to manually refresh the user data.

Parameters:

  • fetch_user (bool) –

    Indicates whether the user should be fetched.

Source code in custom_components/reflex_clerk/lib/clerk_provider.py
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
@classmethod
def set_fetch_user_on_auth(cls, fetch_user: bool):
    """
    This method is used to control whether the authenticating user should be
    fetched from Clerk upon successful authentication.

    Defaults to true; set this to False if the Clark User object is not being
    used, as it saves a backend call to Clark every time a user authenticates.

    Note:
        Setting this to True only fetches ClerkState.user once at the time of
        user authentication. This implementation doesn't automatically detect
         and update any changes in the underlying user object data, such as
        email address modifications. Therefore, to ensure you have the latest
        user data while logged in, especially if changes have been made, you
        should use the ClerkState.fetch_user reflex event to manually refresh
        the user data.

    Args:
        fetch_user (bool): Indicates whether the user should be fetched.
    """
    cls._fetch_user = fetch_user

reflex_clerk.User

Bases: BaseModel

Represents a user object with various attributes related to their profile, authentication, and metadata.

See the Clerk documentation ⧉ for more details.

Attributes:

  • id (str) –

    A unique identifier for the user.

  • object (str) –

    The type of object, typically 'user'.

  • external_id (Optional[str]) –

    An optional external identifier for the user.

  • primary_email_address_id (Optional[str]) –

    The unique identifier for the EmailAddress that the user has set as primary.

  • primary_phone_number_id (Optional[str]) –

    The unique identifier for the PhoneNumber that the user has set as primary.

  • primary_web3_wallet_id (Optional[str]) –

    The unique identifier for the Web3Wallet that the user signed up with.

  • username (Optional[str]) –

    The user's username.

  • first_name (Optional[str]) –

    The user's first name.

  • last_name (Optional[str]) –

    The user's last name.

  • profile_image_url (Optional[str]) –

    Holds the default avatar or user's uploaded profile image. Compatible with Clerk's Image Optimization.

  • image_url (Optional[str]) –

    The URL of the user's profile image.

  • passkeys (Optional[List[PasskeyResource]]) –

    An array of passkeys associated with the user's account.

  • has_image (bool) –

    A boolean to check if the user has uploaded an image or one was copied from OAuth. Returns false if Clerk is displaying an avatar for the user.

  • public_metadata (Dict[str, Any]) –

    Metadata that can be read from the Frontend API and Backend API and can be set only from the Backend API.

  • private_metadata (Optional[Dict[str, Any]]) –

    Metadata that can be read and set only from the Backend API.

  • unsafe_metadata (Dict[str, Any]) –

    Metadata that can be read and set from the Frontend API. Often used for custom fields attached to the User object.

  • email_addresses (List[EmailAddress]) –

    An array of all the EmailAddress objects associated with the user, including the primary.

  • phone_numbers (List[PhoneNumber]) –

    An array of all the PhoneNumber objects associated with the user, including the primary.

  • web3_wallets (List[Web3Wallet]) –

    An array of all the Web3Wallet objects associated with the user, including the primary.

  • saml_accounts (List[SAMLAccount]) –

    An experimental list of SAML accounts associated with the user.

  • password_enabled (bool) –

    A boolean indicating whether the user has a password on their account.

  • two_factor_enabled (bool) –

    A boolean indicating whether the user has enabled two-factor authentication.

  • totp_enabled (bool) –

    A boolean indicating whether the user has enabled TOTP by generating a TOTP secret and verifying it via an authenticator app.

  • backup_code_enabled (bool) –

    A boolean indicating whether the user has enabled Backup codes.

  • last_sign_in_at (Optional[int]) –

    The date when the user last signed in, may be empty if the user has never signed in.

  • banned (bool) –

    A boolean indicating whether the user is banned.

  • locked (bool) –

    A boolean indicating whether the user is locked.

Source code in custom_components/reflex_clerk/clerk_client/clerk_response_models.py
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
class User(BaseModel):
    """
    Represents a user object with various attributes related to their profile, authentication, and metadata.

    See the [Clerk documentation][1] for more details.

    [1]: https://clerk.com/docs/users/overview

    Attributes:
        id: A unique identifier for the user.
        object: The type of object, typically 'user'.
        external_id: An optional external identifier for the user.
        primary_email_address_id: The unique identifier for the EmailAddress that the user has set as primary.
        primary_phone_number_id: The unique identifier for the PhoneNumber that the user has set as primary.
        primary_web3_wallet_id: The unique identifier for the Web3Wallet that the user signed up with.
        username: The user's username.
        first_name: The user's first name.
        last_name: The user's last name.
        profile_image_url: Holds the default avatar or user's uploaded profile image. Compatible with Clerk's Image Optimization.
        image_url: The URL of the user's profile image.
        passkeys: An array of passkeys associated with the user's account.
        has_image: A boolean to check if the user has uploaded an image or one was copied from OAuth. Returns false if Clerk is displaying an avatar for the user.
        public_metadata: Metadata that can be read from the Frontend API and Backend API and can be set only from the Backend API.
        private_metadata: Metadata that can be read and set only from the Backend API.
        unsafe_metadata: Metadata that can be read and set from the Frontend API. Often used for custom fields attached to the User object.
        email_addresses: An array of all the EmailAddress objects associated with the user, including the primary.
        phone_numbers: An array of all the PhoneNumber objects associated with the user, including the primary.
        web3_wallets: An array of all the Web3Wallet objects associated with the user, including the primary.
        saml_accounts: An experimental list of SAML accounts associated with the user.
        password_enabled: A boolean indicating whether the user has a password on their account.
        two_factor_enabled: A boolean indicating whether the user has enabled two-factor authentication.
        totp_enabled: A boolean indicating whether the user has enabled TOTP by generating a TOTP secret and verifying it via an authenticator app.
        backup_code_enabled: A boolean indicating whether the user has enabled Backup codes.
        last_sign_in_at: The date when the user last signed in, may be empty if the user has never signed in.
        banned: A boolean indicating whether the user is banned.
        locked: A boolean indicating whether the user is locked.
    """

    id: str
    """A unique identifier for the user."""

    object: str
    """The type of object, typically 'user'."""

    external_id: Optional[str] = None
    """An optional external identifier for the user."""

    primary_email_address_id: Optional[str] = None
    """The unique identifier for the EmailAddress that the user has set as primary."""

    primary_phone_number_id: Optional[str] = None
    """The unique identifier for the PhoneNumber that the user has set as primary."""

    primary_web3_wallet_id: Optional[str] = None
    """The unique identifier for the Web3Wallet that the user signed up with."""

    username: Optional[str] = None
    """The user's username."""

    first_name: Optional[str] = None
    """The user's first name."""

    last_name: Optional[str] = None
    """The user's last name."""

    profile_image_url: Optional[str] = None
    """Holds the default avatar or user's uploaded profile image. Compatible with Clerk's Image Optimization."""

    image_url: Optional[str] = None
    """The URL of the user's profile image."""

    passkeys: Optional[List[PasskeyResource]] = None
    """An array of passkeys associated with the user's account."""

    has_image: bool
    """
    A boolean to check if the user has uploaded an image or one was copied from OAuth.
     Returns false if Clerk is displaying an avatar for the user.
     """

    public_metadata: Dict[str, Any]
    """Metadata that can be read from the Frontend API and Backend API and can be set only from the Backend API."""

    private_metadata: Optional[Dict[str, Any]] = None
    """Metadata that can be read and set only from the Backend API."""

    unsafe_metadata: Dict[str, Any]
    """
    Metadata that can be read and set from the Frontend API. Often used
    for custom fields attached to the User object.
    """

    email_addresses: List[EmailAddress]
    """An array of all the EmailAddress objects associated with the user, including the primary."""

    phone_numbers: List[PhoneNumber]
    """An array of all the PhoneNumber objects associated with the user, including the primary."""

    web3_wallets: List[Web3Wallet]
    """An array of all the Web3Wallet objects associated with the user, including the primary."""

    saml_accounts: List[SAMLAccount]
    """An experimental list of SAML accounts associated with the user."""

    password_enabled: bool
    """A boolean indicating whether the user has a password on their account."""

    two_factor_enabled: bool
    """A boolean indicating whether the user has enabled two-factor authentication."""

    totp_enabled: bool
    """
    A boolean indicating whether the user has enabled TOTP by generating a TOTP secret
    and verifying it via an authenticator app.
    """

    backup_code_enabled: bool
    """A boolean indicating whether the user has enabled Backup codes."""

    last_sign_in_at: Optional[int] = None
    """The date when the user last signed in, may be empty if the user has never signed in."""

    banned: bool
    """A boolean indicating whether the user is banned."""

    locked: bool
    """A boolean indicating whether the user is locked."""

reflex_clerk.clerk_client.clerk_response_models.PasskeyResource

Bases: BaseModel

Represents a passkey associated with a user response.

Attributes:

  • id (str) –

    The passkey's unique ID generated by Clerk.

  • verification (Verification) –

    Verification details for the passkey.

  • name (str) –

    The passkey's name.

  • created_at (str) –

    The date and time when the passkey was created.

  • updated_at (str) –

    The date and time when the passkey was updated.

  • last_used_at (str) –

    The date and time when the passkey was last used.

Source code in custom_components/reflex_clerk/clerk_client/clerk_response_models.py
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
class PasskeyResource(BaseModel):
    """
    Represents a passkey associated with a user response.

    Attributes:
        id: The passkey's unique ID generated by Clerk.
        verification: Verification details for the passkey.
        name: The passkey's name.
        created_at: The date and time when the passkey was created.
        updated_at: The date and time when the passkey was updated.
        last_used_at: The date and time when the passkey was last used.

    """

    id: str
    """The passkey's unique ID generated by Clerk."""

    verification: Verification
    """Verification details for the passkey."""

    name: str
    """The passkey's name."""

    created_at: str
    """The date and time when the passkey was created."""

    updated_at: str
    """The date and time when the passkey was updated."""

    last_used_at: str
    """The date and time when the passkey was last used."""

reflex_clerk.clerk_client.clerk_response_models.EmailAddress

Bases: BaseModel

Represents an email address associated with a user.

Attributes:

  • id (str) –

    A unique identifier for this email address.

  • email_address (str) –

    The value of this email address.

  • verification (Optional[Verification]) –

    An object holding information on the verification of this email address.

  • linked_to (List[IdentificationLink]) –

    An array of objects containing information about any identifications that might be linked to this email address.

  • created_at (int) –

    Unix timestamp of creation

  • updated_at (int) –

    Unix timestamp of latest update

Source code in custom_components/reflex_clerk/clerk_client/clerk_response_models.py
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
class EmailAddress(BaseModel):
    """
    Represents an email address associated with a user.

    Attributes:
        id: A unique identifier for this email address.
        email_address: The value of this email address.
        verification: An object holding information on the verification of this email address.
        linked_to: An array of objects containing information about any identifications that might be linked to this email address.
        created_at: Unix timestamp of creation
        updated_at: Unix timestamp of latest update
    """
    id: str
    object: Literal['email_address']
    email_address: str
    reserved: bool
    verification: Optional[Verification] = None
    linked_to: List[IdentificationLink]
    created_at: int
    updated_at: int

reflex_clerk.clerk_client.clerk_response_models.PhoneNumber

Bases: BaseModel

Represents a phone number associated with a user.

Attributes:

  • id (str) –

    A unique identifier for this phone number.

  • phone_number (str) –

    The value of this phone number, in E.164 format ⧉.

  • reserved_for_second_factor (Optional[bool]) –

    Set to true if this phone number is reserved for multi-factor authentication (2FA). Set to false otherwise.

  • default_second_factor (Optional[bool]) –

    Marks this phone number as the default second factor for multi-factor authentication(2FA). A user can have exactly one default second factor.

  • verification (Optional[Verification]) –

    An object holding information on the verification of this phone number.

  • linked_to (List[IdentificationLink]) –

    An object containing information about any other identification that might be linked to this phone number.

  • created_at (int) –

    Unix timestamp of creation

  • updated_at (int) –

    Unix timestamp of latest update

Source code in custom_components/reflex_clerk/clerk_client/clerk_response_models.py
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
class PhoneNumber(BaseModel):
    """
    Represents a phone number associated with a user.

    Attributes:
        id: A unique identifier for this phone number.
        phone_number: The value of this phone number, in [E.164 format](https://en.wikipedia.org/wiki/E.164).
        reserved_for_second_factor: Set to true if this phone number is reserved for multi-factor authentication (2FA). Set to false otherwise.
        default_second_factor: Marks this phone number as the default second factor for multi-factor authentication(2FA). A user can have exactly one default second factor.
        verification: An object holding information on the verification of this phone number.
        linked_to: An object containing information about any other identification that might be linked to this phone number.
        created_at: Unix timestamp of creation
        updated_at: Unix timestamp of latest update
    """
    id: str
    object: Literal['phone_number']
    phone_number: str
    reserved_for_second_factor: Optional[bool]
    default_second_factor: Optional[bool]
    reserved: bool
    verification: Optional[Verification] = None
    linked_to: List[IdentificationLink]
    backup_codes: Optional[List[str]] = None
    created_at: int
    updated_at: int

reflex_clerk.clerk_client.clerk_response_models.Web3Wallet

Bases: BaseModel

Represents a Web3 wallet address associated with a user.

The address can be used as a proof of identification for users.

Web3 addresses must be verified to ensure that they can be assigned to their rightful owners. The verification is completed via Web3 wallet browser extensions, such as Metamask ⧉. The Web3Wallet3 object holds all the necessary state around the verification process.

Attributes:

  • id (str) –

    A unique identifier for this web3 wallet.

  • web3_wallet (str) –

    In Ethereum ⧉, the address is made up of 0x + 40 hexadecimal characters.

  • created_at (int) –

    The date and time when the passkey was created.

  • updated_at (int) –

    The date and time when the passkey was updated.

Source code in custom_components/reflex_clerk/clerk_client/clerk_response_models.py
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
class Web3Wallet(BaseModel):
    """
    Represents a Web3 wallet address associated with a user.

    The address can be used as a proof of identification for users.

    Web3 addresses must be verified to ensure that they can be assigned
    to their rightful owners. The verification is completed via Web3 wallet
    browser extensions, such as [Metamask][1]. The Web3Wallet3 object holds all
    the necessary state around the verification process.

    [1]: https://metamask.io/

    Attributes:
        id: A unique identifier for this web3 wallet.
        web3_wallet: In [Ethereum](https://docs.metamask.io/guide/common-terms.html#address-public-key),
                     the address is made up of 0x + 40 hexadecimal characters.
        created_at: The date and time when the passkey was created.
        updated_at: The date and time when the passkey was updated.
    """
    id: str
    web3_wallet: str
    created_at: int
    updated_at: int
    verification: Optional[Verification] = None

reflex_clerk.clerk_client.clerk_response_models.SAMLAccount

Bases: BaseModel

Represents a SAML account associated with a user.

Attributes:

  • id (str) –

    A unique identifier for the SAML account.

  • object (str) –

    The type of object, typically 'saml_account'.

  • provider (str) –

    The SAML provider associated with the account.

  • active (bool) –

    A boolean indicating whether the SAML account is active.

  • email_address (str) –

    The email address associated with the SAML account.

  • first_name (Optional[str]) –

    The first name of the user associated with the SAML account.

  • last_name (Optional[str]) –

    The last name of the user associated with the SAML account.

  • provider_user_id (Optional[str]) –

    An optional identifier for the user within the SAML provider.

  • public_metadata (Dict[str, Any]) –

    Metadata for the SAML account.

  • verification (Optional[Verification]) –

    An optional verification object associated with the SAML account.

Source code in custom_components/reflex_clerk/clerk_client/clerk_response_models.py
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
class SAMLAccount(BaseModel):
    """
    Represents a SAML account associated with a user.

    Attributes:
        id: A unique identifier for the SAML account.
        object: The type of object, typically 'saml_account'.
        provider: The SAML provider associated with the account.
        active: A boolean indicating whether the SAML account is active.
        email_address: The email address associated with the SAML account.
        first_name: The first name of the user associated with the SAML account.
        last_name: The last name of the user associated with the SAML account.
        provider_user_id: An optional identifier for the user within the SAML provider.
        public_metadata: Metadata for the SAML account.
        verification: An optional verification object associated with the SAML account.
    """
    id: str
    object: str
    provider: str
    active: bool
    email_address: str
    first_name: Optional[str] = None
    last_name: Optional[str] = None
    provider_user_id: Optional[str] = None
    public_metadata: Dict[str, Any]
    verification: Optional[Verification] = None

reflex_clerk.clerk_client.clerk_response_models.Verification

Bases: BaseModel

Represents the verification details of an email address or phone number.

Attributes:

  • strategy (Optional[Literal['oauth_google', 'oauth_mock', 'admin', 'phone_code', 'email_code', 'reset_password_email_code', 'web3_metamask_signature']]) –

    The strategy pertaining to the parent sign-up or sign-in attempt.

  • status (Optional[Literal['unverified', 'verified', 'transferable', 'failed', 'expired']]) –

    The state of the verification.

  • attempts (Optional[int]) –

    The number of attempts related to the verification.

  • expire_at (Optional[int]) –

    The time the verification will expire at.

Source code in custom_components/reflex_clerk/clerk_client/clerk_response_models.py
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
class Verification(BaseModel):
    """
    Represents the verification details of an email address or phone number.

    Attributes:
        strategy: The strategy pertaining to the parent sign-up or sign-in attempt.
        status: The state of the verification.
        attempts: The number of attempts related to the verification.
        expire_at: The time the verification will expire at.
    """
    strategy: Optional[
        Literal[
            "oauth_google", "oauth_mock", "admin",
            "phone_code", "email_code", "reset_password_email_code",
            "web3_metamask_signature"
        ]]
    status: Optional[Literal['unverified', 'verified', 'transferable', 'failed', 'expired']]
    nonce: Optional[str] = None
    attempts: Optional[int] = None
    expire_at: Optional[int] = None
    error: Optional[ClerkError] = None
    external_verification_redirect_url: Optional[str] = None

Bases: BaseModel

Represents a link between an email address or phone number and another identification type.

Attributes:

  • type (Literal['oauth_google', 'oauth_mock', 'saml']) –

    One of "oauth_google", "oauth_mock", or "saml"

  • id (str) –

    A unique identifier for this link.

Source code in custom_components/reflex_clerk/clerk_client/clerk_response_models.py
55
56
57
58
59
60
61
62
63
64
class IdentificationLink(BaseModel):
    """
    Represents a link between an email address or phone number and another identification type.

    Attributes:
        type: One of "oauth_google", "oauth_mock", or "saml"
        id: A unique identifier for this link.
    """
    type: Literal["oauth_google", "oauth_mock", "saml"]
    id: str