amazon-auth 0.2.5__tar.gz → 0.2.6__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.5 → amazon_auth-0.2.6}/PKG-INFO +7 -1
  2. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/README.md +6 -0
  3. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazon_auth.egg-info/PKG-INFO +7 -1
  4. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazonauth/__init__.py +1 -1
  5. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazonauth/conf.py +22 -5
  6. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/tests/test_conf.py +25 -0
  7. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/LICENSE +0 -0
  8. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazon_auth.egg-info/SOURCES.txt +0 -0
  9. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazon_auth.egg-info/dependency_links.txt +0 -0
  10. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazon_auth.egg-info/requires.txt +0 -0
  11. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazon_auth.egg-info/top_level.txt +0 -0
  12. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazonauth/cli.py +0 -0
  13. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazonauth/constants.py +0 -0
  14. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazonauth/contrib/__init__.py +0 -0
  15. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazonauth/contrib/browser/__init__.py +0 -0
  16. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazonauth/contrib/browser/playwright.py +0 -0
  17. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazonauth/contrib/waf/__init__.py +0 -0
  18. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazonauth/contrib/waf/anticaptcha.py +0 -0
  19. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazonauth/contrib/waf/base.py +0 -0
  20. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazonauth/contrib/waf/capsolver.py +0 -0
  21. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazonauth/contrib/waf/twocaptcha.py +0 -0
  22. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazonauth/exception.py +0 -0
  23. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazonauth/forms.py +0 -0
  24. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazonauth/py.typed +0 -0
  25. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazonauth/region_data.py +0 -0
  26. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazonauth/selectors.py +0 -0
  27. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazonauth/session.py +0 -0
  28. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/amazonauth/util.py +0 -0
  29. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/pyproject.toml +0 -0
  30. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/setup.cfg +0 -0
  31. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/tests/test_cli.py +0 -0
  32. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/tests/test_constants.py +0 -0
  33. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/tests/test_package.py +0 -0
  34. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/tests/test_session.py +0 -0
  35. {amazon_auth-0.2.5 → amazon_auth-0.2.6}/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.5
3
+ Version: 0.2.6
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>
@@ -126,6 +126,12 @@ PlaywrightBrowserLogin(amazon_session).login()
126
126
 
127
127
  The session is persisted, so `AmazonSession().login()` reuses it without credentials.
128
128
 
