Path: blob/trunk/py/selenium/webdriver/common/fedcm/account.py
1864 views
# Licensed to the Software Freedom Conservancy (SFC) under one1# or more contributor license agreements. See the NOTICE file2# distributed with this work for additional information3# regarding copyright ownership. The SFC licenses this file4# to you under the Apache License, Version 2.0 (the5# "License"); you may not use this file except in compliance6# with the License. You may obtain a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing,11# software distributed under the License is distributed on an12# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13# KIND, either express or implied. See the License for the14# specific language governing permissions and limitations15# under the License.1617from enum import Enum18from typing import Optional192021class LoginState(Enum):22SIGN_IN = "SignIn"23SIGN_UP = "SignUp"242526class _AccountDescriptor:27def __init__(self, name):28self.name = name2930def __get__(self, obj, cls) -> Optional[str]:31return obj._account_data.get(self.name)3233def __set__(self, obj, value) -> None:34raise AttributeError("Cannot set readonly attribute")353637class Account:38"""Represents an account displayed in a FedCM account list.3940See: https://w3c-fedid.github.io/FedCM/#dictdef-identityprovideraccount41https://w3c-fedid.github.io/FedCM/#webdriver-accountlist42"""4344account_id = _AccountDescriptor("accountId")45email = _AccountDescriptor("email")46name = _AccountDescriptor("name")47given_name = _AccountDescriptor("givenName")48picture_url = _AccountDescriptor("pictureUrl")49idp_config_url = _AccountDescriptor("idpConfigUrl")50terms_of_service_url = _AccountDescriptor("termsOfServiceUrl")51privacy_policy_url = _AccountDescriptor("privacyPolicyUrl")52login_state = _AccountDescriptor("loginState")5354def __init__(self, account_data):55self._account_data = account_data565758