Path: blob/trunk/py/selenium/webdriver/common/fedcm/account.py
4058 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 Enum181920class LoginState(Enum):21SIGN_IN = "SignIn"22SIGN_UP = "SignUp"232425class _AccountDescriptor:26def __init__(self, name):27self.name = name2829def __get__(self, obj, cls) -> str | None:30return obj._account_data.get(self.name)3132def __set__(self, obj, value) -> None:33raise AttributeError("Cannot set readonly attribute")343536class Account:37"""Represents an account displayed in a FedCM account list.3839See: https://w3c-fedid.github.io/FedCM/#dictdef-identityprovideraccount40https://w3c-fedid.github.io/FedCM/#webdriver-accountlist41"""4243account_id = _AccountDescriptor("accountId")44email = _AccountDescriptor("email")45name = _AccountDescriptor("name")46given_name = _AccountDescriptor("givenName")47picture_url = _AccountDescriptor("pictureUrl")48idp_config_url = _AccountDescriptor("idpConfigUrl")49terms_of_service_url = _AccountDescriptor("termsOfServiceUrl")50privacy_policy_url = _AccountDescriptor("privacyPolicyUrl")51login_state = _AccountDescriptor("loginState")5253def __init__(self, account_data):54self._account_data = account_data555657