129
+ ### Building on `amazon-auth`
130
+
131
+ `amazon-auth` is meant to be built on: packages that read more of Amazon's website, like
132
+ [`amazon-orders`](https://amazon-orders.readthedocs.io), subclass its config, session, constants and selectors, and
133
+ register its CLI commands. See [Building on `amazon-auth`](https://amazon-auth.readthedocs.io/downstream.html).
134
+
129
135
  ## Documentation
130
136
 
131
137
  For more advanced usage, `amazon-auth`'s official documentation is available
@@ -56,6 +56,12 @@ PlaywrightBrowserLogin(amazon_session).login()
56
56
 
57
57
  The session is persisted, so `AmazonSession().login()` reuses it without credentials.
58
58
 
59
+ ### Building on `amazon-auth`
60
+
61
+ `amazon-auth` is meant to be built on: packages that read more of Amazon's website, like
62
+ [`amazon-orders`](https://amazon-orders.readthedocs.io), subclass its config, session, constants and selectors, and
63
+ register its CLI commands. See [Building on `amazon-auth`](https://amazon-auth.readthedocs.io/downstream.html).
64
+
59
65
  ## Documentation
60
66
 
61
67
  For more advanced usage, `amazon-auth`'s official documentation is available
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: amazon-auth
3
- Version: 0.2.5
3
+ Version: 0.2.6
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>
@@ -126,6 +126,12 @@ PlaywrightBrowserLogin(amazon_session).login()
126
126
 
127
127
  The session is persisted, so `AmazonSession().login()` reuses it without credentials.
128
128
 
129
+ ### Building on `amazon-auth`
130
+
131
+ `amazon-auth` is meant to be built on: packages that read more of Amazon's website, like
132
+ [`amazon-orders`](https://amazon-orders.readthedocs.io), subclass its config, session, constants and selectors, and
133
+ register its CLI commands. See [Building on `amazon-auth`](https://amazon-auth.readthedocs.io/downstream.html).
134
+
129
135
  ## Documentation
130
136
 
131
137
  For more advanced usage, `amazon-auth`'s official documentation is available
@@ -1,4 +1,4 @@
1
1
  __copyright__ = "Copyright (c) 2026 Alex Laird"
2
2
  __license__ = "MIT"
3
- __version__ = "0.2.5"
3
+ __version__ = "0.2.6"
4
4
  __muppets__ = "no strings attached"
@@ -5,6 +5,7 @@ import inspect
5
5
  import logging
6
6
  import os
7
7
  import threading
8
+ import warnings
8
9
  from typing import Any, Dict, Optional, Set, Union
9
10
  from urllib.parse import urlparse
10
11
 
@@ -66,7 +67,7 @@ class AmazonAuthConfig:
66
67
  #: The path to use for the config file.
67
68
  self.config_path: str = os.path.join(DEFAULT_CONFIG_DIR, "config.yml") if config_path is None else config_path
68
69
 
69
- self._data: Dict[str, Any] = self._default_data()
70
+ self._data: Dict[str, Any] = self._defaults()
70
71
  self._environment: Dict[str, Any] = self.read_environment()
71
72
  self._resolved_classes: Dict[str, Any] = {}
72
73
  self._assigned_classes: Dict[str, Any] = {}
@@ -100,7 +101,7 @@ class AmazonAuthConfig:
100
101
  :return: The config values set in the environment, by config key.
101
102
  :raises AmazonAuthError: If the value of a key with a default is not valid YAML.
102
103
  """
103
- default_data = cls._default_data()
104
+ default_data = cls._defaults()
104
105
  environment = {}
105
106
  for name, value in os.environ.items():
106
107
  if not name.startswith(ENVIRONMENT_VARIABLE_PREFIX) or not value:
@@ -136,9 +137,10 @@ class AmazonAuthConfig:
136
137
  return self._data.get(key)
137
138
 
138
139
  @staticmethod
139
- def _default_data() -> Dict[str, Any]:
140
+ def default_data() -> Dict[str, Any]:
140
141
  """
141
- Provision the default config values.
142
+ Provision the default config values. A subclass with config keys of its own adds them here, on top of
143
+ ``AmazonAuthConfig.default_data()``.
142
144
 
143
145
  :return: The default config values.
144
146
  """
@@ -169,6 +171,21 @@ class AmazonAuthConfig:
169
171
  "max_auth_retries": 1
170
172
  }
171
173
 
174
+ @staticmethod
175
+ def _default_data() -> Dict[str, Any]:
176
+ """
177
+ Deprecated, use :func:`default_data` instead. To be removed in 1.0.
178
+ """
179
+ warnings.warn("_default_data() is deprecated and will be removed in 1.0. Override default_data() instead.",
180
+ DeprecationWarning, stacklevel=2)
181
+ return AmazonAuthConfig.default_data()
182
+
183
+ @classmethod
184
+ def _defaults(cls) -> Dict[str, Any]:
185
+ if cls._default_data is not AmazonAuthConfig._default_data:
186
+ return cls._default_data()
187
+ return cls.default_data()
188
+
172
189
  @staticmethod
173
190
  def _default_cookie_jar_path() -> str:
174
191
  return os.path.join(DEFAULT_CONFIG_DIR, "cookies.json")
@@ -196,7 +213,7 @@ class AmazonAuthConfig:
196
213
  try:
197
214
  return util.load_class(module_path.split("."), class_name)
198
215
  except ModuleNotFoundError as e:
199
- default_class_path = self._default_data()[key]
216
+ default_class_path = self._defaults()[key]
200
217
  if (class_path == default_class_path or not e.name or
201
218
  not (module_path == e.name or module_path.startswith(f"{e.name}."))):
202
219
  raise
@@ -389,3 +389,28 @@ some_custom_config: {custom_config}
389
389
 
390
390
  # THEN
391
391
  self.assertEqual("/some/cookies.json", config.cookie_jar_path)
392
+
393
+ def test_downstream_config_adds_its_own_defaults(self):
394
+ # WHEN
395
+ config = DownstreamConfig(data={})
396
+
397
+ # THEN
398
+ self.assertEqual(20, config.page_size)
399
+ self.assertEqual(AmazonAuthConfig.default_data()["max_auth_attempts"], config.max_auth_attempts)
400
+
401
+ def test_downstream_config_reads_its_own_default_key_from_the_environment_as_yaml(self):
402
+ # WHEN
403
+ with patch.dict(os.environ, {"AMAZON_PAGE_SIZE": "30"}):
404
+ config = DownstreamConfig(data={})
405
+
406
+ # THEN
407
+ self.assertEqual(30, config.page_size)
408
+
409
+
410
+ class DownstreamConfig(AmazonAuthConfig):
411
+ @staticmethod
412
+ def default_data():
413
+ return {
414
+ **AmazonAuthConfig.default_data(),
415
+ "page_size": 20,
416
+ }
File without changes
File without changes
File without changes