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.
Files changed (76) hide show
  1. mithwire/__init__.py +32 -0
  2. mithwire/cdp/README.md +4 -0
  3. mithwire/cdp/__init__.py +6 -0
  4. mithwire/cdp/accessibility.py +668 -0
  5. mithwire/cdp/animation.py +494 -0
  6. mithwire/cdp/audits.py +1995 -0
  7. mithwire/cdp/autofill.py +292 -0
  8. mithwire/cdp/background_service.py +215 -0
  9. mithwire/cdp/bluetooth_emulation.py +626 -0
  10. mithwire/cdp/browser.py +821 -0
  11. mithwire/cdp/cache_storage.py +311 -0
  12. mithwire/cdp/cast.py +172 -0
  13. mithwire/cdp/console.py +107 -0
  14. mithwire/cdp/crash_report_context.py +55 -0
  15. mithwire/cdp/css.py +2750 -0
  16. mithwire/cdp/database.py +179 -0
  17. mithwire/cdp/debugger.py +1405 -0
  18. mithwire/cdp/device_access.py +141 -0
  19. mithwire/cdp/device_orientation.py +45 -0
  20. mithwire/cdp/dom.py +2257 -0
  21. mithwire/cdp/dom_debugger.py +321 -0
  22. mithwire/cdp/dom_snapshot.py +876 -0
  23. mithwire/cdp/dom_storage.py +222 -0
  24. mithwire/cdp/emulation.py +1779 -0
  25. mithwire/cdp/event_breakpoints.py +56 -0
  26. mithwire/cdp/extensions.py +238 -0
  27. mithwire/cdp/fed_cm.py +283 -0
  28. mithwire/cdp/fetch.py +507 -0
  29. mithwire/cdp/file_system.py +115 -0
  30. mithwire/cdp/headless_experimental.py +115 -0
  31. mithwire/cdp/heap_profiler.py +401 -0
  32. mithwire/cdp/indexed_db.py +528 -0
  33. mithwire/cdp/input_.py +701 -0
  34. mithwire/cdp/inspector.py +95 -0
  35. mithwire/cdp/io.py +101 -0
  36. mithwire/cdp/layer_tree.py +464 -0
  37. mithwire/cdp/log.py +190 -0
  38. mithwire/cdp/media.py +313 -0
  39. mithwire/cdp/memory.py +305 -0
  40. mithwire/cdp/network.py +5342 -0
  41. mithwire/cdp/overlay.py +1468 -0
  42. mithwire/cdp/page.py +3972 -0
  43. mithwire/cdp/performance.py +124 -0
  44. mithwire/cdp/performance_timeline.py +200 -0
  45. mithwire/cdp/preload.py +575 -0
  46. mithwire/cdp/profiler.py +420 -0
  47. mithwire/cdp/pwa.py +278 -0
  48. mithwire/cdp/py.typed +0 -0
  49. mithwire/cdp/runtime.py +1589 -0
  50. mithwire/cdp/schema.py +50 -0
  51. mithwire/cdp/security.py +518 -0
  52. mithwire/cdp/service_worker.py +401 -0
  53. mithwire/cdp/smart_card_emulation.py +891 -0
  54. mithwire/cdp/storage.py +1573 -0
  55. mithwire/cdp/system_info.py +327 -0
  56. mithwire/cdp/target.py +829 -0
  57. mithwire/cdp/tethering.py +65 -0
  58. mithwire/cdp/tracing.py +377 -0
  59. mithwire/cdp/util.py +18 -0
  60. mithwire/cdp/web_audio.py +606 -0
  61. mithwire/cdp/web_authn.py +598 -0
  62. mithwire/cdp/web_mcp.py +293 -0
  63. mithwire/core/_contradict.py +142 -0
  64. mithwire/core/browser.py +923 -0
  65. mithwire/core/cf_templates/cf_dark_checkbox.png +0 -0
  66. mithwire/core/cf_templates/cf_light_checkbox.png +0 -0
  67. mithwire/core/config.py +323 -0
  68. mithwire/core/connection.py +564 -0
  69. mithwire/core/element.py +1205 -0
  70. mithwire/core/tab.py +2202 -0
  71. mithwire/core/util.py +5063 -0
  72. mithwire-0.50.3.dist-info/METADATA +1049 -0
  73. mithwire-0.50.3.dist-info/RECORD +76 -0
  74. mithwire-0.50.3.dist-info/WHEEL +5 -0
  75. mithwire-0.50.3.dist-info/licenses/LICENSE.txt +619 -0
  76. mithwire-0.50.3.dist-info/top_level.txt +1 -0
