osn-selenium 0.0.0__py3-none-any.whl → 1.1.0__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.
- osn_selenium/_base_models.py +41 -0
- osn_selenium/_cdp_import.py +253 -0
- osn_selenium/_functions.py +84 -0
- osn_selenium/_typehints.py +19 -0
- osn_selenium/abstract/executors/cdp/__init__.py +435 -0
- osn_selenium/abstract/executors/cdp/accessibility.py +62 -0
- osn_selenium/abstract/executors/cdp/animation.py +47 -0
- osn_selenium/abstract/executors/cdp/audits.py +39 -0
- osn_selenium/abstract/executors/cdp/autofill.py +34 -0
- osn_selenium/abstract/executors/cdp/background_service.py +22 -0
- osn_selenium/abstract/executors/cdp/bluetooth_emulation.py +95 -0
- osn_selenium/abstract/executors/cdp/browser.py +122 -0
- osn_selenium/abstract/executors/cdp/cache_storage.py +49 -0
- osn_selenium/abstract/executors/cdp/cast.py +31 -0
- osn_selenium/abstract/executors/cdp/console.py +18 -0
- osn_selenium/abstract/executors/cdp/css.py +197 -0
- osn_selenium/abstract/executors/cdp/debugger.py +198 -0
- osn_selenium/abstract/executors/cdp/device_access.py +22 -0
- osn_selenium/abstract/executors/cdp/device_orientation.py +14 -0
- osn_selenium/abstract/executors/cdp/dom.py +305 -0
- osn_selenium/abstract/executors/cdp/dom_debugger.py +57 -0
- osn_selenium/abstract/executors/cdp/dom_snapshot.py +42 -0
- osn_selenium/abstract/executors/cdp/dom_storage.py +31 -0
- osn_selenium/abstract/executors/cdp/emulation.py +259 -0
- osn_selenium/abstract/executors/cdp/event_breakpoints.py +18 -0
- osn_selenium/abstract/executors/cdp/extensions.py +31 -0
- osn_selenium/abstract/executors/cdp/fed_cm.py +35 -0
- osn_selenium/abstract/executors/cdp/fetch.py +76 -0
- osn_selenium/abstract/executors/cdp/file_system.py +11 -0
- osn_selenium/abstract/executors/cdp/headless_experimental.py +30 -0
- osn_selenium/abstract/executors/cdp/heap_profiler.py +73 -0
- osn_selenium/abstract/executors/cdp/indexed_db.py +99 -0
- osn_selenium/abstract/executors/cdp/input.py +158 -0
- osn_selenium/abstract/executors/cdp/inspector.py +14 -0
- osn_selenium/abstract/executors/cdp/io.py +24 -0
- osn_selenium/abstract/executors/cdp/layer_tree.py +61 -0
- osn_selenium/abstract/executors/cdp/log.py +27 -0
- osn_selenium/abstract/executors/cdp/media.py +14 -0
- osn_selenium/abstract/executors/cdp/memory.py +61 -0
- osn_selenium/abstract/executors/cdp/network.py +252 -0
- osn_selenium/abstract/executors/cdp/overlay.py +166 -0
- osn_selenium/abstract/executors/cdp/page.py +347 -0
- osn_selenium/abstract/executors/cdp/performance.py +28 -0
- osn_selenium/abstract/executors/cdp/performance_timeline.py +11 -0
- osn_selenium/abstract/executors/cdp/preload.py +14 -0
- osn_selenium/abstract/executors/cdp/profiler.py +54 -0
- osn_selenium/abstract/executors/cdp/pwa.py +46 -0
- osn_selenium/abstract/executors/cdp/runtime.py +176 -0
- osn_selenium/abstract/executors/cdp/schema.py +11 -0
- osn_selenium/abstract/executors/cdp/security.py +26 -0
- osn_selenium/abstract/executors/cdp/service_worker.py +54 -0
- osn_selenium/abstract/executors/cdp/storage.py +175 -0
- osn_selenium/abstract/executors/cdp/system_info.py +24 -0
- osn_selenium/abstract/executors/cdp/target.py +125 -0
- osn_selenium/abstract/executors/cdp/tethering.py +14 -0
- osn_selenium/abstract/executors/cdp/tracing.py +48 -0
- osn_selenium/abstract/executors/cdp/web_audio.py +19 -0
- osn_selenium/abstract/executors/cdp/web_authn.py +76 -0
- osn_selenium/abstract/executors/cdp.py +63 -0
- osn_selenium/abstract/executors/javascript.py +203 -0
- osn_selenium/abstract/instances/action_chains/__init__.py +12 -0
- osn_selenium/abstract/instances/action_chains/base.py +25 -0
- osn_selenium/abstract/instances/action_chains/click.py +93 -0
- osn_selenium/abstract/instances/action_chains/drag_and_drop.py +46 -0
- osn_selenium/abstract/instances/action_chains/hm_keyboard.py +44 -0
- osn_selenium/abstract/instances/action_chains/hm_move.py +104 -0
- osn_selenium/abstract/instances/action_chains/hm_scroll.py +75 -0
- osn_selenium/abstract/instances/action_chains/keyboard.py +79 -0
- osn_selenium/abstract/instances/action_chains/move.py +60 -0
- osn_selenium/abstract/instances/action_chains/scroll.py +61 -0
- osn_selenium/abstract/instances/action_chains/utils.py +44 -0
- osn_selenium/abstract/instances/alert.py +67 -0
- osn_selenium/abstract/instances/browser.py +76 -0
- osn_selenium/abstract/instances/browsing_context.py +310 -0
- osn_selenium/abstract/instances/dialog.py +107 -0
- osn_selenium/abstract/instances/fedcm.py +133 -0
- osn_selenium/abstract/instances/mobile.py +79 -0
- osn_selenium/abstract/instances/network.py +100 -0
- osn_selenium/abstract/instances/permissions.py +52 -0
- osn_selenium/abstract/instances/script.py +109 -0
- osn_selenium/abstract/instances/shadow_root.py +81 -0
- osn_selenium/abstract/instances/storage.py +98 -0
- osn_selenium/abstract/instances/switch_to.py +104 -0
- osn_selenium/abstract/instances/web_driver_wait.py +57 -0
- osn_selenium/abstract/instances/web_element.py +395 -0
- osn_selenium/abstract/instances/web_extension.py +70 -0
- osn_selenium/abstract/webdriver/blink/__init__.py +18 -0
- osn_selenium/abstract/webdriver/blink/base.py +80 -0
- osn_selenium/abstract/webdriver/blink/casting.py +82 -0
- osn_selenium/abstract/webdriver/blink/features.py +51 -0
- osn_selenium/abstract/webdriver/blink/lifecycle.py +76 -0
- osn_selenium/abstract/webdriver/blink/logging.py +40 -0
- osn_selenium/abstract/webdriver/blink/network.py +45 -0
- osn_selenium/abstract/webdriver/blink/settings.py +68 -0
- osn_selenium/abstract/webdriver/chrome/__init__.py +18 -0
- osn_selenium/abstract/webdriver/chrome/base.py +36 -0
- osn_selenium/abstract/webdriver/chrome/lifecycle.py +92 -0
- osn_selenium/abstract/webdriver/chrome/settings.py +110 -0
- osn_selenium/abstract/webdriver/core/__init__.py +16 -0
- osn_selenium/abstract/webdriver/core/actions.py +58 -0
- osn_selenium/abstract/webdriver/core/auth.py +145 -0
- osn_selenium/abstract/webdriver/core/base.py +298 -0
- osn_selenium/abstract/webdriver/core/capture.py +84 -0
- osn_selenium/abstract/webdriver/core/components.py +82 -0
- osn_selenium/abstract/webdriver/core/devtools.py +69 -0
- osn_selenium/abstract/webdriver/core/element.py +55 -0
- osn_selenium/abstract/webdriver/core/file.py +82 -0
- osn_selenium/abstract/webdriver/core/lifecycle.py +103 -0
- osn_selenium/abstract/webdriver/core/navigation.py +65 -0
- osn_selenium/abstract/webdriver/core/script.py +88 -0
- osn_selenium/abstract/webdriver/core/settings.py +43 -0
- osn_selenium/abstract/webdriver/core/storage.py +81 -0
- osn_selenium/abstract/webdriver/core/timeouts.py +101 -0
- osn_selenium/abstract/webdriver/core/window.py +237 -0
- osn_selenium/abstract/webdriver/edge/__init__.py +18 -0
- osn_selenium/abstract/webdriver/edge/base.py +36 -0
- osn_selenium/abstract/webdriver/edge/lifecycle.py +92 -0
- osn_selenium/abstract/webdriver/edge/settings.py +110 -0
- osn_selenium/abstract/webdriver/yandex/__init__.py +18 -0
- osn_selenium/abstract/webdriver/yandex/base.py +18 -0
- osn_selenium/abstract/webdriver/yandex/lifecycle.py +92 -0
- osn_selenium/abstract/webdriver/yandex/settings.py +110 -0
- osn_selenium/base_mixin.py +122 -0
- osn_selenium/browsers_handler/__init__.py +47 -17
- osn_selenium/browsers_handler/_linux.py +226 -0
- osn_selenium/browsers_handler/_windows.py +21 -14
- osn_selenium/browsers_handler/{types.py → models.py} +5 -2
- osn_selenium/dev_tools/_decorators.py +149 -0
- osn_selenium/dev_tools/_exception_helpers.py +116 -0
- osn_selenium/dev_tools/_functions.py +174 -0
- osn_selenium/dev_tools/_system_utils.py +35 -0
- osn_selenium/dev_tools/_typehints.py +35 -0
- osn_selenium/dev_tools/_validators.py +227 -0
- osn_selenium/dev_tools/_wrappers.py +92 -0
- osn_selenium/dev_tools/domains/__init__.py +7 -40
- osn_selenium/dev_tools/domains/abstract.py +98 -254
- osn_selenium/dev_tools/domains/fetch.py +229 -906
- osn_selenium/dev_tools/domains_default/fetch.py +40 -28
- osn_selenium/dev_tools/filters.py +40 -0
- osn_selenium/dev_tools/logger/main.py +214 -0
- osn_selenium/dev_tools/logger/models.py +232 -0
- osn_selenium/dev_tools/logger/target.py +278 -0
- osn_selenium/dev_tools/manager/__init__.py +16 -0
- osn_selenium/dev_tools/manager/base.py +124 -0
- osn_selenium/dev_tools/manager/lifecycle.py +236 -0
- osn_selenium/dev_tools/manager/logging.py +153 -0
- osn_selenium/dev_tools/manager/settings.py +89 -0
- osn_selenium/dev_tools/manager/targets.py +175 -0
- osn_selenium/dev_tools/models.py +49 -0
- osn_selenium/dev_tools/settings.py +139 -0
- osn_selenium/dev_tools/target/__init__.py +16 -0
- osn_selenium/dev_tools/target/base.py +427 -0
- osn_selenium/dev_tools/target/detach.py +54 -0
- osn_selenium/dev_tools/target/discovery.py +112 -0
- osn_selenium/dev_tools/target/events.py +120 -0
- osn_selenium/dev_tools/target/fingerprint.py +126 -0
- osn_selenium/dev_tools/target/lifecycle.py +184 -0
- osn_selenium/dev_tools/target/logging.py +163 -0
- osn_selenium/exceptions/__init__.py +1 -0
- osn_selenium/exceptions/base.py +9 -0
- osn_selenium/exceptions/configuration.py +84 -0
- osn_selenium/exceptions/dependencies.py +60 -0
- osn_selenium/exceptions/devtools.py +114 -0
- osn_selenium/exceptions/flags.py +45 -0
- osn_selenium/exceptions/instance.py +92 -0
- osn_selenium/exceptions/javascript.py +31 -0
- osn_selenium/exceptions/logic.py +31 -0
- osn_selenium/exceptions/path.py +77 -0
- osn_selenium/exceptions/platform.py +33 -0
- osn_selenium/exceptions/protocol.py +86 -0
- osn_selenium/exceptions/webdriver.py +44 -0
- osn_selenium/exceptions/window.py +63 -0
- osn_selenium/executors/__init__.py +1 -0
- osn_selenium/executors/sync/__init__.py +1 -0
- osn_selenium/executors/sync/cdp/__init__.py +550 -0
- osn_selenium/executors/sync/cdp/accessibility.py +74 -0
- osn_selenium/executors/sync/cdp/animation.py +50 -0
- osn_selenium/executors/sync/cdp/audits.py +48 -0
- osn_selenium/executors/sync/cdp/autofill.py +39 -0
- osn_selenium/executors/sync/cdp/background_service.py +30 -0
- osn_selenium/executors/sync/cdp/bluetooth_emulation.py +101 -0
- osn_selenium/executors/sync/cdp/browser.py +131 -0
- osn_selenium/executors/sync/cdp/cache_storage.py +66 -0
- osn_selenium/executors/sync/cdp/cast.py +38 -0
- osn_selenium/executors/sync/cdp/console.py +24 -0
- osn_selenium/executors/sync/cdp/css.py +187 -0
- osn_selenium/executors/sync/cdp/debugger.py +206 -0
- osn_selenium/executors/sync/cdp/device_access.py +27 -0
- osn_selenium/executors/sync/cdp/device_orientation.py +24 -0
- osn_selenium/executors/sync/cdp/dom.py +310 -0
- osn_selenium/executors/sync/cdp/dom_debugger.py +56 -0
- osn_selenium/executors/sync/cdp/dom_snapshot.py +58 -0
- osn_selenium/executors/sync/cdp/dom_storage.py +38 -0
- osn_selenium/executors/sync/cdp/emulation.py +270 -0
- osn_selenium/executors/sync/cdp/event_breakpoints.py +27 -0
- osn_selenium/executors/sync/cdp/extensions.py +39 -0
- osn_selenium/executors/sync/cdp/fed_cm.py +45 -0
- osn_selenium/executors/sync/cdp/fetch.py +96 -0
- osn_selenium/executors/sync/cdp/file_system.py +18 -0
- osn_selenium/executors/sync/cdp/headless_experimental.py +44 -0
- osn_selenium/executors/sync/cdp/heap_profiler.py +89 -0
- osn_selenium/executors/sync/cdp/indexed_db.py +142 -0
- osn_selenium/executors/sync/cdp/input.py +233 -0
- osn_selenium/executors/sync/cdp/inspector.py +21 -0
- osn_selenium/executors/sync/cdp/io.py +33 -0
- osn_selenium/executors/sync/cdp/layer_tree.py +71 -0
- osn_selenium/executors/sync/cdp/log.py +35 -0
- osn_selenium/executors/sync/cdp/media.py +21 -0
- osn_selenium/executors/sync/cdp/memory.py +62 -0
- osn_selenium/executors/sync/cdp/network.py +287 -0
- osn_selenium/executors/sync/cdp/overlay.py +174 -0
- osn_selenium/executors/sync/cdp/page.py +365 -0
- osn_selenium/executors/sync/cdp/performance.py +33 -0
- osn_selenium/executors/sync/cdp/performance_timeline.py +26 -0
- osn_selenium/executors/sync/cdp/preload.py +21 -0
- osn_selenium/executors/sync/cdp/profiler.py +58 -0
- osn_selenium/executors/sync/cdp/pwa.py +55 -0
- osn_selenium/executors/sync/cdp/runtime.py +221 -0
- osn_selenium/executors/sync/cdp/schema.py +23 -0
- osn_selenium/executors/sync/cdp/security.py +30 -0
- osn_selenium/executors/sync/cdp/service_worker.py +56 -0
- osn_selenium/executors/sync/cdp/storage.py +151 -0
- osn_selenium/executors/sync/cdp/system_info.py +30 -0
- osn_selenium/executors/sync/cdp/target.py +147 -0
- osn_selenium/executors/sync/cdp/tethering.py +21 -0
- osn_selenium/executors/sync/cdp/tracing.py +62 -0
- osn_selenium/executors/sync/cdp/web_audio.py +24 -0
- osn_selenium/executors/sync/cdp/web_authn.py +82 -0
- osn_selenium/executors/sync/cdp.py +100 -0
- osn_selenium/executors/sync/javascript.py +79 -0
- osn_selenium/executors/trio_threads/__init__.py +1 -0
- osn_selenium/executors/trio_threads/cdp/__init__.py +771 -0
- osn_selenium/executors/trio_threads/cdp/accessibility.py +87 -0
- osn_selenium/executors/trio_threads/cdp/animation.py +63 -0
- osn_selenium/executors/trio_threads/cdp/audits.py +57 -0
- osn_selenium/executors/trio_threads/cdp/autofill.py +52 -0
- osn_selenium/executors/trio_threads/cdp/background_service.py +40 -0
- osn_selenium/executors/trio_threads/cdp/bluetooth_emulation.py +111 -0
- osn_selenium/executors/trio_threads/cdp/browser.py +140 -0
- osn_selenium/executors/trio_threads/cdp/cache_storage.py +79 -0
- osn_selenium/executors/trio_threads/cdp/cast.py +47 -0
- osn_selenium/executors/trio_threads/cdp/console.py +33 -0
- osn_selenium/executors/trio_threads/cdp/css.py +196 -0
- osn_selenium/executors/trio_threads/cdp/debugger.py +219 -0
- osn_selenium/executors/trio_threads/cdp/device_access.py +40 -0
- osn_selenium/executors/trio_threads/cdp/device_orientation.py +34 -0
- osn_selenium/executors/trio_threads/cdp/dom.py +319 -0
- osn_selenium/executors/trio_threads/cdp/dom_debugger.py +69 -0
- osn_selenium/executors/trio_threads/cdp/dom_snapshot.py +71 -0
- osn_selenium/executors/trio_threads/cdp/dom_storage.py +51 -0
- osn_selenium/executors/trio_threads/cdp/emulation.py +283 -0
- osn_selenium/executors/trio_threads/cdp/event_breakpoints.py +37 -0
- osn_selenium/executors/trio_threads/cdp/extensions.py +52 -0
- osn_selenium/executors/trio_threads/cdp/fed_cm.py +54 -0
- osn_selenium/executors/trio_threads/cdp/fetch.py +105 -0
- osn_selenium/executors/trio_threads/cdp/file_system.py +31 -0
- osn_selenium/executors/trio_threads/cdp/headless_experimental.py +54 -0
- osn_selenium/executors/trio_threads/cdp/heap_profiler.py +102 -0
- osn_selenium/executors/trio_threads/cdp/indexed_db.py +155 -0
- osn_selenium/executors/trio_threads/cdp/input.py +242 -0
- osn_selenium/executors/trio_threads/cdp/inspector.py +34 -0
- osn_selenium/executors/trio_threads/cdp/io.py +42 -0
- osn_selenium/executors/trio_threads/cdp/layer_tree.py +84 -0
- osn_selenium/executors/trio_threads/cdp/log.py +44 -0
- osn_selenium/executors/trio_threads/cdp/media.py +30 -0
- osn_selenium/executors/trio_threads/cdp/memory.py +71 -0
- osn_selenium/executors/trio_threads/cdp/network.py +296 -0
- osn_selenium/executors/trio_threads/cdp/overlay.py +183 -0
- osn_selenium/executors/trio_threads/cdp/page.py +374 -0
- osn_selenium/executors/trio_threads/cdp/performance.py +46 -0
- osn_selenium/executors/trio_threads/cdp/performance_timeline.py +36 -0
- osn_selenium/executors/trio_threads/cdp/preload.py +30 -0
- osn_selenium/executors/trio_threads/cdp/profiler.py +71 -0
- osn_selenium/executors/trio_threads/cdp/pwa.py +64 -0
- osn_selenium/executors/trio_threads/cdp/runtime.py +230 -0
- osn_selenium/executors/trio_threads/cdp/schema.py +32 -0
- osn_selenium/executors/trio_threads/cdp/security.py +43 -0
- osn_selenium/executors/trio_threads/cdp/service_worker.py +69 -0
- osn_selenium/executors/trio_threads/cdp/storage.py +162 -0
- osn_selenium/executors/trio_threads/cdp/system_info.py +43 -0
- osn_selenium/executors/trio_threads/cdp/target.py +156 -0
- osn_selenium/executors/trio_threads/cdp/tethering.py +34 -0
- osn_selenium/executors/trio_threads/cdp/tracing.py +71 -0
- osn_selenium/executors/trio_threads/cdp/web_audio.py +37 -0
- osn_selenium/executors/trio_threads/cdp/web_authn.py +95 -0
- osn_selenium/executors/trio_threads/cdp.py +104 -0
- osn_selenium/executors/trio_threads/javascript.py +90 -0
- osn_selenium/executors/unified/__init__.py +1 -0
- osn_selenium/executors/unified/cdp/__init__.py +1 -0
- osn_selenium/executors/unified/cdp/accessibility.py +81 -0
- osn_selenium/executors/unified/cdp/animation.py +50 -0
- osn_selenium/executors/unified/cdp/audits.py +45 -0
- osn_selenium/executors/unified/cdp/autofill.py +41 -0
- osn_selenium/executors/unified/cdp/background_service.py +24 -0
- osn_selenium/executors/unified/cdp/bluetooth_emulation.py +132 -0
- osn_selenium/executors/unified/cdp/browser.py +143 -0
- osn_selenium/executors/unified/cdp/cache_storage.py +69 -0
- osn_selenium/executors/unified/cdp/cast.py +32 -0
- osn_selenium/executors/unified/cdp/console.py +18 -0
- osn_selenium/executors/unified/cdp/css.py +237 -0
- osn_selenium/executors/unified/cdp/debugger.py +243 -0
- osn_selenium/executors/unified/cdp/device_access.py +21 -0
- osn_selenium/executors/unified/cdp/device_orientation.py +18 -0
- osn_selenium/executors/unified/cdp/dom.py +380 -0
- osn_selenium/executors/unified/cdp/dom_debugger.py +65 -0
- osn_selenium/executors/unified/cdp/dom_snapshot.py +58 -0
- osn_selenium/executors/unified/cdp/dom_storage.py +38 -0
- osn_selenium/executors/unified/cdp/emulation.py +312 -0
- osn_selenium/executors/unified/cdp/event_breakpoints.py +24 -0
- osn_selenium/executors/unified/cdp/extensions.py +45 -0
- osn_selenium/executors/unified/cdp/fed_cm.py +51 -0
- osn_selenium/executors/unified/cdp/fetch.py +111 -0
- osn_selenium/executors/unified/cdp/file_system.py +15 -0
- osn_selenium/executors/unified/cdp/headless_experimental.py +38 -0
- osn_selenium/executors/unified/cdp/heap_profiler.py +101 -0
- osn_selenium/executors/unified/cdp/indexed_db.py +157 -0
- osn_selenium/executors/unified/cdp/input.py +254 -0
- osn_selenium/executors/unified/cdp/inspector.py +15 -0
- osn_selenium/executors/unified/cdp/io.py +29 -0
- osn_selenium/executors/unified/cdp/layer_tree.py +71 -0
- osn_selenium/executors/unified/cdp/log.py +29 -0
- osn_selenium/executors/unified/cdp/media.py +15 -0
- osn_selenium/executors/unified/cdp/memory.py +59 -0
- osn_selenium/executors/unified/cdp/network.py +323 -0
- osn_selenium/executors/unified/cdp/overlay.py +209 -0
- osn_selenium/executors/unified/cdp/page.py +410 -0
- osn_selenium/executors/unified/cdp/performance.py +27 -0
- osn_selenium/executors/unified/cdp/performance_timeline.py +17 -0
- osn_selenium/executors/unified/cdp/preload.py +15 -0
- osn_selenium/executors/unified/cdp/profiler.py +55 -0
- osn_selenium/executors/unified/cdp/pwa.py +55 -0
- osn_selenium/executors/unified/cdp/runtime.py +245 -0
- osn_selenium/executors/unified/cdp/schema.py +17 -0
- osn_selenium/executors/unified/cdp/security.py +27 -0
- osn_selenium/executors/unified/cdp/service_worker.py +62 -0
- osn_selenium/executors/unified/cdp/storage.py +178 -0
- osn_selenium/executors/unified/cdp/system_info.py +24 -0
- osn_selenium/executors/unified/cdp/target.py +165 -0
- osn_selenium/executors/unified/cdp/tethering.py +15 -0
- osn_selenium/executors/unified/cdp/tracing.py +62 -0
- osn_selenium/executors/unified/cdp/web_audio.py +18 -0
- osn_selenium/executors/unified/cdp/web_authn.py +103 -0
- osn_selenium/executors/unified/javascript.py +104 -0
- osn_selenium/flags/__init__.py +1 -0
- osn_selenium/flags/_functions.py +45 -0
- osn_selenium/flags/_typehints.py +34 -0
- osn_selenium/flags/_validators.py +101 -0
- osn_selenium/{webdrivers/BaseDriver/flags.py → flags/base.py} +159 -245
- osn_selenium/{webdrivers/Blink/flags.py → flags/blink.py} +130 -374
- osn_selenium/flags/chrome.py +259 -0
- osn_selenium/flags/edge.py +259 -0
- osn_selenium/flags/models/__init__.py +1 -0
- osn_selenium/flags/models/base.py +130 -0
- osn_selenium/flags/models/blink.py +263 -0
- osn_selenium/{webdrivers/Chrome/flags.py → flags/models/chrome.py} +25 -75
- osn_selenium/{webdrivers/Edge/flags.py → flags/models/edge.py} +25 -75
- osn_selenium/flags/models/values.py +44 -0
- osn_selenium/{webdrivers/Yandex/flags.py → flags/models/yandex.py} +26 -76
- osn_selenium/flags/yandex.py +259 -0
- osn_selenium/instances/__init__.py +1 -0
- osn_selenium/instances/_functions.py +242 -0
- osn_selenium/instances/_typehints.py +148 -0
- osn_selenium/instances/_utils.py +143 -0
- osn_selenium/instances/convert.py +287 -0
- osn_selenium/instances/protocols.py +105 -0
- osn_selenium/instances/sync/__init__.py +1 -0
- osn_selenium/instances/sync/action_chains/__init__.py +32 -0
- osn_selenium/instances/sync/action_chains/base.py +74 -0
- osn_selenium/instances/sync/action_chains/click.py +61 -0
- osn_selenium/instances/sync/action_chains/drag_and_drop.py +45 -0
- osn_selenium/instances/sync/action_chains/hm_keyboard.py +37 -0
- osn_selenium/instances/sync/action_chains/hm_move.py +81 -0
- osn_selenium/instances/sync/action_chains/hm_scroll.py +60 -0
- osn_selenium/instances/sync/action_chains/keyboard.py +55 -0
- osn_selenium/instances/sync/action_chains/move.py +46 -0
- osn_selenium/instances/sync/action_chains/scroll.py +43 -0
- osn_selenium/instances/sync/action_chains/utils.py +30 -0
- osn_selenium/instances/sync/alert.py +69 -0
- osn_selenium/instances/sync/browser.py +72 -0
- osn_selenium/instances/sync/browsing_context.py +193 -0
- osn_selenium/instances/sync/dialog.py +81 -0
- osn_selenium/instances/sync/fedcm.py +92 -0
- osn_selenium/instances/sync/mobile.py +75 -0
- osn_selenium/instances/sync/network.py +90 -0
- osn_selenium/instances/sync/permissions.py +80 -0
- osn_selenium/instances/sync/script.py +77 -0
- osn_selenium/instances/sync/shadow_root.py +113 -0
- osn_selenium/instances/sync/storage.py +91 -0
- osn_selenium/instances/sync/switch_to.py +92 -0
- osn_selenium/instances/sync/web_driver_wait.py +83 -0
- osn_selenium/instances/sync/web_element.py +179 -0
- osn_selenium/instances/sync/web_extension.py +77 -0
- osn_selenium/instances/trio_threads/__init__.py +1 -0
- osn_selenium/instances/trio_threads/action_chains/__init__.py +32 -0
- osn_selenium/instances/trio_threads/action_chains/base.py +88 -0
- osn_selenium/instances/trio_threads/action_chains/click.py +71 -0
- osn_selenium/instances/trio_threads/action_chains/drag_and_drop.py +49 -0
- osn_selenium/instances/trio_threads/action_chains/hm_keyboard.py +41 -0
- osn_selenium/instances/trio_threads/action_chains/hm_move.py +91 -0
- osn_selenium/instances/trio_threads/action_chains/hm_scroll.py +66 -0
- osn_selenium/instances/trio_threads/action_chains/keyboard.py +63 -0
- osn_selenium/instances/trio_threads/action_chains/move.py +52 -0
- osn_selenium/instances/trio_threads/action_chains/scroll.py +49 -0
- osn_selenium/instances/trio_threads/action_chains/utils.py +32 -0
- osn_selenium/instances/trio_threads/alert.py +87 -0
- osn_selenium/instances/trio_threads/browser.py +90 -0
- osn_selenium/instances/trio_threads/browsing_context.py +216 -0
- osn_selenium/instances/trio_threads/dialog.py +99 -0
- osn_selenium/instances/trio_threads/fedcm.py +110 -0
- osn_selenium/instances/trio_threads/mobile.py +93 -0
- osn_selenium/instances/trio_threads/network.py +108 -0
- osn_selenium/instances/trio_threads/permissions.py +102 -0
- osn_selenium/instances/trio_threads/script.py +95 -0
- osn_selenium/instances/trio_threads/shadow_root.py +154 -0
- osn_selenium/instances/trio_threads/storage.py +109 -0
- osn_selenium/instances/trio_threads/switch_to.py +124 -0
- osn_selenium/instances/trio_threads/web_driver_wait.py +101 -0
- osn_selenium/instances/trio_threads/web_element.py +217 -0
- osn_selenium/instances/trio_threads/web_extension.py +99 -0
- osn_selenium/instances/unified/__init__.py +1 -0
- osn_selenium/instances/unified/action_chains/__init__.py +22 -0
- osn_selenium/instances/unified/action_chains/base.py +31 -0
- osn_selenium/instances/unified/action_chains/click.py +27 -0
- osn_selenium/instances/unified/action_chains/drag_and_drop.py +24 -0
- osn_selenium/instances/unified/action_chains/hm_keyboard.py +30 -0
- osn_selenium/instances/unified/action_chains/hm_move.py +66 -0
- osn_selenium/instances/unified/action_chains/hm_scroll.py +79 -0
- osn_selenium/instances/unified/action_chains/keyboard.py +24 -0
- osn_selenium/instances/unified/action_chains/move.py +24 -0
- osn_selenium/instances/unified/action_chains/scroll.py +21 -0
- osn_selenium/instances/unified/action_chains/utils.py +19 -0
- osn_selenium/instances/unified/alert.py +29 -0
- osn_selenium/instances/unified/browser.py +33 -0
- osn_selenium/instances/unified/browsing_context.py +151 -0
- osn_selenium/instances/unified/dialog.py +42 -0
- osn_selenium/instances/unified/fedcm.py +48 -0
- osn_selenium/instances/unified/mobile.py +36 -0
- osn_selenium/instances/unified/network.py +50 -0
- osn_selenium/instances/unified/permissions.py +43 -0
- osn_selenium/instances/unified/script.py +38 -0
- osn_selenium/instances/unified/shadow_root.py +46 -0
- osn_selenium/instances/unified/storage.py +48 -0
- osn_selenium/instances/unified/switch_to.py +49 -0
- osn_selenium/instances/unified/web_driver_wait.py +45 -0
- osn_selenium/instances/unified/web_element.py +145 -0
- osn_selenium/instances/unified/web_extension.py +38 -0
- osn_selenium/javascript/__init__.py +1 -0
- osn_selenium/javascript/_functions.py +63 -0
- osn_selenium/javascript/fingerprint/__init__.py +120 -0
- osn_selenium/javascript/fingerprint/_decorators.py +41 -0
- osn_selenium/javascript/fingerprint/_detect/__init__.py +1 -0
- osn_selenium/javascript/fingerprint/_detect/functions.py +253 -0
- osn_selenium/javascript/fingerprint/_detect/templates.py +128 -0
- osn_selenium/javascript/fingerprint/_functions.py +35 -0
- osn_selenium/javascript/fingerprint/_typehints.py +27 -0
- osn_selenium/javascript/fingerprint/registry/__init__.py +7 -0
- osn_selenium/javascript/fingerprint/registry/_core_functions.py +236 -0
- osn_selenium/javascript/fingerprint/registry/_functions.py +923 -0
- osn_selenium/javascript/fingerprint/registry/_typehints.py +6 -0
- osn_selenium/javascript/fingerprint/registry/_utils.py +6 -0
- osn_selenium/javascript/fingerprint/registry/models.py +41 -0
- osn_selenium/javascript/fingerprint/spoof/__init__.py +1 -0
- osn_selenium/javascript/fingerprint/spoof/_functions.py +172 -0
- osn_selenium/javascript/fingerprint/spoof/_templates.py +134 -0
- osn_selenium/javascript/fingerprint/spoof/_typehints.py +22 -0
- osn_selenium/javascript/fingerprint/spoof/core_rules.py +141 -0
- osn_selenium/javascript/fingerprint/spoof/noise.py +51 -0
- osn_selenium/javascript/fingerprint/spoof/rules.py +313 -0
- osn_selenium/javascript/functions.py +44 -0
- osn_selenium/javascript/models.py +35 -0
- osn_selenium/javascript/scripts/start_fingerprint_detection.js +56 -0
- osn_selenium/models.py +94 -0
- osn_selenium/trio_threads_mixin.py +159 -0
- osn_selenium/webdrivers/_args_helpers.py +181 -0
- osn_selenium/webdrivers/_bridges.py +57 -0
- osn_selenium/webdrivers/_decorators.py +83 -0
- osn_selenium/webdrivers/_executable_tables/__init__.py +1 -0
- osn_selenium/webdrivers/_executable_tables/functions.py +113 -0
- osn_selenium/webdrivers/_executable_tables/models.py +19 -0
- osn_selenium/webdrivers/_typehints.py +10 -0
- osn_selenium/webdrivers/protocols.py +50 -0
- osn_selenium/webdrivers/sync/__init__.py +1 -0
- osn_selenium/webdrivers/sync/blink/__init__.py +124 -0
- osn_selenium/webdrivers/sync/blink/base.py +140 -0
- osn_selenium/webdrivers/sync/blink/casting.py +34 -0
- osn_selenium/webdrivers/sync/blink/features.py +28 -0
- osn_selenium/webdrivers/sync/blink/lifecycle.py +66 -0
- osn_selenium/webdrivers/sync/blink/logging.py +25 -0
- osn_selenium/webdrivers/sync/blink/network.py +28 -0
- osn_selenium/webdrivers/sync/blink/settings.py +63 -0
- osn_selenium/webdrivers/sync/chrome/__init__.py +102 -0
- osn_selenium/webdrivers/sync/chrome/base.py +118 -0
- osn_selenium/webdrivers/sync/chrome/lifecycle.py +63 -0
- osn_selenium/webdrivers/sync/chrome/settings.py +58 -0
- osn_selenium/webdrivers/sync/core/__init__.py +100 -0
- osn_selenium/webdrivers/sync/core/actions.py +59 -0
- osn_selenium/webdrivers/sync/core/auth.py +77 -0
- osn_selenium/webdrivers/sync/core/base.py +175 -0
- osn_selenium/webdrivers/sync/core/capture.py +37 -0
- osn_selenium/webdrivers/sync/core/comonents.py +57 -0
- osn_selenium/webdrivers/sync/core/devtools.py +47 -0
- osn_selenium/webdrivers/sync/core/element.py +42 -0
- osn_selenium/webdrivers/sync/core/file.py +40 -0
- osn_selenium/webdrivers/sync/core/lifecycle.py +59 -0
- osn_selenium/webdrivers/sync/core/navigation.py +36 -0
- osn_selenium/webdrivers/sync/core/script.py +53 -0
- osn_selenium/webdrivers/sync/core/settings.py +35 -0
- osn_selenium/webdrivers/sync/core/storage.py +48 -0
- osn_selenium/webdrivers/sync/core/timeouts.py +59 -0
- osn_selenium/webdrivers/sync/core/window.py +99 -0
- osn_selenium/webdrivers/sync/edge/__init__.py +102 -0
- osn_selenium/webdrivers/sync/edge/base.py +114 -0
- osn_selenium/webdrivers/sync/edge/lifecycle.py +63 -0
- osn_selenium/webdrivers/sync/edge/settings.py +58 -0
- osn_selenium/webdrivers/sync/yandex/__init__.py +102 -0
- osn_selenium/webdrivers/sync/yandex/base.py +111 -0
- osn_selenium/webdrivers/sync/yandex/lifecycle.py +63 -0
- osn_selenium/webdrivers/sync/yandex/settings.py +58 -0
- osn_selenium/webdrivers/trio_threads/__init__.py +1 -0
- osn_selenium/webdrivers/trio_threads/blink/__init__.py +134 -0
- osn_selenium/webdrivers/trio_threads/blink/base.py +143 -0
- osn_selenium/webdrivers/trio_threads/blink/casting.py +35 -0
- osn_selenium/webdrivers/trio_threads/blink/features.py +29 -0
- osn_selenium/webdrivers/trio_threads/blink/lifecycle.py +66 -0
- osn_selenium/webdrivers/trio_threads/blink/logging.py +26 -0
- osn_selenium/webdrivers/trio_threads/blink/network.py +29 -0
- osn_selenium/webdrivers/trio_threads/blink/settings.py +63 -0
- osn_selenium/webdrivers/trio_threads/chrome/__init__.py +114 -0
- osn_selenium/webdrivers/trio_threads/chrome/base.py +119 -0
- osn_selenium/webdrivers/trio_threads/chrome/lifecycle.py +63 -0
- osn_selenium/webdrivers/trio_threads/chrome/settings.py +63 -0
- osn_selenium/webdrivers/trio_threads/core/__init__.py +115 -0
- osn_selenium/webdrivers/trio_threads/core/actions.py +72 -0
- osn_selenium/webdrivers/trio_threads/core/auth.py +88 -0
- osn_selenium/webdrivers/trio_threads/core/base.py +199 -0
- osn_selenium/webdrivers/trio_threads/core/capture.py +38 -0
- osn_selenium/webdrivers/trio_threads/core/comonents.py +92 -0
- osn_selenium/webdrivers/trio_threads/core/devtools.py +53 -0
- osn_selenium/webdrivers/trio_threads/core/element.py +58 -0
- osn_selenium/webdrivers/trio_threads/core/file.py +45 -0
- osn_selenium/webdrivers/trio_threads/core/lifecycle.py +60 -0
- osn_selenium/webdrivers/trio_threads/core/navigation.py +41 -0
- osn_selenium/webdrivers/trio_threads/core/script.py +59 -0
- osn_selenium/webdrivers/trio_threads/core/settings.py +36 -0
- osn_selenium/webdrivers/trio_threads/core/storage.py +54 -0
- osn_selenium/webdrivers/trio_threads/core/timeouts.py +60 -0
- osn_selenium/webdrivers/trio_threads/core/window.py +105 -0
- osn_selenium/webdrivers/trio_threads/edge/__init__.py +114 -0
- osn_selenium/webdrivers/trio_threads/edge/base.py +115 -0
- osn_selenium/webdrivers/trio_threads/edge/lifecycle.py +63 -0
- osn_selenium/webdrivers/trio_threads/edge/settings.py +63 -0
- osn_selenium/webdrivers/trio_threads/yandex/__init__.py +114 -0
- osn_selenium/webdrivers/trio_threads/yandex/base.py +112 -0
- osn_selenium/webdrivers/trio_threads/yandex/lifecycle.py +63 -0
- osn_selenium/webdrivers/trio_threads/yandex/settings.py +63 -0
- osn_selenium/webdrivers/unified/__init__.py +1 -0
- osn_selenium/webdrivers/unified/blink/__init__.py +1 -0
- osn_selenium/webdrivers/unified/blink/base.py +135 -0
- osn_selenium/webdrivers/unified/blink/casting.py +30 -0
- osn_selenium/webdrivers/unified/blink/features.py +22 -0
- osn_selenium/webdrivers/unified/blink/lifecycle.py +114 -0
- osn_selenium/webdrivers/unified/blink/logging.py +18 -0
- osn_selenium/webdrivers/unified/blink/network.py +22 -0
- osn_selenium/webdrivers/unified/blink/settings.py +86 -0
- osn_selenium/webdrivers/unified/chrome/__init__.py +1 -0
- osn_selenium/webdrivers/unified/chrome/base.py +58 -0
- osn_selenium/webdrivers/unified/chrome/lifecycle.py +88 -0
- osn_selenium/webdrivers/unified/chrome/settings.py +48 -0
- osn_selenium/webdrivers/unified/core/__init__.py +1 -0
- osn_selenium/webdrivers/unified/core/actions.py +43 -0
- osn_selenium/webdrivers/unified/core/auth.py +70 -0
- osn_selenium/webdrivers/unified/core/base.py +139 -0
- osn_selenium/webdrivers/unified/core/capture.py +32 -0
- osn_selenium/webdrivers/unified/core/components.py +32 -0
- osn_selenium/webdrivers/unified/core/devtools.py +35 -0
- osn_selenium/webdrivers/unified/core/element.py +24 -0
- osn_selenium/webdrivers/unified/core/file.py +35 -0
- osn_selenium/webdrivers/unified/core/lifecycle.py +84 -0
- osn_selenium/webdrivers/unified/core/navigation.py +31 -0
- osn_selenium/webdrivers/unified/core/script.py +32 -0
- osn_selenium/webdrivers/unified/core/settings.py +44 -0
- osn_selenium/webdrivers/unified/core/storage.py +37 -0
- osn_selenium/webdrivers/unified/core/timeouts.py +56 -0
- osn_selenium/webdrivers/unified/core/window.py +135 -0
- osn_selenium/webdrivers/unified/edge/__init__.py +1 -0
- osn_selenium/webdrivers/unified/edge/base.py +56 -0
- osn_selenium/webdrivers/unified/edge/lifecycle.py +88 -0
- osn_selenium/webdrivers/unified/edge/settings.py +48 -0
- osn_selenium/webdrivers/unified/yandex/__init__.py +1 -0
- osn_selenium/webdrivers/unified/yandex/base.py +58 -0
- osn_selenium/webdrivers/unified/yandex/lifecycle.py +58 -0
- osn_selenium/webdrivers/unified/yandex/settings.py +48 -0
- osn_selenium-1.1.0.dist-info/METADATA +252 -0
- osn_selenium-1.1.0.dist-info/RECORD +615 -0
- {osn_selenium-0.0.0.dist-info → osn_selenium-1.1.0.dist-info}/WHEEL +1 -1
- osn_selenium/captcha_workers/__init__.py +0 -26
- osn_selenium/dev_tools/_types.py +0 -22
- osn_selenium/dev_tools/errors.py +0 -89
- osn_selenium/dev_tools/logger.py +0 -558
- osn_selenium/dev_tools/manager.py +0 -1551
- osn_selenium/dev_tools/utils.py +0 -509
- osn_selenium/errors.py +0 -16
- osn_selenium/types.py +0 -118
- osn_selenium/webdrivers/BaseDriver/_utils.py +0 -37
- osn_selenium/webdrivers/BaseDriver/protocols.py +0 -2135
- osn_selenium/webdrivers/BaseDriver/trio_wrapper.py +0 -71
- osn_selenium/webdrivers/BaseDriver/webdriver.py +0 -2626
- osn_selenium/webdrivers/Blink/protocols.py +0 -330
- osn_selenium/webdrivers/Blink/webdriver.py +0 -637
- osn_selenium/webdrivers/Chrome/protocols.py +0 -228
- osn_selenium/webdrivers/Chrome/webdriver.py +0 -394
- osn_selenium/webdrivers/Edge/protocols.py +0 -228
- osn_selenium/webdrivers/Edge/webdriver.py +0 -394
- osn_selenium/webdrivers/Yandex/protocols.py +0 -211
- osn_selenium/webdrivers/Yandex/webdriver.py +0 -350
- osn_selenium/webdrivers/_functions.py +0 -504
- osn_selenium/webdrivers/types.py +0 -390
- osn_selenium-0.0.0.dist-info/METADATA +0 -710
- osn_selenium-0.0.0.dist-info/RECORD +0 -57
- /osn_selenium/{webdrivers/BaseDriver → abstract}/__init__.py +0 -0
- /osn_selenium/{webdrivers/Blink → abstract/executors}/__init__.py +0 -0
- /osn_selenium/{webdrivers/Chrome → abstract/instances}/__init__.py +0 -0
- /osn_selenium/{webdrivers/Edge → abstract/webdriver}/__init__.py +0 -0
- /osn_selenium/{webdrivers/Yandex → dev_tools/logger}/__init__.py +0 -0
- /osn_selenium/{webdrivers/js_scripts → javascript/scripts}/check_element_in_viewport.js +0 -0
- /osn_selenium/{webdrivers/js_scripts → javascript/scripts}/get_document_scroll_size.js +0 -0
- /osn_selenium/{webdrivers/js_scripts → javascript/scripts}/get_element_css.js +0 -0
- /osn_selenium/{webdrivers/js_scripts → javascript/scripts}/get_element_rect_in_viewport.js +0 -0
- /osn_selenium/{webdrivers/js_scripts → javascript/scripts}/get_random_element_point_in_viewport.js +0 -0
- /osn_selenium/{webdrivers/js_scripts → javascript/scripts}/get_viewport_position.js +0 -0
- /osn_selenium/{webdrivers/js_scripts → javascript/scripts}/get_viewport_rect.js +0 -0
- /osn_selenium/{webdrivers/js_scripts → javascript/scripts}/get_viewport_size.js +0 -0
- /osn_selenium/{webdrivers/js_scripts → javascript/scripts}/open_new_tab.js +0 -0
- /osn_selenium/{webdrivers/js_scripts → javascript/scripts}/stop_window_loading.js +0 -0
- {osn_selenium-0.0.0.dist-info → osn_selenium-1.1.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
from osn_selenium.javascript.fingerprint._decorators import indent_code
|
|
3
|
+
from osn_selenium.javascript.fingerprint._functions import add_code_level
|
|
4
|
+
from osn_selenium.javascript.fingerprint.registry.models import RegistryItem
|
|
5
|
+
from osn_selenium.javascript.fingerprint._detect.templates import (
|
|
6
|
+
ARG_WRAPPER_LOGIC,
|
|
7
|
+
CALL_ORIGINAL_METHOD,
|
|
8
|
+
CALL_ORIGINAL_PROP,
|
|
9
|
+
DESCRIPTOR_LOOKUP_METHOD,
|
|
10
|
+
DESCRIPTOR_LOOKUP_PROP,
|
|
11
|
+
HOOK_IIFE_WRAPPER,
|
|
12
|
+
METADATA_PRESERVATION,
|
|
13
|
+
PART_ARG_WRAPPER,
|
|
14
|
+
PART_REPORT,
|
|
15
|
+
PART_SPOOF_METHOD,
|
|
16
|
+
PART_SPOOF_PROP,
|
|
17
|
+
REPORT_LOGIC,
|
|
18
|
+
TARGET_RESOLUTION,
|
|
19
|
+
WRAPPER_CONSTRUCTOR_SKELETON,
|
|
20
|
+
WRAPPER_METHOD_SKELETON,
|
|
21
|
+
WRAPPER_PROP_SKELETON
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
__all__ = [
|
|
26
|
+
"build_function_body",
|
|
27
|
+
"get_arg_wrapper_js",
|
|
28
|
+
"get_constructor_hook_body",
|
|
29
|
+
"get_hook_js",
|
|
30
|
+
"get_method_hook_body",
|
|
31
|
+
"get_prop_hook_body"
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def build_function_body(
|
|
36
|
+
report_js: str,
|
|
37
|
+
arg_wrapper_js: Optional[str],
|
|
38
|
+
call_original: Optional[str],
|
|
39
|
+
spoof_path: Optional[str],
|
|
40
|
+
is_method: bool,
|
|
41
|
+
indent_level: int,
|
|
42
|
+
) -> str:
|
|
43
|
+
"""
|
|
44
|
+
Constructs the internal body of a hook function in JavaScript.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
report_js (str): The JavaScript code for reporting.
|
|
48
|
+
arg_wrapper_js (Optional[str]): The JavaScript code for argument wrapping.
|
|
49
|
+
call_original (Optional[str]): The JavaScript code to call the original method/property.
|
|
50
|
+
spoof_path (Optional[str]): The path key for looking up spoofing modifiers.
|
|
51
|
+
is_method (bool): True if building a method hook, False for a property hook.
|
|
52
|
+
indent_level (int): The indentation level to apply to the generated code.
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
str: The indented JavaScript function body.
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
parts = []
|
|
59
|
+
|
|
60
|
+
if report_js:
|
|
61
|
+
parts.append(PART_REPORT.format(report_logic=report_js))
|
|
62
|
+
|
|
63
|
+
if arg_wrapper_js:
|
|
64
|
+
parts.append(PART_ARG_WRAPPER.format(arg_wrapper_logic=arg_wrapper_js))
|
|
65
|
+
|
|
66
|
+
if call_original:
|
|
67
|
+
parts.append(call_original)
|
|
68
|
+
|
|
69
|
+
if spoof_path:
|
|
70
|
+
template = PART_SPOOF_METHOD if is_method else PART_SPOOF_PROP
|
|
71
|
+
parts.append(template.format(path=spoof_path))
|
|
72
|
+
|
|
73
|
+
raw_body = "\n".join(parts)
|
|
74
|
+
|
|
75
|
+
return add_code_level(code=raw_body, num=indent_level)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
@indent_code
|
|
79
|
+
def get_constructor_hook_body(target: str, report_js: str, arg_wrapper_js: str) -> str:
|
|
80
|
+
"""
|
|
81
|
+
Generates the body of a constructor hook.
|
|
82
|
+
|
|
83
|
+
Args:
|
|
84
|
+
target (str): The JS target class name.
|
|
85
|
+
report_js (str): JavaScript code for reporting usage.
|
|
86
|
+
arg_wrapper_js (str): JavaScript code for wrapping arguments.
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
str: The complete JavaScript code for hooking the constructor via Proxy.
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
resolution = f"const originalClass = window['{target}'];\nif (!originalClass) return;"
|
|
93
|
+
|
|
94
|
+
wrapper_body = build_function_body(
|
|
95
|
+
report_js=report_js,
|
|
96
|
+
arg_wrapper_js=arg_wrapper_js,
|
|
97
|
+
call_original=None,
|
|
98
|
+
spoof_path=None,
|
|
99
|
+
is_method=True,
|
|
100
|
+
indent_level=2,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
wrapper = WRAPPER_CONSTRUCTOR_SKELETON.format(class_name=target, wrapper_body=wrapper_body)
|
|
104
|
+
|
|
105
|
+
return f"{resolution}\n\n{wrapper}"
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@indent_code
|
|
109
|
+
def get_prop_hook_body(target: str, name: str, report_js: str, spoof_path: Optional[str]) -> str:
|
|
110
|
+
"""
|
|
111
|
+
Generates the body of a property getter hook.
|
|
112
|
+
|
|
113
|
+
Args:
|
|
114
|
+
target (str): The JS target object (e.g., 'window').
|
|
115
|
+
name (str): The name of the property.
|
|
116
|
+
report_js (str): JavaScript code for reporting usage.
|
|
117
|
+
spoof_path (Optional[str]): Path key for spoofing logic, if enabled.
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
str: The complete JavaScript code for hooking the property.
|
|
121
|
+
"""
|
|
122
|
+
|
|
123
|
+
lookup = DESCRIPTOR_LOOKUP_PROP.format(prop_name=name)
|
|
124
|
+
resolution = TARGET_RESOLUTION.format(target_object=target, descriptor_lookup=lookup)
|
|
125
|
+
|
|
126
|
+
wrapper_body = build_function_body(
|
|
127
|
+
report_js=report_js,
|
|
128
|
+
arg_wrapper_js=None,
|
|
129
|
+
call_original=CALL_ORIGINAL_PROP,
|
|
130
|
+
spoof_path=spoof_path,
|
|
131
|
+
is_method=False,
|
|
132
|
+
indent_level=1,
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
wrapper = WRAPPER_PROP_SKELETON.format(prop_name=name, wrapper_body=wrapper_body)
|
|
136
|
+
|
|
137
|
+
return f"{resolution}\n\n{wrapper}"
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
@indent_code
|
|
141
|
+
def get_method_hook_body(
|
|
142
|
+
target: str,
|
|
143
|
+
name: str,
|
|
144
|
+
report_js: str,
|
|
145
|
+
arg_wrapper_js: str,
|
|
146
|
+
spoof_path: Optional[str]
|
|
147
|
+
) -> str:
|
|
148
|
+
"""
|
|
149
|
+
Generates the body of a method hook.
|
|
150
|
+
|
|
151
|
+
Args:
|
|
152
|
+
target (str): The JS target object.
|
|
153
|
+
name (str): The name of the method.
|
|
154
|
+
report_js (str): JavaScript code for reporting usage.
|
|
155
|
+
arg_wrapper_js (str): JavaScript code for wrapping arguments.
|
|
156
|
+
spoof_path (Optional[str]): Path key for spoofing logic, if enabled.
|
|
157
|
+
|
|
158
|
+
Returns:
|
|
159
|
+
str: The complete JavaScript code for hooking the method.
|
|
160
|
+
"""
|
|
161
|
+
|
|
162
|
+
lookup = DESCRIPTOR_LOOKUP_METHOD.format(method_name=name)
|
|
163
|
+
resolution = TARGET_RESOLUTION.format(target_object=target, descriptor_lookup=lookup)
|
|
164
|
+
|
|
165
|
+
wrapper_body = build_function_body(
|
|
166
|
+
report_js=report_js,
|
|
167
|
+
arg_wrapper_js=arg_wrapper_js,
|
|
168
|
+
call_original=CALL_ORIGINAL_METHOD,
|
|
169
|
+
spoof_path=spoof_path,
|
|
170
|
+
is_method=True,
|
|
171
|
+
indent_level=1,
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
wrapper = WRAPPER_METHOD_SKELETON.format(method_name=name, wrapper_body=wrapper_body)
|
|
175
|
+
metadata = METADATA_PRESERVATION.format(method_name=name)
|
|
176
|
+
|
|
177
|
+
return f"{resolution}\n\n{wrapper}\n\n{metadata}"
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
@indent_code
|
|
181
|
+
def get_arg_wrapper_js(entry: RegistryItem) -> str:
|
|
182
|
+
"""
|
|
183
|
+
Generates JavaScript code to wrap arguments if required by the registry entry.
|
|
184
|
+
|
|
185
|
+
Args:
|
|
186
|
+
entry (RegistryItem): The registry item containing configuration settings.
|
|
187
|
+
|
|
188
|
+
Returns:
|
|
189
|
+
str: The JavaScript code for argument wrapping, or an empty string if not applicable.
|
|
190
|
+
"""
|
|
191
|
+
|
|
192
|
+
if entry.settings is None:
|
|
193
|
+
return ""
|
|
194
|
+
|
|
195
|
+
index = entry.settings.get("wrapArgIndex")
|
|
196
|
+
|
|
197
|
+
if index is None:
|
|
198
|
+
return ""
|
|
199
|
+
|
|
200
|
+
return ARG_WRAPPER_LOGIC.format(index=index, api=entry.api, name=entry.name or "constructor")
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def get_hook_js(path: str, entry: RegistryItem, is_detected: bool, is_spoofed: bool) -> str:
|
|
204
|
+
"""
|
|
205
|
+
Generates the full IIFE JavaScript hook for a given registry entry.
|
|
206
|
+
|
|
207
|
+
Args:
|
|
208
|
+
path (str): The unique path identifier for the hook.
|
|
209
|
+
entry (RegistryItem): The registry item configuration.
|
|
210
|
+
is_detected (bool): Whether to include detection/reporting logic.
|
|
211
|
+
is_spoofed (bool): Whether to include spoofing logic.
|
|
212
|
+
|
|
213
|
+
Returns:
|
|
214
|
+
str: The generated JavaScript code wrapped in an IIFE guard.
|
|
215
|
+
"""
|
|
216
|
+
|
|
217
|
+
spoof_path = path if is_spoofed else None
|
|
218
|
+
|
|
219
|
+
report_js = ""
|
|
220
|
+
arg_wrapper_js = ""
|
|
221
|
+
|
|
222
|
+
if is_detected:
|
|
223
|
+
name = entry.name if entry.name else "constructor"
|
|
224
|
+
report_js = REPORT_LOGIC.format(api=entry.api, target=entry.target, name=name)
|
|
225
|
+
|
|
226
|
+
if entry.type_ in ("method", "constructor"):
|
|
227
|
+
arg_wrapper_js = get_arg_wrapper_js(entry=entry)
|
|
228
|
+
|
|
229
|
+
if entry.type_ == "method":
|
|
230
|
+
hook_body = get_method_hook_body(
|
|
231
|
+
target=entry.target,
|
|
232
|
+
name=entry.name,
|
|
233
|
+
report_js=report_js,
|
|
234
|
+
arg_wrapper_js=arg_wrapper_js,
|
|
235
|
+
spoof_path=spoof_path,
|
|
236
|
+
)
|
|
237
|
+
elif entry.type_ == "prop":
|
|
238
|
+
hook_body = get_prop_hook_body(
|
|
239
|
+
target=entry.target,
|
|
240
|
+
name=entry.name,
|
|
241
|
+
report_js=report_js,
|
|
242
|
+
spoof_path=spoof_path,
|
|
243
|
+
)
|
|
244
|
+
elif entry.type_ == "constructor":
|
|
245
|
+
hook_body = get_constructor_hook_body(
|
|
246
|
+
target=entry.target,
|
|
247
|
+
report_js=report_js,
|
|
248
|
+
arg_wrapper_js=arg_wrapper_js,
|
|
249
|
+
)
|
|
250
|
+
else:
|
|
251
|
+
return ""
|
|
252
|
+
|
|
253
|
+
return HOOK_IIFE_WRAPPER.format(hook_body=add_code_level(code=hook_body, num=1))
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
__all__ = [
|
|
2
|
+
"ARG_WRAPPER_LOGIC",
|
|
3
|
+
"CALL_ORIGINAL_METHOD",
|
|
4
|
+
"CALL_ORIGINAL_PROP",
|
|
5
|
+
"DESCRIPTOR_LOOKUP_METHOD",
|
|
6
|
+
"DESCRIPTOR_LOOKUP_PROP",
|
|
7
|
+
"HOOK_IIFE_WRAPPER",
|
|
8
|
+
"METADATA_PRESERVATION",
|
|
9
|
+
"PART_ARG_WRAPPER",
|
|
10
|
+
"PART_REPORT",
|
|
11
|
+
"PART_SPOOF_METHOD",
|
|
12
|
+
"PART_SPOOF_PROP",
|
|
13
|
+
"REPORT_LOGIC",
|
|
14
|
+
"TARGET_RESOLUTION",
|
|
15
|
+
"WRAPPER_CONSTRUCTOR_SKELETON",
|
|
16
|
+
"WRAPPER_METHOD_SKELETON",
|
|
17
|
+
"WRAPPER_PROP_SKELETON"
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
HOOK_IIFE_WRAPPER = """
|
|
21
|
+
guard(
|
|
22
|
+
() => {{
|
|
23
|
+
{hook_body}
|
|
24
|
+
}}
|
|
25
|
+
);
|
|
26
|
+
""".strip("\n")
|
|
27
|
+
|
|
28
|
+
TARGET_RESOLUTION = """
|
|
29
|
+
const target = ({target_object}.prototype || {target_object});
|
|
30
|
+
let descriptor, current = target;
|
|
31
|
+
|
|
32
|
+
{descriptor_lookup}
|
|
33
|
+
""".strip("\n")
|
|
34
|
+
|
|
35
|
+
DESCRIPTOR_LOOKUP_METHOD = """
|
|
36
|
+
let original;
|
|
37
|
+
try {{ original = target['{method_name}']; }} catch(e) {{ return; }}
|
|
38
|
+
|
|
39
|
+
if (!original || typeof original !== 'function' || hookedRegistry.has(original)) return;
|
|
40
|
+
""".strip("\n")
|
|
41
|
+
|
|
42
|
+
DESCRIPTOR_LOOKUP_PROP = """
|
|
43
|
+
while (current && !descriptor) {{
|
|
44
|
+
descriptor = Object.getOwnPropertyDescriptor(current, '{prop_name}');
|
|
45
|
+
current = Object.getPrototypeOf(current);
|
|
46
|
+
}}
|
|
47
|
+
|
|
48
|
+
if (!descriptor || !descriptor.get || hookedRegistry.has(descriptor.get)) return;
|
|
49
|
+
|
|
50
|
+
const originalGet = descriptor.get;
|
|
51
|
+
""".strip("\n")
|
|
52
|
+
|
|
53
|
+
WRAPPER_METHOD_SKELETON = """
|
|
54
|
+
const wrapper = function(...args) {{
|
|
55
|
+
{wrapper_body}
|
|
56
|
+
|
|
57
|
+
return result;
|
|
58
|
+
}};
|
|
59
|
+
|
|
60
|
+
hookedRegistry.add(wrapper);
|
|
61
|
+
hookedRegistry.add(original);
|
|
62
|
+
|
|
63
|
+
target['{method_name}'] = wrapper;
|
|
64
|
+
""".strip("\n")
|
|
65
|
+
|
|
66
|
+
WRAPPER_PROP_SKELETON = """
|
|
67
|
+
const wrapperGet = function() {{
|
|
68
|
+
{wrapper_body}
|
|
69
|
+
|
|
70
|
+
return result;
|
|
71
|
+
}};
|
|
72
|
+
|
|
73
|
+
hookedRegistry.add(wrapperGet);
|
|
74
|
+
hookedRegistry.add(originalGet);
|
|
75
|
+
|
|
76
|
+
Object.defineProperty(
|
|
77
|
+
target,
|
|
78
|
+
'{prop_name}',
|
|
79
|
+
{{
|
|
80
|
+
...descriptor,
|
|
81
|
+
get: wrapperGet
|
|
82
|
+
}}
|
|
83
|
+
);
|
|
84
|
+
""".strip("\n")
|
|
85
|
+
|
|
86
|
+
WRAPPER_CONSTRUCTOR_SKELETON = """
|
|
87
|
+
if (hookedRegistry.has(originalClass)) return;
|
|
88
|
+
|
|
89
|
+
const handler = {{
|
|
90
|
+
construct(target, args) {{
|
|
91
|
+
{wrapper_body}
|
|
92
|
+
|
|
93
|
+
return new target(...args);
|
|
94
|
+
}}
|
|
95
|
+
}};
|
|
96
|
+
|
|
97
|
+
try {{
|
|
98
|
+
const wrapped = new Proxy(originalClass, handler);
|
|
99
|
+
window['{class_name}'] = wrapped;
|
|
100
|
+
hookedRegistry.add(wrapped);
|
|
101
|
+
}} catch (e) {{}}
|
|
102
|
+
""".strip("\n")
|
|
103
|
+
|
|
104
|
+
METADATA_PRESERVATION = """
|
|
105
|
+
try {{ Object.defineProperty(wrapper, 'name', {{ value: '{method_name}' }}); }} catch (e) {{}}
|
|
106
|
+
try {{ Object.defineProperty(wrapper, 'toString', {{ value: () => original.toString() }}); }} catch (e) {{}}
|
|
107
|
+
""".strip("\n")
|
|
108
|
+
|
|
109
|
+
CALL_ORIGINAL_METHOD = "let result; try { result = original.apply(this, args); } catch(e) {}"
|
|
110
|
+
CALL_ORIGINAL_PROP = "let result; try { result = originalGet.call(this); } catch(e) {}"
|
|
111
|
+
|
|
112
|
+
PART_REPORT = "{report_logic}"
|
|
113
|
+
PART_ARG_WRAPPER = "{arg_wrapper_logic}"
|
|
114
|
+
PART_SPOOF_METHOD = "if (MODIFIERS['{path}']) {{ result = MODIFIERS['{path}'](result, args); }}"
|
|
115
|
+
PART_SPOOF_PROP = "if (MODIFIERS['{path}']) {{ result = MODIFIERS['{path}'](result); }}"
|
|
116
|
+
|
|
117
|
+
REPORT_LOGIC = "Reporter.send('{api}', '{target}', '{name}');"
|
|
118
|
+
|
|
119
|
+
ARG_WRAPPER_LOGIC = """
|
|
120
|
+
if (typeof args[{index}] === 'function') {{
|
|
121
|
+
const origCb = args[{index}];
|
|
122
|
+
|
|
123
|
+
args[{index}] = function(...cbArgs) {{
|
|
124
|
+
Reporter.send('{api}', '{name}_cb');
|
|
125
|
+
return origCb.apply(this, cbArgs);
|
|
126
|
+
}};
|
|
127
|
+
}}
|
|
128
|
+
""".strip("\n")
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
__all__ = ["add_code_level", "reduce_code_level"]
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def reduce_code_level(code: str, num: int = 1) -> str:
|
|
5
|
+
"""
|
|
6
|
+
Reduces the indentation level of a multi-line string by removing leading tabs.
|
|
7
|
+
|
|
8
|
+
Args:
|
|
9
|
+
code (str): The code block to un-indent.
|
|
10
|
+
num (int): The number of tabs to remove. Defaults to 1.
|
|
11
|
+
|
|
12
|
+
Returns:
|
|
13
|
+
str: The un-indented code.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
reducing = "\t" * num
|
|
17
|
+
|
|
18
|
+
return "\n".join([line.removeprefix(reducing) for line in code.splitlines()])
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def add_code_level(code: str, num: int = 1) -> str:
|
|
22
|
+
"""
|
|
23
|
+
Increases the indentation level of a multi-line string by adding leading tabs.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
code (str): The code block to indent.
|
|
27
|
+
num (int): The number of tabs to add. Defaults to 1.
|
|
28
|
+
|
|
29
|
+
Returns:
|
|
30
|
+
str: The indented code.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
adding = "\t" * num
|
|
34
|
+
|
|
35
|
+
return adding + f"\n{adding}".join(code.splitlines())
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from typing import Union
|
|
2
|
+
from osn_selenium.javascript.fingerprint.spoof.rules import (
|
|
3
|
+
CustomRule,
|
|
4
|
+
RandomArrayNoiseRule,
|
|
5
|
+
RandomArraySetRule,
|
|
6
|
+
RandomItemNoiseRule,
|
|
7
|
+
RandomItemSetRule,
|
|
8
|
+
StaticArrayNoiseRule,
|
|
9
|
+
StaticArraySetRule,
|
|
10
|
+
StaticItemNoiseRule,
|
|
11
|
+
StaticItemSetRule
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
__all__ = ["SPOOF_RULE_TYPEHINT"]
|
|
16
|
+
|
|
17
|
+
SPOOF_RULE_TYPEHINT = Union[
|
|
18
|
+
StaticItemSetRule,
|
|
19
|
+
RandomItemSetRule,
|
|
20
|
+
StaticArraySetRule,
|
|
21
|
+
RandomArraySetRule,
|
|
22
|
+
StaticItemNoiseRule,
|
|
23
|
+
RandomItemNoiseRule,
|
|
24
|
+
StaticArrayNoiseRule,
|
|
25
|
+
RandomArrayNoiseRule,
|
|
26
|
+
CustomRule
|
|
27
|
+
]
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
from typing import (
|
|
2
|
+
Any,
|
|
3
|
+
Dict,
|
|
4
|
+
Iterable,
|
|
5
|
+
Mapping,
|
|
6
|
+
Optional
|
|
7
|
+
)
|
|
8
|
+
from osn_selenium.javascript.fingerprint.registry.models import RegistryItem
|
|
9
|
+
from osn_selenium.javascript.fingerprint.registry._typehints import ITEM_TYPE_TYPEHINT
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"register",
|
|
14
|
+
"register_key_methods",
|
|
15
|
+
"register_keys_methods",
|
|
16
|
+
"register_target_methods",
|
|
17
|
+
"register_targets",
|
|
18
|
+
"register_targets_methods"
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def register(
|
|
23
|
+
registry: Dict[str, RegistryItem],
|
|
24
|
+
target: str,
|
|
25
|
+
key: str,
|
|
26
|
+
type_: ITEM_TYPE_TYPEHINT,
|
|
27
|
+
api: str,
|
|
28
|
+
method: Optional[str],
|
|
29
|
+
settings: Optional[Dict[str, Any]] = None
|
|
30
|
+
) -> Dict[str, RegistryItem]:
|
|
31
|
+
"""
|
|
32
|
+
Registers a single item into the registry.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
registry (Dict[str, RegistryItem]): The registry dictionary to update.
|
|
36
|
+
target (str): The JavaScript target object/class.
|
|
37
|
+
key (str): The unique key for the registry entry.
|
|
38
|
+
type_ (ITEM_TYPE): The type of hook ('method', 'prop', 'constructor').
|
|
39
|
+
api (str): The API category name.
|
|
40
|
+
method (Optional[str]): The name of the method/property, or None.
|
|
41
|
+
settings (Optional[Dict[str, Any]]): Additional configuration settings.
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
Dict[str, RegistryItem]: The updated registry dictionary.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
registry[key] = RegistryItem(target=target, name=method, type=type_, api=api, settings=settings)
|
|
48
|
+
|
|
49
|
+
return registry
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def register_targets_methods(
|
|
53
|
+
registry: Dict[str, RegistryItem],
|
|
54
|
+
targets: Iterable[str],
|
|
55
|
+
type_: ITEM_TYPE_TYPEHINT,
|
|
56
|
+
api: str,
|
|
57
|
+
methods: Iterable[str],
|
|
58
|
+
settings: Optional[Dict[str, Any]] = None
|
|
59
|
+
) -> Dict[str, RegistryItem]:
|
|
60
|
+
"""
|
|
61
|
+
Registers multiple methods for multiple targets.
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
registry (Dict[str, RegistryItem]): The registry to update.
|
|
65
|
+
targets (Iterable[str]): A list of target objects.
|
|
66
|
+
type_ (ITEM_TYPE): The type of the items.
|
|
67
|
+
api (str): The API category.
|
|
68
|
+
methods (Iterable[str]): A list of methods to register for each target.
|
|
69
|
+
settings (Optional[Dict[str, Any]]): Configuration settings.
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
Dict[str, RegistryItem]: The updated registry.
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
for target in targets:
|
|
76
|
+
for method in methods:
|
|
77
|
+
registry = register(
|
|
78
|
+
registry=registry,
|
|
79
|
+
key=f"{target}.{method}",
|
|
80
|
+
target=target,
|
|
81
|
+
type_=type_,
|
|
82
|
+
api=api,
|
|
83
|
+
method=method,
|
|
84
|
+
settings=settings
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
return registry
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def register_targets(
|
|
91
|
+
registry: Dict[str, RegistryItem],
|
|
92
|
+
targets: Iterable[str],
|
|
93
|
+
type_: ITEM_TYPE_TYPEHINT,
|
|
94
|
+
api: str,
|
|
95
|
+
settings: Optional[Dict[str, Any]] = None
|
|
96
|
+
) -> Dict[str, RegistryItem]:
|
|
97
|
+
"""
|
|
98
|
+
Registers multiple targets directly without specific methods.
|
|
99
|
+
|
|
100
|
+
Args:
|
|
101
|
+
registry (Dict[str, RegistryItem]): The registry to update.
|
|
102
|
+
targets (Iterable[str]): A list of target objects.
|
|
103
|
+
type_ (ITEM_TYPE): The type of the items.
|
|
104
|
+
api (str): The API category.
|
|
105
|
+
settings (Optional[Dict[str, Any]]): Configuration settings.
|
|
106
|
+
|
|
107
|
+
Returns:
|
|
108
|
+
Dict[str, RegistryItem]: The updated registry.
|
|
109
|
+
"""
|
|
110
|
+
|
|
111
|
+
for target in targets:
|
|
112
|
+
registry = register(
|
|
113
|
+
registry=registry,
|
|
114
|
+
key=target,
|
|
115
|
+
target=target,
|
|
116
|
+
type_=type_,
|
|
117
|
+
api=api,
|
|
118
|
+
method=None,
|
|
119
|
+
settings=settings
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
return registry
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def register_target_methods(
|
|
126
|
+
registry: Dict[str, RegistryItem],
|
|
127
|
+
target: str,
|
|
128
|
+
type_: ITEM_TYPE_TYPEHINT,
|
|
129
|
+
api: str,
|
|
130
|
+
methods: Iterable[str],
|
|
131
|
+
settings: Optional[Dict[str, Any]] = None
|
|
132
|
+
) -> Dict[str, RegistryItem]:
|
|
133
|
+
"""
|
|
134
|
+
Registers multiple methods for a single target.
|
|
135
|
+
|
|
136
|
+
Args:
|
|
137
|
+
registry (Dict[str, RegistryItem]): The registry to update.
|
|
138
|
+
target (str): The target object.
|
|
139
|
+
type_ (ITEM_TYPE): The type of the items.
|
|
140
|
+
api (str): The API category.
|
|
141
|
+
methods (Iterable[str]): A list of methods/properties to register.
|
|
142
|
+
settings (Optional[Dict[str, Any]]): Configuration settings.
|
|
143
|
+
|
|
144
|
+
Returns:
|
|
145
|
+
Dict[str, RegistryItem]: The updated registry.
|
|
146
|
+
"""
|
|
147
|
+
|
|
148
|
+
for method in methods:
|
|
149
|
+
registry = register(
|
|
150
|
+
registry=registry,
|
|
151
|
+
key=f"{target}.{method}",
|
|
152
|
+
target=target,
|
|
153
|
+
type_=type_,
|
|
154
|
+
api=api,
|
|
155
|
+
method=method,
|
|
156
|
+
settings=settings
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
return registry
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def register_keys_methods(
|
|
163
|
+
registry: Dict[str, RegistryItem],
|
|
164
|
+
keys: Mapping[str, str],
|
|
165
|
+
type_: ITEM_TYPE_TYPEHINT,
|
|
166
|
+
api: str,
|
|
167
|
+
methods: Iterable[str],
|
|
168
|
+
settings: Optional[Dict[str, Any]] = None
|
|
169
|
+
) -> Dict[str, RegistryItem]:
|
|
170
|
+
"""
|
|
171
|
+
Registers methods for multiple targets defined by a mapping of keys to targets.
|
|
172
|
+
|
|
173
|
+
Args:
|
|
174
|
+
registry (Dict[str, RegistryItem]): The registry to update.
|
|
175
|
+
keys (Mapping[str, str]): Map where key is the registry key prefix and value is the target object.
|
|
176
|
+
type_ (ITEM_TYPE): The type of the items.
|
|
177
|
+
api (str): The API category.
|
|
178
|
+
methods (Iterable[str]): A list of methods to register.
|
|
179
|
+
settings (Optional[Dict[str, Any]]): Configuration settings.
|
|
180
|
+
|
|
181
|
+
Returns:
|
|
182
|
+
Dict[str, RegistryItem]: The updated registry.
|
|
183
|
+
"""
|
|
184
|
+
|
|
185
|
+
for key, target in keys.items():
|
|
186
|
+
for method in methods:
|
|
187
|
+
registry = register(
|
|
188
|
+
registry=registry,
|
|
189
|
+
key=f"{key}.{method}",
|
|
190
|
+
target=target,
|
|
191
|
+
type_=type_,
|
|
192
|
+
api=api,
|
|
193
|
+
method=method,
|
|
194
|
+
settings=settings
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
return registry
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def register_key_methods(
|
|
201
|
+
registry: Dict[str, RegistryItem],
|
|
202
|
+
key: str,
|
|
203
|
+
target: str,
|
|
204
|
+
type_: ITEM_TYPE_TYPEHINT,
|
|
205
|
+
api: str,
|
|
206
|
+
methods: Iterable[str],
|
|
207
|
+
settings: Optional[Dict[str, Any]] = None
|
|
208
|
+
) -> Dict[str, RegistryItem]:
|
|
209
|
+
"""
|
|
210
|
+
Registers multiple methods for a single target using a custom key prefix.
|
|
211
|
+
|
|
212
|
+
Args:
|
|
213
|
+
registry (Dict[str, RegistryItem]): The registry to update.
|
|
214
|
+
key (str): The prefix to use for the registry keys.
|
|
215
|
+
target (str): The target object.
|
|
216
|
+
type_ (ITEM_TYPE): The type of the items.
|
|
217
|
+
api (str): The API category.
|
|
218
|
+
methods (Iterable[str]): A list of methods to register.
|
|
219
|
+
settings (Optional[Dict[str, Any]]): Configuration settings.
|
|
220
|
+
|
|
221
|
+
Returns:
|
|
222
|
+
Dict[str, RegistryItem]: The updated registry.
|
|
223
|
+
"""
|
|
224
|
+
|
|
225
|
+
for method in methods:
|
|
226
|
+
registry = register(
|
|
227
|
+
registry=registry,
|
|
228
|
+
key=f"{key}.{method}",
|
|
229
|
+
target=target,
|
|
230
|
+
type_=type_,
|
|
231
|
+
api=api,
|
|
232
|
+
method=method,
|
|
233
|
+
settings=settings
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
return registry
|