Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/py/selenium/webdriver/common/fedcm/account.py
1864 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
from typing import Optional
20
21
22
class LoginState(Enum):
23
SIGN_IN = "SignIn"
24
SIGN_UP = "SignUp"
25
26
27
class _AccountDescriptor:
28
def __init__(self, name):
29
self.name = name
30
31
def __get__(self, obj, cls) -> Optional[str]:
32
return obj._account_data.get(self.name)
33
34
def __set__(self, obj, value) -> None:
35
raise AttributeError("Cannot set readonly attribute")
36
37
38
class Account:
39
"""Represents an account displayed in a FedCM account list.
40
41
See: https://w3c-fedid.github.io/FedCM/#dictdef-identityprovideraccount
42
https://w3c-fedid.github.io/FedCM/#webdriver-accountlist
43
"""
44
45
account_id = _AccountDescriptor("accountId")
46
email = _AccountDescriptor("email")
47
name = _AccountDescriptor("name")
48
given_name = _AccountDescriptor("givenName")
49
picture_url = _AccountDescriptor("pictureUrl")
50
idp_config_url = _AccountDescriptor("idpConfigUrl")
51
terms_of_service_url = _AccountDescriptor("termsOfServiceUrl")
52
privacy_policy_url = _AccountDescriptor("privacyPolicyUrl")
53
login_state = _AccountDescriptor("loginState")
54
55
def __init__(self, account_data):
56
self._account_data = account_data
57
58