mithwire/cdp/fetch.py ADDED
@@ -0,0 +1,507 @@
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: Fetch
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
+ from . import io
15
+ from . import network
16
+ from . import page
17
+
18
+
19
+ class RequestId(str):
20
+ '''
21
+ Unique request identifier.
22
+ Note that this does not identify individual HTTP requests that are part of
23
+ a network request.
24
+ '''
25
+ def to_json(self) -> str:
26
+ return self
27
+
28
+ @classmethod
29
+ def from_json(cls, json: str) -> RequestId:
30
+ return cls(json)
31
+
32
+ def __repr__(self):
33
+ return 'RequestId({})'.format(super().__repr__())
34
+
35
+
36
+ class RequestStage(enum.Enum):
37
+ '''
38
+ Stages of the request to handle. Request will intercept before the request is
39
+ sent. Response will intercept after the response is received (but before response
40
+ body is received).
41
+ '''
42
+ REQUEST = "Request"
43
+ RESPONSE = "Response"
44
+
45
+ def to_json(self) -> str:
46
+ return self.value
47
+
48
+ @classmethod
49
+ def from_json(cls, json: str) -> RequestStage:
50
+ return cls(json)
51
+
52
+
53
+ @dataclass
54
+ class RequestPattern:
55
+ #: Wildcards (``'*'`` -> zero or more, ``'?'`` -> exactly one) are allowed. Escape character is
56
+ #: backslash. Omitting is equivalent to ``"*"``.
57
+ url_pattern: typing.Optional[str] = None
58
+
59
+ #: If set, only requests for matching resource types will be intercepted.
60
+ resource_type: typing.Optional[network.ResourceType] = None
61
+
62
+ #: Stage at which to begin intercepting requests. Default is Request.
63
+ request_stage: typing.Optional[RequestStage] = None
64
+
65
+ def to_json(self) -> T_JSON_DICT:
66
+ json: T_JSON_DICT = dict()
67
+ if self.url_pattern is not None:
68
+ json['urlPattern'] = self.url_pattern
69
+ if self.resource_type is not None:
70
+ json['resourceType'] = self.resource_type.to_json()
71
+ if self.request_stage is not None:
72
+ json['requestStage'] = self.request_stage.to_json()
73
+ return json
74
+
75
+ @classmethod
76
+ def from_json(cls, json: T_JSON_DICT) -> RequestPattern:
77
+ return cls(
78
+ url_pattern=str(json['urlPattern']) if json.get('urlPattern', None) is not None else None,
79
+ resource_type=network.ResourceType.from_json(json['resourceType']) if json.get('resourceType', None) is not None else None,
80
+ request_stage=RequestStage.from_json(json['requestStage']) if json.get('requestStage', None) is not None else None,
81
+ )
82
+
83
+
84
+ @dataclass
85
+ class HeaderEntry:
86
+ '''
87
+ Response HTTP header entry
88
+ '''
89
+ name: str
90
+
91
+ value: str
92
+
93
+ def to_json(self) -> T_JSON_DICT:
94
+ json: T_JSON_DICT = dict()
95
+ json['name'] = self.name
96
+ json['value'] = self.value
97
+ return json
98
+
99
+ @classmethod
100
+ def from_json(cls, json: T_JSON_DICT) -> HeaderEntry:
101
+ return cls(
102
+ name=str(json['name']),
103
+ value=str(json['value']),
104
+ )
105
+
106
+
107
+ @dataclass
108
+ class AuthChallenge:
109
+ '''
110
+ Authorization challenge for HTTP status code 401 or 407.
111
+ '''
112
+ #: Origin of the challenger.
113
+ origin: str
114
+
115
+ #: The authentication scheme used, such as basic or digest
116
+ scheme: str
117
+
118
+ #: The realm of the challenge. May be empty.
119
+ realm: str
120
+
121
+ #: Source of the authentication challenge.
122
+ source: typing.Optional[str] = None
123
+
124
+ def to_json(self) -> T_JSON_DICT:
125
+ json: T_JSON_DICT = dict()
126
+ json['origin'] = self.origin
127
+ json['scheme'] = self.scheme
128
+ json['realm'] = self.realm
129
+ if self.source is not None:
130
+ json['source'] = self.source
131
+ return json
132
+
133
+ @classmethod
134
+ def from_json(cls, json: T_JSON_DICT) -> AuthChallenge:
135
+ return cls(
136
+ origin=str(json['origin']),
137
+ scheme=str(json['scheme']),
138
+ realm=str(json['realm']),
139
+ source=str(json['source']) if json.get('source', None) is not None else None,
140
+ )
141
+
142
+
143
+ @dataclass
144
+ class AuthChallengeResponse:
145
+ '''
146
+ Response to an AuthChallenge.
147
+ '''
148
+ #: The decision on what to do in response to the authorization challenge. Default means
149
+ #: deferring to the default behavior of the net stack, which will likely either the Cancel
150
+ #: authentication or display a popup dialog box.
151
+ response: str
152
+
153
+ #: The username to provide, possibly empty. Should only be set if response is
154
+ #: ProvideCredentials.
155
+ username: typing.Optional[str] = None
156
+
157
+ #: The password to provide, possibly empty. Should only be set if response is
158
+ #: ProvideCredentials.
159
+ password: typing.Optional[str] = None
160
+
161
+ def to_json(self) -> T_JSON_DICT:
162
+ json: T_JSON_DICT = dict()
163
+ json['response'] = self.response
164
+ if self.username is not None:
165
+ json['username'] = self.username
166
+ if self.password is not None:
167
+ json['password'] = self.password
168
+ return json
169
+
170
+ @classmethod
171
+ def from_json(cls, json: T_JSON_DICT) -> AuthChallengeResponse:
172
+ return cls(
173
+ response=str(json['response']),
174
+ username=str(json['username']) if json.get('username', None) is not None else None,
175
+ password=str(json['password']) if json.get('password', None) is not None else None,
176
+ )
177
+
178
+
179
+ def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
180
+ '''
181
+ Disables the fetch domain.
182
+ '''
183
+ cmd_dict: T_JSON_DICT = {
184
+ 'method': 'Fetch.disable',
185
+ }
186
+ json = yield cmd_dict
187
+
188
+
189
+ def enable(
190
+ patterns: typing.Optional[typing.List[RequestPattern]] = None,
191
+ handle_auth_requests: typing.Optional[bool] = None
192
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
193
+ '''
194
+ Enables issuing of requestPaused events. A request will be paused until client
195
+ calls one of failRequest, fulfillRequest or continueRequest/continueWithAuth.
196
+
197
+ :param patterns: *(Optional)* If specified, only requests matching any of these patterns will produce fetchRequested event and will be paused until clients response. If not set, all requests will be affected.
198
+ :param handle_auth_requests: *(Optional)* If true, authRequired events will be issued and requests will be paused expecting a call to continueWithAuth.
199
+ '''
200
+ params: T_JSON_DICT = dict()
201
+ if patterns is not None:
202
+ params['patterns'] = [i.to_json() for i in patterns]
203
+ if handle_auth_requests is not None:
204
+ params['handleAuthRequests'] = handle_auth_requests
205
+ cmd_dict: T_JSON_DICT = {
206
+ 'method': 'Fetch.enable',
207
+ 'params': params,
208
+ }
209
+ json = yield cmd_dict
210
+
211
+
212
+ def fail_request(
213
+ request_id: RequestId,
214
+ error_reason: network.ErrorReason
215
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
216
+ '''
217
+ Causes the request to fail with specified reason.
218
+
219
+ :param request_id: An id the client received in requestPaused event.
220
+ :param error_reason: Causes the request to fail with the given reason.
221
+ '''
222
+ params: T_JSON_DICT = dict()
223
+ params['requestId'] = request_id.to_json()
224
+ params['errorReason'] = error_reason.to_json()
225
+ cmd_dict: T_JSON_DICT = {
226
+ 'method': 'Fetch.failRequest',
227
+ 'params': params,
228
+ }
229
+ json = yield cmd_dict
230
+
231
+
232
+ def fulfill_request(
233
+ request_id: RequestId,
234
+ response_code: int,
235
+ response_headers: typing.Optional[typing.List[HeaderEntry]] = None,
236
+ binary_response_headers: typing.Optional[str] = None,
237
+ body: typing.Optional[str] = None,
238
+ response_phrase: typing.Optional[str] = None
239
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
240
+ r'''
241
+ Provides response to the request.
242
+
243
+ :param request_id: An id the client received in requestPaused event.
244
+ :param response_code: An HTTP response code.
245
+ :param response_headers: *(Optional)* Response headers.
246
+ :param binary_response_headers: *(Optional)* Alternative way of specifying response headers as a \0-separated series of name: value pairs. Prefer the above method unless you need to represent some non-UTF8 values that can't be transmitted over the protocol as text. (Encoded as a base64 string when passed over JSON)
247
+ :param body: *(Optional)* A response body. If absent, original response body will be used if the request is intercepted at the response stage and empty body will be used if the request is intercepted at the request stage. (Encoded as a base64 string when passed over JSON)
248
+ :param response_phrase: *(Optional)* A textual representation of responseCode. If absent, a standard phrase matching responseCode is used.
249
+ '''
250
+ params: T_JSON_DICT = dict()
251
+ params['requestId'] = request_id.to_json()
252
+ params['responseCode'] = response_code
253
+ if response_headers is not None:
254
+ params['responseHeaders'] = [i.to_json() for i in response_headers]
255
+ if binary_response_headers is not None:
256
+ params['binaryResponseHeaders'] = binary_response_headers
257
+ if body is not None:
258
+ params['body'] = body
259
+ if response_phrase is not None:
260
+ params['responsePhrase'] = response_phrase
261
+ cmd_dict: T_JSON_DICT = {
262
+ 'method': 'Fetch.fulfillRequest',
263
+ 'params': params,
264
+ }
265
+ json = yield cmd_dict
266
+
267
+
268
+ def continue_request(
269
+ request_id: RequestId,
270
+ url: typing.Optional[str] = None,
271
+ method: typing.Optional[str] = None,
272
+ post_data: typing.Optional[str] = None,
273
+ headers: typing.Optional[typing.List[HeaderEntry]] = None,
274
+ intercept_response: typing.Optional[bool] = None
275
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
276
+ '''
277
+ Continues the request, optionally modifying some of its parameters.
278
+
279
+ :param request_id: An id the client received in requestPaused event.
280
+ :param url: *(Optional)* If set, the request url will be modified in a way that's not observable by page.
281
+ :param method: *(Optional)* If set, the request method is overridden.
282
+ :param post_data: *(Optional)* If set, overrides the post data in the request. (Encoded as a base64 string when passed over JSON)
283
+ :param headers: *(Optional)* If set, overrides the request headers. Note that the overrides do not extend to subsequent redirect hops, if a redirect happens. Another override may be applied to a different request produced by a redirect.
284
+ :param intercept_response: **(EXPERIMENTAL)** *(Optional)* If set, overrides response interception behavior for this request.
285
+ '''
286
+ params: T_JSON_DICT = dict()
287
+ params['requestId'] = request_id.to_json()
288
+ if url is not None:
289
+ params['url'] = url
290
+ if method is not None:
291
+ params['method'] = method
292
+ if post_data is not None:
293
+ params['postData'] = post_data
294
+ if headers is not None:
295
+ params['headers'] = [i.to_json() for i in headers]
296
+ if intercept_response is not None:
297
+ params['interceptResponse'] = intercept_response
298
+ cmd_dict: T_JSON_DICT = {
299
+ 'method': 'Fetch.continueRequest',
300
+ 'params': params,
301
+ }
302
+ json = yield cmd_dict
303
+
304
+
305
+ def continue_with_auth(
306
+ request_id: RequestId,
307
+ auth_challenge_response: AuthChallengeResponse
308
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
309
+ '''
310
+ Continues a request supplying authChallengeResponse following authRequired event.
311
+
312
+ :param request_id: An id the client received in authRequired event.
313
+ :param auth_challenge_response: Response to with an authChallenge.
314
+ '''
315
+ params: T_JSON_DICT = dict()
316
+ params['requestId'] = request_id.to_json()
317
+ params['authChallengeResponse'] = auth_challenge_response.to_json()
318
+ cmd_dict: T_JSON_DICT = {
319
+ 'method': 'Fetch.continueWithAuth',
320
+ 'params': params,
321
+ }
322
+ json = yield cmd_dict
323
+
324
+
325
+ def continue_response(
326
+ request_id: RequestId,
327
+ response_code: typing.Optional[int] = None,
328
+ response_phrase: typing.Optional[str] = None,
329
+ response_headers: typing.Optional[typing.List[HeaderEntry]] = None,
330
+ binary_response_headers: typing.Optional[str] = None
331
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
332
+ r'''
333
+ Continues loading of the paused response, optionally modifying the
334
+ response headers. If either responseCode or headers are modified, all of them
335
+ must be present.
336
+
337
+ **EXPERIMENTAL**
338
+
339
+ :param request_id: An id the client received in requestPaused event.
340
+ :param response_code: *(Optional)* An HTTP response code. If absent, original response code will be used.
341
+ :param response_phrase: *(Optional)* A textual representation of responseCode. If absent, a standard phrase matching responseCode is used.
342
+ :param response_headers: *(Optional)* Response headers. If absent, original response headers will be used.
343
+ :param binary_response_headers: *(Optional)* Alternative way of specifying response headers as a \0-separated series of name: value pairs. Prefer the above method unless you need to represent some non-UTF8 values that can't be transmitted over the protocol as text. (Encoded as a base64 string when passed over JSON)
344
+ '''
345
+ params: T_JSON_DICT = dict()
346
+ params['requestId'] = request_id.to_json()
347
+ if response_code is not None:
348
+ params['responseCode'] = response_code
349
+ if response_phrase is not None:
350
+ params['responsePhrase'] = response_phrase
351
+ if response_headers is not None:
352
+ params['responseHeaders'] = [i.to_json() for i in response_headers]
353
+ if binary_response_headers is not None:
354
+ params['binaryResponseHeaders'] = binary_response_headers
355
+ cmd_dict: T_JSON_DICT = {
356
+ 'method': 'Fetch.continueResponse',
357
+ 'params': params,
358
+ }
359
+ json = yield cmd_dict
360
+
361
+
362
+ def get_response_body(
363
+ request_id: RequestId
364
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[str, bool]]:
365
+ '''
366
+ Causes the body of the response to be received from the server and
367
+ returned as a single string. May only be issued for a request that
368
+ is paused in the Response stage and is mutually exclusive with
369
+ takeResponseBodyForInterceptionAsStream. Calling other methods that
370
+ affect the request or disabling fetch domain before body is received
371
+ results in an undefined behavior.
372
+ Note that the response body is not available for redirects. Requests
373
+ paused in the _redirect received_ state may be differentiated by
374
+ ``responseCode`` and presence of ``location`` response header, see
375
+ comments to ``requestPaused`` for details.
376
+
377
+ :param request_id: Identifier for the intercepted request to get body for.
378
+ :returns: A tuple with the following items:
379
+
380
+ 0. **body** - Response body.
381
+ 1. **base64Encoded** - True, if content was sent as base64.
382
+ '''
383
+ params: T_JSON_DICT = dict()
384
+ params['requestId'] = request_id.to_json()
385
+ cmd_dict: T_JSON_DICT = {
386
+ 'method': 'Fetch.getResponseBody',
387
+ 'params': params,
388
+ }
389
+ json = yield cmd_dict
390
+ return (
391
+ str(json['body']),
392
+ bool(json['base64Encoded'])
393
+ )
394
+
395
+
396
+ def take_response_body_as_stream(
397
+ request_id: RequestId
398
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,io.StreamHandle]:
399
+ '''
400
+ Returns a handle to the stream representing the response body.
401
+ The request must be paused in the HeadersReceived stage.
402
+ Note that after this command the request can't be continued
403
+ as is -- client either needs to cancel it or to provide the
404
+ response body.
405
+ The stream only supports sequential read, IO.read will fail if the position
406
+ is specified.
407
+ This method is mutually exclusive with getResponseBody.
408
+ Calling other methods that affect the request or disabling fetch
409
+ domain before body is received results in an undefined behavior.
410
+
411
+ :param request_id:
412
+ :returns:
413
+ '''
414
+ params: T_JSON_DICT = dict()
415
+ params['requestId'] = request_id.to_json()
416
+ cmd_dict: T_JSON_DICT = {
417
+ 'method': 'Fetch.takeResponseBodyAsStream',
418
+ 'params': params,
419
+ }
420
+ json = yield cmd_dict
421
+ return io.StreamHandle.from_json(json['stream'])
422
+
423
+
424
+ @event_class('Fetch.requestPaused')
425
+ @dataclass
426
+ class RequestPaused:
427
+ '''
428
+ Issued when the domain is enabled and the request URL matches the
429
+ specified filter. The request is paused until the client responds
430
+ with one of continueRequest, failRequest or fulfillRequest.
431
+ The stage of the request can be determined by presence of responseErrorReason
432
+ and responseStatusCode -- the request is at the response stage if either
433
+ of these fields is present and in the request stage otherwise.
434
+ Redirect responses and subsequent requests are reported similarly to regular
435
+ responses and requests. Redirect responses may be distinguished by the value
436
+ of ``responseStatusCode`` (which is one of 301, 302, 303, 307, 308) along with
437
+ presence of the ``location`` header. Requests resulting from a redirect will
438
+ have ``redirectedRequestId`` field set.
439
+ '''
440
+ #: Each request the page makes will have a unique id.
441
+ request_id: RequestId
442
+ #: The details of the request.
443
+ request: network.Request
444
+ #: The id of the frame that initiated the request.
445
+ frame_id: page.FrameId
446
+ #: How the requested resource will be used.
447
+ resource_type: network.ResourceType
448
+ #: Response error if intercepted at response stage.
449
+ response_error_reason: typing.Optional[network.ErrorReason]
450
+ #: Response code if intercepted at response stage.
451
+ response_status_code: typing.Optional[int]
452
+ #: Response status text if intercepted at response stage.
453
+ response_status_text: typing.Optional[str]
454
+ #: Response headers if intercepted at the response stage.
455
+ response_headers: typing.Optional[typing.List[HeaderEntry]]
456
+ #: If the intercepted request had a corresponding Network.requestWillBeSent event fired for it,
457
+ #: then this networkId will be the same as the requestId present in the requestWillBeSent event.
458
+ network_id: typing.Optional[network.RequestId]
459
+ #: If the request is due to a redirect response from the server, the id of the request that
460
+ #: has caused the redirect.
461
+ redirected_request_id: typing.Optional[RequestId]
462
+
463
+ @classmethod
464
+ def from_json(cls, json: T_JSON_DICT) -> RequestPaused:
465
+ return cls(
466
+ request_id=RequestId.from_json(json['requestId']),
467
+ request=network.Request.from_json(json['request']),
468
+ frame_id=page.FrameId.from_json(json['frameId']),
469
+ resource_type=network.ResourceType.from_json(json['resourceType']),
470
+ response_error_reason=network.ErrorReason.from_json(json['responseErrorReason']) if json.get('responseErrorReason', None) is not None else None,
471
+ response_status_code=int(json['responseStatusCode']) if json.get('responseStatusCode', None) is not None else None,
472
+ response_status_text=str(json['responseStatusText']) if json.get('responseStatusText', None) is not None else None,
473
+ response_headers=[HeaderEntry.from_json(i) for i in json['responseHeaders']] if json.get('responseHeaders', None) is not None else None,
474
+ network_id=network.RequestId.from_json(json['networkId']) if json.get('networkId', None) is not None else None,
475
+ redirected_request_id=RequestId.from_json(json['redirectedRequestId']) if json.get('redirectedRequestId', None) is not None else None
476
+ )
477
+
478
+
479
+ @event_class('Fetch.authRequired')
480
+ @dataclass
481
+ class AuthRequired:
482
+ '''
483
+ Issued when the domain is enabled with handleAuthRequests set to true.
484
+ The request is paused until client responds with continueWithAuth.
485
+ '''
486
+ #: Each request the page makes will have a unique id.
487
+ request_id: RequestId
488
+ #: The details of the request.
489
+ request: network.Request
490
+ #: The id of the frame that initiated the request.
491
+ frame_id: page.FrameId
492
+ #: How the requested resource will be used.
493
+ resource_type: network.ResourceType
494
+ #: Details of the Authorization Challenge encountered.
495
+ #: If this is set, client should respond with continueRequest that
496
+ #: contains AuthChallengeResponse.
497
+ auth_challenge: AuthChallenge
498
+
499
+ @classmethod
500
+ def from_json(cls, json: T_JSON_DICT) -> AuthRequired:
501
+ return cls(
502
+ request_id=RequestId.from_json(json['requestId']),
503
+ request=network.Request.from_json(json['request']),
504
+ frame_id=page.FrameId.from_json(json['frameId']),
505
+ resource_type=network.ResourceType.from_json(json['resourceType']),
506
+ auth_challenge=AuthChallenge.from_json(json['authChallenge'])
507
+ )
@@ -0,0 +1,115 @@
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: FileSystem (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
+ from . import network
15
+ from . import storage
16
+
17
+
18
+ @dataclass
19
+ class File:
20
+ name: str
21
+
22
+ #: Timestamp
23
+ last_modified: network.TimeSinceEpoch
24
+
25
+ #: Size in bytes
26
+ size: float
27
+
28
+ type_: str
29
+
30
+ def to_json(self) -> T_JSON_DICT:
31
+ json: T_JSON_DICT = dict()
32
+ json['name'] = self.name
33
+ json['lastModified'] = self.last_modified.to_json()
34
+ json['size'] = self.size
35
+ json['type'] = self.type_
36
+ return json
37
+
38
+ @classmethod
39
+ def from_json(cls, json: T_JSON_DICT) -> File:
40
+ return cls(
41
+ name=str(json['name']),
42
+ last_modified=network.TimeSinceEpoch.from_json(json['lastModified']),
43
+ size=float(json['size']),
44
+ type_=str(json['type']),
45
+ )
46
+
47
+
48
+ @dataclass
49
+ class Directory:
50
+ name: str
51
+
52
+ nested_directories: typing.List[str]
53
+
54
+ #: Files that are directly nested under this directory.
55
+ nested_files: typing.List[File]
56
+
57
+ def to_json(self) -> T_JSON_DICT:
58
+ json: T_JSON_DICT = dict()
59
+ json['name'] = self.name
60
+ json['nestedDirectories'] = [i for i in self.nested_directories]
61
+ json['nestedFiles'] = [i.to_json() for i in self.nested_files]
62
+ return json
63
+
64
+ @classmethod
65
+ def from_json(cls, json: T_JSON_DICT) -> Directory:
66
+ return cls(
67
+ name=str(json['name']),
68
+ nested_directories=[str(i) for i in json['nestedDirectories']],
69
+ nested_files=[File.from_json(i) for i in json['nestedFiles']],
70
+ )
71
+
72
+
73
+ @dataclass
74
+ class BucketFileSystemLocator:
75
+ #: Storage key
76
+ storage_key: storage.SerializedStorageKey
77
+
78
+ #: Path to the directory using each path component as an array item.
79
+ path_components: typing.List[str]
80
+
81
+ #: Bucket name. Not passing a ``bucketName`` will retrieve the default Bucket. (https://developer.mozilla.org/en-US/docs/Web/API/Storage_API#storage_buckets)
82
+ bucket_name: typing.Optional[str] = None
83
+
84
+ def to_json(self) -> T_JSON_DICT:
85
+ json: T_JSON_DICT = dict()
86
+ json['storageKey'] = self.storage_key.to_json()
87
+ json['pathComponents'] = [i for i in self.path_components]
88
+ if self.bucket_name is not None:
89
+ json['bucketName'] = self.bucket_name
90
+ return json
91
+
92
+ @classmethod
93
+ def from_json(cls, json: T_JSON_DICT) -> BucketFileSystemLocator:
94
+ return cls(
95
+ storage_key=storage.SerializedStorageKey.from_json(json['storageKey']),
96
+ path_components=[str(i) for i in json['pathComponents']],
97
+ bucket_name=str(json['bucketName']) if json.get('bucketName', None) is not None else None,
98
+ )
99
+
100
+
101
+ def get_directory(
102
+ bucket_file_system_locator: BucketFileSystemLocator
103
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,Directory]:
104
+ '''
105
+ :param bucket_file_system_locator:
106
+ :returns: Returns the directory object at the path.
107
+ '''
108
+ params: T_JSON_DICT = dict()
109
+ params['bucketFileSystemLocator'] = bucket_file_system_locator.to_json()
110
+ cmd_dict: T_JSON_DICT = {
111
+ 'method': 'FileSystem.getDirectory',
112
+ 'params': params,
113
+ }
114
+ json = yield cmd_dict
115
+ return Directory.from_json(json['directory'])