mithwire 0.50.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mithwire/__init__.py +32 -0
- mithwire/cdp/README.md +4 -0
- mithwire/cdp/__init__.py +6 -0
- mithwire/cdp/accessibility.py +668 -0
- mithwire/cdp/animation.py +494 -0
- mithwire/cdp/audits.py +1995 -0
- mithwire/cdp/autofill.py +292 -0
- mithwire/cdp/background_service.py +215 -0
- mithwire/cdp/bluetooth_emulation.py +626 -0
- mithwire/cdp/browser.py +821 -0
- mithwire/cdp/cache_storage.py +311 -0
- mithwire/cdp/cast.py +172 -0
- mithwire/cdp/console.py +107 -0
- mithwire/cdp/crash_report_context.py +55 -0
- mithwire/cdp/css.py +2750 -0
- mithwire/cdp/database.py +179 -0
- mithwire/cdp/debugger.py +1405 -0
- mithwire/cdp/device_access.py +141 -0
- mithwire/cdp/device_orientation.py +45 -0
- mithwire/cdp/dom.py +2257 -0
- mithwire/cdp/dom_debugger.py +321 -0
- mithwire/cdp/dom_snapshot.py +876 -0
- mithwire/cdp/dom_storage.py +222 -0
- mithwire/cdp/emulation.py +1779 -0
- mithwire/cdp/event_breakpoints.py +56 -0
- mithwire/cdp/extensions.py +238 -0
- mithwire/cdp/fed_cm.py +283 -0
- mithwire/cdp/fetch.py +507 -0
- mithwire/cdp/file_system.py +115 -0
- mithwire/cdp/headless_experimental.py +115 -0
- mithwire/cdp/heap_profiler.py +401 -0
- mithwire/cdp/indexed_db.py +528 -0
- mithwire/cdp/input_.py +701 -0
- mithwire/cdp/inspector.py +95 -0
- mithwire/cdp/io.py +101 -0
- mithwire/cdp/layer_tree.py +464 -0
- mithwire/cdp/log.py +190 -0
- mithwire/cdp/media.py +313 -0
- mithwire/cdp/memory.py +305 -0
- mithwire/cdp/network.py +5342 -0
- mithwire/cdp/overlay.py +1468 -0
- mithwire/cdp/page.py +3972 -0
- mithwire/cdp/performance.py +124 -0
- mithwire/cdp/performance_timeline.py +200 -0
- mithwire/cdp/preload.py +575 -0
- mithwire/cdp/profiler.py +420 -0
- mithwire/cdp/pwa.py +278 -0
- mithwire/cdp/py.typed +0 -0
- mithwire/cdp/runtime.py +1589 -0
- mithwire/cdp/schema.py +50 -0
- mithwire/cdp/security.py +518 -0
- mithwire/cdp/service_worker.py +401 -0
- mithwire/cdp/smart_card_emulation.py +891 -0
- mithwire/cdp/storage.py +1573 -0
- mithwire/cdp/system_info.py +327 -0
- mithwire/cdp/target.py +829 -0
- mithwire/cdp/tethering.py +65 -0
- mithwire/cdp/tracing.py +377 -0
- mithwire/cdp/util.py +18 -0
- mithwire/cdp/web_audio.py +606 -0
- mithwire/cdp/web_authn.py +598 -0
- mithwire/cdp/web_mcp.py +293 -0
- mithwire/core/_contradict.py +142 -0
- mithwire/core/browser.py +923 -0
- mithwire/core/cf_templates/cf_dark_checkbox.png +0 -0
- mithwire/core/cf_templates/cf_light_checkbox.png +0 -0
- mithwire/core/config.py +323 -0
- mithwire/core/connection.py +564 -0
- mithwire/core/element.py +1205 -0
- mithwire/core/tab.py +2202 -0
- mithwire/core/util.py +5063 -0
- mithwire-0.50.3.dist-info/METADATA +1049 -0
- mithwire-0.50.3.dist-info/RECORD +76 -0
- mithwire-0.50.3.dist-info/WHEEL +5 -0
- mithwire-0.50.3.dist-info/licenses/LICENSE.txt +619 -0
- mithwire-0.50.3.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# DO NOT EDIT THIS FILE!
|
|
2
|
+
#
|
|
3
|
+
# This file is generated from the CDP specification. If you need to make
|
|
4
|
+
# changes, edit the generator and regenerate all of the modules.
|
|
5
|
+
#
|
|
6
|
+
# CDP domain: EventBreakpoints (experimental)
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
import enum
|
|
10
|
+
import typing
|
|
11
|
+
from dataclasses import dataclass
|
|
12
|
+
from .util import event_class, T_JSON_DICT
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def set_instrumentation_breakpoint(
|
|
16
|
+
event_name: str
|
|
17
|
+
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
|
18
|
+
'''
|
|
19
|
+
Sets breakpoint on particular native event.
|
|
20
|
+
|
|
21
|
+
:param event_name: Instrumentation name to stop on.
|
|
22
|
+
'''
|
|
23
|
+
params: T_JSON_DICT = dict()
|
|
24
|
+
params['eventName'] = event_name
|
|
25
|
+
cmd_dict: T_JSON_DICT = {
|
|
26
|
+
'method': 'EventBreakpoints.setInstrumentationBreakpoint',
|
|
27
|
+
'params': params,
|
|
28
|
+
}
|
|
29
|
+
json = yield cmd_dict
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def remove_instrumentation_breakpoint(
|
|
33
|
+
event_name: str
|
|
34
|
+
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
|
35
|
+
'''
|
|
36
|
+
Removes breakpoint on particular native event.
|
|
37
|
+
|
|
38
|
+
:param event_name: Instrumentation name to stop on.
|
|
39
|
+
'''
|
|
40
|
+
params: T_JSON_DICT = dict()
|
|
41
|
+
params['eventName'] = event_name
|
|
42
|
+
cmd_dict: T_JSON_DICT = {
|
|
43
|
+
'method': 'EventBreakpoints.removeInstrumentationBreakpoint',
|
|
44
|
+
'params': params,
|
|
45
|
+
}
|
|
46
|
+
json = yield cmd_dict
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
|
50
|
+
'''
|
|
51
|
+
Removes all breakpoints
|
|
52
|
+
'''
|
|
53
|
+
cmd_dict: T_JSON_DICT = {
|
|
54
|
+
'method': 'EventBreakpoints.disable',
|
|
55
|
+
}
|
|
56
|
+
json = yield cmd_dict
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
# DO NOT EDIT THIS FILE!
|
|
2
|
+
#
|
|
3
|
+
# This file is generated from the CDP specification. If you need to make
|
|
4
|
+
# changes, edit the generator and regenerate all of the modules.
|
|
5
|
+
#
|
|
6
|
+
# CDP domain: Extensions (experimental)
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
import enum
|
|
10
|
+
import typing
|
|
11
|
+
from dataclasses import dataclass
|
|
12
|
+
from .util import event_class, T_JSON_DICT
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class StorageArea(enum.Enum):
|
|
16
|
+
'''
|
|
17
|
+
Storage areas.
|
|
18
|
+
'''
|
|
19
|
+
SESSION = "session"
|
|
20
|
+
LOCAL = "local"
|
|
21
|
+
SYNC = "sync"
|
|
22
|
+
MANAGED = "managed"
|
|
23
|
+
|
|
24
|
+
def to_json(self) -> str:
|
|
25
|
+
return self.value
|
|
26
|
+
|
|
27
|
+
@classmethod
|
|
28
|
+
def from_json(cls, json: str) -> StorageArea:
|
|
29
|
+
return cls(json)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@dataclass
|
|
33
|
+
class ExtensionInfo:
|
|
34
|
+
'''
|
|
35
|
+
Detailed information about an extension.
|
|
36
|
+
'''
|
|
37
|
+
#: Extension id.
|
|
38
|
+
id_: str
|
|
39
|
+
|
|
40
|
+
#: Extension name.
|
|
41
|
+
name: str
|
|
42
|
+
|
|
43
|
+
#: Extension version.
|
|
44
|
+
version: str
|
|
45
|
+
|
|
46
|
+
#: The path from which the extension was loaded.
|
|
47
|
+
path: str
|
|
48
|
+
|
|
49
|
+
#: Extension enabled status.
|
|
50
|
+
enabled: bool
|
|
51
|
+
|
|
52
|
+
def to_json(self) -> T_JSON_DICT:
|
|
53
|
+
json: T_JSON_DICT = dict()
|
|
54
|
+
json['id'] = self.id_
|
|
55
|
+
json['name'] = self.name
|
|
56
|
+
json['version'] = self.version
|
|
57
|
+
json['path'] = self.path
|
|
58
|
+
json['enabled'] = self.enabled
|
|
59
|
+
return json
|
|
60
|
+
|
|
61
|
+
@classmethod
|
|
62
|
+
def from_json(cls, json: T_JSON_DICT) -> ExtensionInfo:
|
|
63
|
+
return cls(
|
|
64
|
+
id_=str(json['id']),
|
|
65
|
+
name=str(json['name']),
|
|
66
|
+
version=str(json['version']),
|
|
67
|
+
path=str(json['path']),
|
|
68
|
+
enabled=bool(json['enabled']),
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def trigger_action(
|
|
73
|
+
id_: str,
|
|
74
|
+
target_id: str
|
|
75
|
+
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
|
76
|
+
'''
|
|
77
|
+
Runs an extension default action.
|
|
78
|
+
|
|
79
|
+
:param id_: Extension id.
|
|
80
|
+
:param target_id: A tab target ID to trigger the default extension action on.
|
|
81
|
+
'''
|
|
82
|
+
params: T_JSON_DICT = dict()
|
|
83
|
+
params['id'] = id_
|
|
84
|
+
params['targetId'] = target_id
|
|
85
|
+
cmd_dict: T_JSON_DICT = {
|
|
86
|
+
'method': 'Extensions.triggerAction',
|
|
87
|
+
'params': params,
|
|
88
|
+
}
|
|
89
|
+
json = yield cmd_dict
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def load_unpacked(
|
|
93
|
+
path: str,
|
|
94
|
+
enable_in_incognito: typing.Optional[bool] = None
|
|
95
|
+
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,str]:
|
|
96
|
+
'''
|
|
97
|
+
Installs an unpacked extension from the filesystem similar to
|
|
98
|
+
--load-extension CLI flags. Returns extension ID once the extension
|
|
99
|
+
has been installed.
|
|
100
|
+
|
|
101
|
+
:param path: Absolute file path.
|
|
102
|
+
:param enable_in_incognito: *(Optional)* Enable the extension in incognito
|
|
103
|
+
:returns: Extension id.
|
|
104
|
+
'''
|
|
105
|
+
params: T_JSON_DICT = dict()
|
|
106
|
+
params['path'] = path
|
|
107
|
+
if enable_in_incognito is not None:
|
|
108
|
+
params['enableInIncognito'] = enable_in_incognito
|
|
109
|
+
cmd_dict: T_JSON_DICT = {
|
|
110
|
+
'method': 'Extensions.loadUnpacked',
|
|
111
|
+
'params': params,
|
|
112
|
+
}
|
|
113
|
+
json = yield cmd_dict
|
|
114
|
+
return str(json['id'])
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def get_extensions() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[ExtensionInfo]]:
|
|
118
|
+
'''
|
|
119
|
+
Gets a list of all unpacked extensions.
|
|
120
|
+
|
|
121
|
+
:returns:
|
|
122
|
+
'''
|
|
123
|
+
cmd_dict: T_JSON_DICT = {
|
|
124
|
+
'method': 'Extensions.getExtensions',
|
|
125
|
+
}
|
|
126
|
+
json = yield cmd_dict
|
|
127
|
+
return [ExtensionInfo.from_json(i) for i in json['extensions']]
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def uninstall(
|
|
131
|
+
id_: str
|
|
132
|
+
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
|
133
|
+
'''
|
|
134
|
+
Uninstalls an unpacked extension (others not supported) from the profile.
|
|
135
|
+
|
|
136
|
+
:param id_: Extension id.
|
|
137
|
+
'''
|
|
138
|
+
params: T_JSON_DICT = dict()
|
|
139
|
+
params['id'] = id_
|
|
140
|
+
cmd_dict: T_JSON_DICT = {
|
|
141
|
+
'method': 'Extensions.uninstall',
|
|
142
|
+
'params': params,
|
|
143
|
+
}
|
|
144
|
+
json = yield cmd_dict
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def get_storage_items(
|
|
148
|
+
id_: str,
|
|
149
|
+
storage_area: StorageArea,
|
|
150
|
+
keys: typing.Optional[typing.List[str]] = None
|
|
151
|
+
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,dict]:
|
|
152
|
+
'''
|
|
153
|
+
Gets data from extension storage in the given ``storageArea``. If ``keys`` is
|
|
154
|
+
specified, these are used to filter the result.
|
|
155
|
+
|
|
156
|
+
:param id_: ID of extension.
|
|
157
|
+
:param storage_area: StorageArea to retrieve data from.
|
|
158
|
+
:param keys: *(Optional)* Keys to retrieve.
|
|
159
|
+
:returns:
|
|
160
|
+
'''
|
|
161
|
+
params: T_JSON_DICT = dict()
|
|
162
|
+
params['id'] = id_
|
|
163
|
+
params['storageArea'] = storage_area.to_json()
|
|
164
|
+
if keys is not None:
|
|
165
|
+
params['keys'] = [i for i in keys]
|
|
166
|
+
cmd_dict: T_JSON_DICT = {
|
|
167
|
+
'method': 'Extensions.getStorageItems',
|
|
168
|
+
'params': params,
|
|
169
|
+
}
|
|
170
|
+
json = yield cmd_dict
|
|
171
|
+
return dict(json['data'])
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def remove_storage_items(
|
|
175
|
+
id_: str,
|
|
176
|
+
storage_area: StorageArea,
|
|
177
|
+
keys: typing.List[str]
|
|
178
|
+
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
|
179
|
+
'''
|
|
180
|
+
Removes ``keys`` from extension storage in the given ``storageArea``.
|
|
181
|
+
|
|
182
|
+
:param id_: ID of extension.
|
|
183
|
+
:param storage_area: StorageArea to remove data from.
|
|
184
|
+
:param keys: Keys to remove.
|
|
185
|
+
'''
|
|
186
|
+
params: T_JSON_DICT = dict()
|
|
187
|
+
params['id'] = id_
|
|
188
|
+
params['storageArea'] = storage_area.to_json()
|
|
189
|
+
params['keys'] = [i for i in keys]
|
|
190
|
+
cmd_dict: T_JSON_DICT = {
|
|
191
|
+
'method': 'Extensions.removeStorageItems',
|
|
192
|
+
'params': params,
|
|
193
|
+
}
|
|
194
|
+
json = yield cmd_dict
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def clear_storage_items(
|
|
198
|
+
id_: str,
|
|
199
|
+
storage_area: StorageArea
|
|
200
|
+
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
|
201
|
+
'''
|
|
202
|
+
Clears extension storage in the given ``storageArea``.
|
|
203
|
+
|
|
204
|
+
:param id_: ID of extension.
|
|
205
|
+
:param storage_area: StorageArea to remove data from.
|
|
206
|
+
'''
|
|
207
|
+
params: T_JSON_DICT = dict()
|
|
208
|
+
params['id'] = id_
|
|
209
|
+
params['storageArea'] = storage_area.to_json()
|
|
210
|
+
cmd_dict: T_JSON_DICT = {
|
|
211
|
+
'method': 'Extensions.clearStorageItems',
|
|
212
|
+
'params': params,
|
|
213
|
+
}
|
|
214
|
+
json = yield cmd_dict
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def set_storage_items(
|
|
218
|
+
id_: str,
|
|
219
|
+
storage_area: StorageArea,
|
|
220
|
+
values: dict
|
|
221
|
+
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
|
222
|
+
'''
|
|
223
|
+
Sets ``values`` in extension storage in the given ``storageArea``. The provided ``values``
|
|
224
|
+
will be merged with existing values in the storage area.
|
|
225
|
+
|
|
226
|
+
:param id_: ID of extension.
|
|
227
|
+
:param storage_area: StorageArea to set data in.
|
|
228
|
+
:param values: Values to set.
|
|
229
|
+
'''
|
|
230
|
+
params: T_JSON_DICT = dict()
|
|
231
|
+
params['id'] = id_
|
|
232
|
+
params['storageArea'] = storage_area.to_json()
|
|
233
|
+
params['values'] = values
|
|
234
|
+
cmd_dict: T_JSON_DICT = {
|
|
235
|
+
'method': 'Extensions.setStorageItems',
|
|
236
|
+
'params': params,
|
|
237
|
+
}
|
|
238
|
+
json = yield cmd_dict
|
mithwire/cdp/fed_cm.py
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
# DO NOT EDIT THIS FILE!
|
|
2
|
+
#
|
|
3
|
+
# This file is generated from the CDP specification. If you need to make
|
|
4
|
+
# changes, edit the generator and regenerate all of the modules.
|
|
5
|
+
#
|
|
6
|
+
# CDP domain: FedCm (experimental)
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
import enum
|
|
10
|
+
import typing
|
|
11
|
+
from dataclasses import dataclass
|
|
12
|
+
from .util import event_class, T_JSON_DICT
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class LoginState(enum.Enum):
|
|
16
|
+
'''
|
|
17
|
+
Whether this is a sign-up or sign-in action for this account, i.e.
|
|
18
|
+
whether this account has ever been used to sign in to this RP before.
|
|
19
|
+
'''
|
|
20
|
+
SIGN_IN = "SignIn"
|
|
21
|
+
SIGN_UP = "SignUp"
|
|
22
|
+
|
|
23
|
+
def to_json(self) -> str:
|
|
24
|
+
return self.value
|
|
25
|
+
|
|
26
|
+
@classmethod
|
|
27
|
+
def from_json(cls, json: str) -> LoginState:
|
|
28
|
+
return cls(json)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class DialogType(enum.Enum):
|
|
32
|
+
'''
|
|
33
|
+
The types of FedCM dialogs.
|
|
34
|
+
'''
|
|
35
|
+
ACCOUNT_CHOOSER = "AccountChooser"
|
|
36
|
+
AUTO_REAUTHN = "AutoReauthn"
|
|
37
|
+
CONFIRM_IDP_LOGIN = "ConfirmIdpLogin"
|
|
38
|
+
ERROR = "Error"
|
|
39
|
+
|
|
40
|
+
def to_json(self) -> str:
|
|
41
|
+
return self.value
|
|
42
|
+
|
|
43
|
+
@classmethod
|
|
44
|
+
def from_json(cls, json: str) -> DialogType:
|
|
45
|
+
return cls(json)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class DialogButton(enum.Enum):
|
|
49
|
+
'''
|
|
50
|
+
The buttons on the FedCM dialog.
|
|
51
|
+
'''
|
|
52
|
+
CONFIRM_IDP_LOGIN_CONTINUE = "ConfirmIdpLoginContinue"
|
|
53
|
+
ERROR_GOT_IT = "ErrorGotIt"
|
|
54
|
+
ERROR_MORE_DETAILS = "ErrorMoreDetails"
|
|
55
|
+
|
|
56
|
+
def to_json(self) -> str:
|
|
57
|
+
return self.value
|
|
58
|
+
|
|
59
|
+
@classmethod
|
|
60
|
+
def from_json(cls, json: str) -> DialogButton:
|
|
61
|
+
return cls(json)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class AccountUrlType(enum.Enum):
|
|
65
|
+
'''
|
|
66
|
+
The URLs that each account has
|
|
67
|
+
'''
|
|
68
|
+
TERMS_OF_SERVICE = "TermsOfService"
|
|
69
|
+
PRIVACY_POLICY = "PrivacyPolicy"
|
|
70
|
+
|
|
71
|
+
def to_json(self) -> str:
|
|
72
|
+
return self.value
|
|
73
|
+
|
|
74
|
+
@classmethod
|
|
75
|
+
def from_json(cls, json: str) -> AccountUrlType:
|
|
76
|
+
return cls(json)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@dataclass
|
|
80
|
+
class Account:
|
|
81
|
+
'''
|
|
82
|
+
Corresponds to IdentityRequestAccount
|
|
83
|
+
'''
|
|
84
|
+
account_id: str
|
|
85
|
+
|
|
86
|
+
email: str
|
|
87
|
+
|
|
88
|
+
name: str
|
|
89
|
+
|
|
90
|
+
given_name: str
|
|
91
|
+
|
|
92
|
+
picture_url: str
|
|
93
|
+
|
|
94
|
+
idp_config_url: str
|
|
95
|
+
|
|
96
|
+
idp_login_url: str
|
|
97
|
+
|
|
98
|
+
login_state: LoginState
|
|
99
|
+
|
|
100
|
+
#: These two are only set if the loginState is signUp
|
|
101
|
+
terms_of_service_url: typing.Optional[str] = None
|
|
102
|
+
|
|
103
|
+
privacy_policy_url: typing.Optional[str] = None
|
|
104
|
+
|
|
105
|
+
def to_json(self) -> T_JSON_DICT:
|
|
106
|
+
json: T_JSON_DICT = dict()
|
|
107
|
+
json['accountId'] = self.account_id
|
|
108
|
+
json['email'] = self.email
|
|
109
|
+
json['name'] = self.name
|
|
110
|
+
json['givenName'] = self.given_name
|
|
111
|
+
json['pictureUrl'] = self.picture_url
|
|
112
|
+
json['idpConfigUrl'] = self.idp_config_url
|
|
113
|
+
json['idpLoginUrl'] = self.idp_login_url
|
|
114
|
+
json['loginState'] = self.login_state.to_json()
|
|
115
|
+
if self.terms_of_service_url is not None:
|
|
116
|
+
json['termsOfServiceUrl'] = self.terms_of_service_url
|
|
117
|
+
if self.privacy_policy_url is not None:
|
|
118
|
+
json['privacyPolicyUrl'] = self.privacy_policy_url
|
|
119
|
+
return json
|
|
120
|
+
|
|
121
|
+
@classmethod
|
|
122
|
+
def from_json(cls, json: T_JSON_DICT) -> Account:
|
|
123
|
+
return cls(
|
|
124
|
+
account_id=str(json['accountId']),
|
|
125
|
+
email=str(json['email']),
|
|
126
|
+
name=str(json['name']),
|
|
127
|
+
given_name=str(json['givenName']),
|
|
128
|
+
picture_url=str(json['pictureUrl']),
|
|
129
|
+
idp_config_url=str(json['idpConfigUrl']),
|
|
130
|
+
idp_login_url=str(json['idpLoginUrl']),
|
|
131
|
+
login_state=LoginState.from_json(json['loginState']),
|
|
132
|
+
terms_of_service_url=str(json['termsOfServiceUrl']) if json.get('termsOfServiceUrl', None) is not None else None,
|
|
133
|
+
privacy_policy_url=str(json['privacyPolicyUrl']) if json.get('privacyPolicyUrl', None) is not None else None,
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def enable(
|
|
138
|
+
disable_rejection_delay: typing.Optional[bool] = None
|
|
139
|
+
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
|
140
|
+
'''
|
|
141
|
+
:param disable_rejection_delay: *(Optional)* Allows callers to disable the promise rejection delay that would normally happen, if this is unimportant to what's being tested. (step 4 of https://fedidcg.github.io/FedCM/#browser-api-rp-sign-in)
|
|
142
|
+
'''
|
|
143
|
+
params: T_JSON_DICT = dict()
|
|
144
|
+
if disable_rejection_delay is not None:
|
|
145
|
+
params['disableRejectionDelay'] = disable_rejection_delay
|
|
146
|
+
cmd_dict: T_JSON_DICT = {
|
|
147
|
+
'method': 'FedCm.enable',
|
|
148
|
+
'params': params,
|
|
149
|
+
}
|
|
150
|
+
json = yield cmd_dict
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
|
154
|
+
|
|
155
|
+
cmd_dict: T_JSON_DICT = {
|
|
156
|
+
'method': 'FedCm.disable',
|
|
157
|
+
}
|
|
158
|
+
json = yield cmd_dict
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def select_account(
|
|
162
|
+
dialog_id: str,
|
|
163
|
+
account_index: int
|
|
164
|
+
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
|
165
|
+
'''
|
|
166
|
+
:param dialog_id:
|
|
167
|
+
:param account_index:
|
|
168
|
+
'''
|
|
169
|
+
params: T_JSON_DICT = dict()
|
|
170
|
+
params['dialogId'] = dialog_id
|
|
171
|
+
params['accountIndex'] = account_index
|
|
172
|
+
cmd_dict: T_JSON_DICT = {
|
|
173
|
+
'method': 'FedCm.selectAccount',
|
|
174
|
+
'params': params,
|
|
175
|
+
}
|
|
176
|
+
json = yield cmd_dict
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def click_dialog_button(
|
|
180
|
+
dialog_id: str,
|
|
181
|
+
dialog_button: DialogButton
|
|
182
|
+
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
|
183
|
+
'''
|
|
184
|
+
:param dialog_id:
|
|
185
|
+
:param dialog_button:
|
|
186
|
+
'''
|
|
187
|
+
params: T_JSON_DICT = dict()
|
|
188
|
+
params['dialogId'] = dialog_id
|
|
189
|
+
params['dialogButton'] = dialog_button.to_json()
|
|
190
|
+
cmd_dict: T_JSON_DICT = {
|
|
191
|
+
'method': 'FedCm.clickDialogButton',
|
|
192
|
+
'params': params,
|
|
193
|
+
}
|
|
194
|
+
json = yield cmd_dict
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def open_url(
|
|
198
|
+
dialog_id: str,
|
|
199
|
+
account_index: int,
|
|
200
|
+
account_url_type: AccountUrlType
|
|
201
|
+
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
|
202
|
+
'''
|
|
203
|
+
:param dialog_id:
|
|
204
|
+
:param account_index:
|
|
205
|
+
:param account_url_type:
|
|
206
|
+
'''
|
|
207
|
+
params: T_JSON_DICT = dict()
|
|
208
|
+
params['dialogId'] = dialog_id
|
|
209
|
+
params['accountIndex'] = account_index
|
|
210
|
+
params['accountUrlType'] = account_url_type.to_json()
|
|
211
|
+
cmd_dict: T_JSON_DICT = {
|
|
212
|
+
'method': 'FedCm.openUrl',
|
|
213
|
+
'params': params,
|
|
214
|
+
}
|
|
215
|
+
json = yield cmd_dict
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def dismiss_dialog(
|
|
219
|
+
dialog_id: str,
|
|
220
|
+
trigger_cooldown: typing.Optional[bool] = None
|
|
221
|
+
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
|
222
|
+
'''
|
|
223
|
+
:param dialog_id:
|
|
224
|
+
:param trigger_cooldown: *(Optional)*
|
|
225
|
+
'''
|
|
226
|
+
params: T_JSON_DICT = dict()
|
|
227
|
+
params['dialogId'] = dialog_id
|
|
228
|
+
if trigger_cooldown is not None:
|
|
229
|
+
params['triggerCooldown'] = trigger_cooldown
|
|
230
|
+
cmd_dict: T_JSON_DICT = {
|
|
231
|
+
'method': 'FedCm.dismissDialog',
|
|
232
|
+
'params': params,
|
|
233
|
+
}
|
|
234
|
+
json = yield cmd_dict
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def reset_cooldown() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
|
238
|
+
'''
|
|
239
|
+
Resets the cooldown time, if any, to allow the next FedCM call to show
|
|
240
|
+
a dialog even if one was recently dismissed by the user.
|
|
241
|
+
'''
|
|
242
|
+
cmd_dict: T_JSON_DICT = {
|
|
243
|
+
'method': 'FedCm.resetCooldown',
|
|
244
|
+
}
|
|
245
|
+
json = yield cmd_dict
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
@event_class('FedCm.dialogShown')
|
|
249
|
+
@dataclass
|
|
250
|
+
class DialogShown:
|
|
251
|
+
dialog_id: str
|
|
252
|
+
dialog_type: DialogType
|
|
253
|
+
accounts: typing.List[Account]
|
|
254
|
+
#: These exist primarily so that the caller can verify the
|
|
255
|
+
#: RP context was used appropriately.
|
|
256
|
+
title: str
|
|
257
|
+
subtitle: typing.Optional[str]
|
|
258
|
+
|
|
259
|
+
@classmethod
|
|
260
|
+
def from_json(cls, json: T_JSON_DICT) -> DialogShown:
|
|
261
|
+
return cls(
|
|
262
|
+
dialog_id=str(json['dialogId']),
|
|
263
|
+
dialog_type=DialogType.from_json(json['dialogType']),
|
|
264
|
+
accounts=[Account.from_json(i) for i in json['accounts']],
|
|
265
|
+
title=str(json['title']),
|
|
266
|
+
subtitle=str(json['subtitle']) if json.get('subtitle', None) is not None else None
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
@event_class('FedCm.dialogClosed')
|
|
271
|
+
@dataclass
|
|
272
|
+
class DialogClosed:
|
|
273
|
+
'''
|
|
274
|
+
Triggered when a dialog is closed, either by user action, JS abort,
|
|
275
|
+
or a command below.
|
|
276
|
+
'''
|
|
277
|
+
dialog_id: str
|
|
278
|
+
|
|
279
|
+
@classmethod
|
|
280
|
+
def from_json(cls, json: T_JSON_DICT) -> DialogClosed:
|
|
281
|
+
return cls(
|
|
282
|
+
dialog_id=str(json['dialogId'])
|
|
283
|
+
)
|