amazon-auth 0.2.2__tar.gz → 0.2.4__tar.gz

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 (35) hide show
  1. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/PKG-INFO +1 -1
  2. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazon_auth.egg-info/PKG-INFO +1 -1
  3. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazonauth/__init__.py +1 -1
  4. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazonauth/contrib/waf/base.py +20 -11
  5. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazonauth/util.py +1 -0
  6. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/tests/test_conf.py +21 -0
  7. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/LICENSE +0 -0
  8. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/README.md +0 -0
  9. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazon_auth.egg-info/SOURCES.txt +0 -0
  10. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazon_auth.egg-info/dependency_links.txt +0 -0
  11. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazon_auth.egg-info/requires.txt +0 -0
  12. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazon_auth.egg-info/top_level.txt +0 -0
  13. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazonauth/cli.py +0 -0
  14. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazonauth/conf.py +0 -0
  15. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazonauth/constants.py +0 -0
  16. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazonauth/contrib/__init__.py +0 -0
  17. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazonauth/contrib/browser/__init__.py +0 -0
  18. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazonauth/contrib/browser/playwright.py +0 -0
  19. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazonauth/contrib/waf/__init__.py +0 -0
  20. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazonauth/contrib/waf/anticaptcha.py +0 -0
  21. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazonauth/contrib/waf/capsolver.py +0 -0
  22. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazonauth/contrib/waf/twocaptcha.py +0 -0
  23. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazonauth/exception.py +0 -0
  24. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazonauth/forms.py +0 -0
  25. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazonauth/py.typed +0 -0
  26. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazonauth/region_data.py +0 -0
  27. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazonauth/selectors.py +0 -0
  28. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/amazonauth/session.py +0 -0
  29. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/pyproject.toml +0 -0
  30. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/setup.cfg +0 -0
  31. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/tests/test_cli.py +0 -0
  32. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/tests/test_constants.py +0 -0
  33. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/tests/test_package.py +0 -0
  34. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/tests/test_session.py +0 -0
  35. {amazon_auth-0.2.2 → amazon_auth-0.2.4}/tests/test_util.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: amazon-auth
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: Sign in to Amazon's consumer website and reuse the session from Python.
5
5
  Author-email: Alex Laird <contact@alexlaird.com>
6
6
  Maintainer-email: Alex Laird <contact@alexlaird.com>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: amazon-auth
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: Sign in to Amazon's consumer website and reuse the session from Python.
5
5
  Author-email: Alex Laird <contact@alexlaird.com>
6
6
  Maintainer-email: Alex Laird <contact@alexlaird.com>
@@ -1,4 +1,4 @@
1
1
  __copyright__ = "Copyright (c) 2026 Alex Laird"
2
2
  __license__ = "MIT"
3
- __version__ = "0.2.2"
3
+ __version__ = "0.2.4"
4
4
  __muppets__ = "no strings attached"
@@ -44,21 +44,30 @@ class AwsWafForm(AuthForm):
44
44
  def __init__(self,
45
45
  config: AmazonAuthConfig) -> None:
46
46
  super().__init__(config, selector=None)
47
- config_key = self.API_KEY_ENV_VAR.lower()
48
- api_key = (os.environ.get(self.API_KEY_ENV_VAR)
49
- or getattr(config, config_key, None)
50
- or "")
51
- if not api_key:
47
+ self._api_key: str = (os.environ.get(self.API_KEY_ENV_VAR)
48
+ or getattr(config, self.API_KEY_ENV_VAR.lower(), None)
49
+ or "")
50
+ self._goku: Optional[Dict[str, Any]] = None
51
+ self._challenge_script: Optional[str] = None
52
+
53
+ @property
54
+ def api_key(self) -> str:
55
+ """
56
+ The third-party solver API key. Resolved (in order of precedence) from the :attr:`API_KEY_ENV_VAR`
57
+ environment variable, then from the lowercase config key of the same name on
58
+ :class:`~amazonauth.conf.AmazonAuthConfig`. It's only required to solve a challenge, so a solver configured
59
+ without one doesn't keep a session from being created.
60
+
61
+ :raises AmazonAuthError: if neither is set.
62
+ """
63
+ if not self._api_key:
64
+ config_key = self.API_KEY_ENV_VAR.lower()
52
65
  raise AmazonAuthError(
53
66
  f"{type(self).__name__} requires the {self.API_KEY_ENV_VAR} "
54
67
  f"environment variable, or the {config_key} config key, to be set."
55
68
  )
56
- #: The third-party solver API key. Resolved (in order of precedence) from the
57
- #: :attr:`API_KEY_ENV_VAR` environment variable, then from the lowercase config key
58
- #: of the same name on :class:`~amazonauth.conf.AmazonAuthConfig`.
59
- self.api_key: str = api_key
60
- self._goku: Optional[Dict[str, Any]] = None
61
- self._challenge_script: Optional[str] = None
69
+
70
+ return self._api_key
62
71
 
63
72
  def select_form(self,
64
73
  amazon_session: "AmazonSession",
@@ -156,6 +156,7 @@ def write_private_file(path: str,
156
156
  :param path: The file to write.
157
157
  :param content: The text to write.
158
158
  """
159
+ path = os.path.realpath(path)
159
160
  file_descriptor, temp_path = tempfile.mkstemp(dir=os.path.dirname(path) or ".",
160
161
  prefix=f".{os.path.basename(path)}-", suffix=".tmp")
161
162
  try:
@@ -188,6 +188,27 @@ some_custom_config: {custom_config}
188
188
  self.assertEqual(0o600, os.stat(config_path).st_mode & 0o777)
189
189
  self.assertEqual([], [name for name in os.listdir(os.path.dirname(config_path)) if name.endswith(".tmp")])
190
190
 
191
+ @unittest.skipIf(sys.platform == "win32", reason="Windows does not support POSIX file permissions")
192
+ def test_saved_config_is_written_through_a_symlink(self):
193
+ # GIVEN
194
+ target_dir = os.path.join(conf.DEFAULT_CONFIG_DIR, "dotfiles")
195
+ os.makedirs(target_dir, exist_ok=True)
196
+ target_path = os.path.join(target_dir, "config.yml")
197
+ with open(target_path, "w") as f:
198
+ f.write("max_auth_attempts: 3\n")
199
+ config_path = os.path.join(conf.DEFAULT_CONFIG_DIR, "linked-config.yml")
200
+ os.symlink(target_path, config_path)
201
+ config = AmazonAuthConfig(config_path=config_path)
202
+
203
+ # WHEN
204
+ config.update_config("max_auth_attempts", 7)
205
+
206
+ # THEN
207
+ self.assertTrue(os.path.islink(config_path))
208
+ with open(target_path, "r") as f:
209
+ self.assertEqual(7, yaml.safe_load(f)["max_auth_attempts"])
210
+ self.assertEqual(0o600, os.stat(target_path).st_mode & 0o777)
211
+
191
212
  def test_update_config(self):
192
213
  # GIVEN
193
214
  config = AmazonAuthConfig(data={
File without changes
File without changes
File without changes
File without changes