Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/py/selenium/webdriver/common/fedcm/account.py
4058 views
1
# Licensed to the Software Freedom Conservancy (SFC) under one
2
# or more contributor license agreements. See the NOTICE file
3
# distributed with this work for additional information
4
# regarding copyright ownership. The SFC licenses this file
5
# to you under the Apache License, Version 2.0 (the
6
# "License"); you may not use this file except in compliance
7
# with the License. You may obtain a copy of the License at
8
#
9
# http://www.apache.org/licenses/LICENSE-2.0
10
#
11
# Unless required by applicable law or agreed to in writing,
12
# software distributed under the License is distributed on an
13
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
# KIND, either express or implied. See the License for the
15
# specific language governing permissions and limitations
16
# under the License.
17
18
from enum import Enum
19
20
21
class LoginState(Enum):
22
SIGN_IN = "SignIn"
23
SIGN_UP = "SignUp"
24
25
26
class _AccountDescriptor:
27
def __init__(self, name):
28
self.name = name
29
30
def __get__(self, obj, cls) -> str | None:
31
return obj._account_data.get(self.name)
32
33
def __set__(self, obj, value) -> None:
34
raise AttributeError("Cannot set readonly attribute")
35
36
37
class Account:
38
"""Represents an account displayed in a FedCM account list.
39
40
See: https://w3c-fedid.github.io/FedCM/#dictdef-identityprovideraccount
41
https://w3c-fedid.github.io/FedCM/#webdriver-accountlist
42
"""
43
44
account_id = _AccountDescriptor("accountId")
45
email = _AccountDescriptor("email")
46
name = _AccountDescriptor("name")
47
given_name = _AccountDescriptor("givenName")
48
picture_url = _AccountDescriptor("pictureUrl")
49
idp_config_url = _AccountDescriptor("idpConfigUrl")
50
terms_of_service_url = _AccountDescriptor("termsOfServiceUrl")
51
privacy_policy_url = _AccountDescriptor("privacyPolicyUrl")
52
login_state = _AccountDescriptor("loginState")
53
54
def __init__(self, account_data):
55
self._account_data = account_data
56
57