fancy-amazon-ses 0.1.0__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.
@@ -0,0 +1,24 @@
1
+ node_modules/
2
+ dist/
3
+ vendor/
4
+ .venv/
5
+ __pycache__/
6
+ *.egg-info/
7
+ .pytest_cache/
8
+ .ruff_cache/
9
+ .mypy_cache/
10
+
11
+ # Lockfiles are NOT source of a generated repo.
12
+ #
13
+ # The generator cannot emit one -- a lockfile is the result of a network
14
+ # resolve -- and "a provider repo must be generated and re-generatable" is the
15
+ # constraint the whole estate rests on. At a few hundred repos, a committed
16
+ # lockfile each is a few hundred files nothing can regenerate and a few hundred
17
+ # Dependabot surfaces.
18
+ #
19
+ # The trade is real and worth stating: CI resolves fresh on every run, so an
20
+ # upstream release inside the declared range can break a build with no change
21
+ # here. That is early warning rather than a surprise at publish time, and the
22
+ # ranges are deliberately narrow (>=X <2.0, never a caret on a 0.x).
23
+ composer.lock
24
+ package-lock.json
@@ -0,0 +1,73 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@particle-academy/amazon-ses-ui`,
4
+ `@particle-academy/amazon-ses-js`, `particle-academy/amazon-ses-php` and
5
+ `fancy-amazon-ses`.
6
+
7
+ The four packages share one version, because they are generated from one
8
+ `provider/` definition and a version that meant something different in each
9
+ would be a version nobody could reason about.
10
+
11
+ ## [0.1.0] — 2026-08-20
12
+
13
+ First release. Provider five, and the first whose requests are **signed**
14
+ rather than presented.
15
+
16
+ ### Added
17
+
18
+ - `email_send` — send an email. `POST /v2/email/outbound-emails`.
19
+ - AWS **Signature Version 4** signing, pinned against AWS's own published test
20
+ vectors.
21
+ - A faker for it, so the node runs on a canvas with no AWS account.
22
+
23
+ ### Why SES, and not the next name on the list
24
+
25
+ Every provider before this one presents a static credential: a bearer token, a
26
+ header, a path segment. SES **signs**. The method, the path, the query, the
27
+ headers and a hash of the body go into a canonical form, which is hashed and
28
+ HMAC'd with a key derived in four steps from the secret, the date, the region
29
+ and the service.
30
+
31
+ Every fact here is read from **AWS's own service model**
32
+ (`botocore/data/sesv2/2019-09-27/service-2.json`), not from memory: the
33
+ endpoint, the path, the request shape, the response shape, and
34
+ `signatureVersion: v4` with `signingName: ses`.
35
+
36
+ ### `restricted-reach` — the value that existed and had never been used
37
+
38
+ A new SES account is in the **sandbox**, and it is the reason that value is in
39
+ the vocabulary. The endpoint is identical, the credentials are identical, the
40
+ request is identical, and the API answers **200 with a MessageId** — but the
41
+ mail only reaches addresses you have verified. Everyone else is silently
42
+ discarded.
43
+
44
+ So a sandbox run looks completely successful and reached nobody, which is why
45
+ `restricted-reach` **cannot be selected as a mode**: there is nothing to
46
+ select. You leave the sandbox by asking AWS for production access, not by
47
+ pointing at a different host.
48
+
49
+ `MessageId` therefore means **accepted**, not delivered. That distinction is in
50
+ the output shape rather than left to be discovered.
51
+
52
+ ### Three other firsts
53
+
54
+ - **A base URL that is not the same string for everybody.** The host carries
55
+ the region (`https://email.{region}.amazonaws.com`), which is a
56
+ per-connection credential. The placeholder is checked against the declared
57
+ credentials — and refused if it names a secret, because a host is recorded by
58
+ every proxy and error reporter between here and the provider.
59
+ - **A five-level nested body.** `Content.Simple.Body.Text.Data` is deeper than
60
+ anything HubSpot needed, and it is what proves the nesting is arbitrary-depth
61
+ rather than one level.
62
+ - **A signer that reads the clock.** A signature is only valid for a window, so
63
+ the time is an argument rather than a call to `now()` — otherwise the
64
+ signature could not be tested for a fixed answer.
65
+
66
+ ### On not taking a dependency
67
+
68
+ The AWS SDK is enormous and would be one SDK per provider at scale. SigV4 is
69
+ about eighty lines in each language, it is pinned against AWS's own vectors,
70
+ and it is the same algorithm for every AWS service — so the next one costs
71
+ nothing.
72
+
73
+ [0.1.0]: https://github.com/Fancy-Friends/amazon-ses/releases/tag/v0.1.0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Particle Academy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,73 @@
1
+ Metadata-Version: 2.5
2
+ Name: fancy-amazon-ses
3
+ Version: 0.1.0
4
+ Summary: Amazon SES for Python — the service descriptor, its faker, its webhook verification, and one function per operation. Plain HTTP; no vendor SDK.
5
+ Project-URL: Homepage, https://github.com/Fancy-Friends/amazon-ses
6
+ Project-URL: Issues, https://github.com/Fancy-Friends/amazon-ses/issues
7
+ Project-URL: Source, https://github.com/Fancy-Friends/amazon-ses
8
+ Author: Particle Academy
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: amazon_ses,api,connector,email,fancy-flow,particle-academy
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Libraries
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.11
21
+ Description-Content-Type: text/markdown
22
+
23
+ # Amazon SES
24
+
25
+ Amazon SES for [fancy-flow][flow] — as **four imported, versioned packages**, one
26
+ per runtime. Not vendored source: a copy cannot be upgraded, and third-party APIs
27
+ change.
28
+
29
+ [flow]: https://github.com/Particle-Academy/fancy-flow
30
+
31
+ | Runtime | Package | Install |
32
+ |---|---|---|
33
+ | Authoring surface (every host) | `@particle-academy/amazon-ses-ui` | `npm install @particle-academy/amazon-ses-ui` |
34
+ | Node | `@particle-academy/amazon-ses-js` | `npm install @particle-academy/amazon-ses-js` |
35
+ | PHP 8.4+ | `particle-academy/amazon-ses-php` | `composer require particle-academy/amazon-ses-php` |
36
+ | Python 3.11+ | `fancy-amazon-ses` | `pip install fancy-amazon-ses` |
37
+
38
+ The `ui` package is the editor surface and is React on every host — a PHP or
39
+ Python project installs it *and* its own runtime package, and never the `js` one.
40
+
41
+ ## What it costs you
42
+
43
+ One dependency: `@particle-academy/fancy-connector-core` (or
44
+ `particle-academy/fancy-connector-core` on Composer), which the `js` and `php`
45
+ packages pull in themselves. The Python package has **zero** runtime
46
+ dependencies.
47
+
48
+ **No Amazon SES SDK.** Plain HTTP, deliberately: a vendor SDK is third-party code
49
+ subject to the kit's full approval bar, and one per provider is hundreds of
50
+ dependencies nobody is tracking.
51
+
52
+ ## Run it before you have credentials
53
+
54
+ Every operation ships a **faker**, whether or not Amazon SES has a sandbox. Set a
55
+ node's mode to `fake` and it returns the shape Amazon SES actually publishes — the
56
+ same field names, deterministically — so you can wire the downstream nodes before
57
+ touching an account, a key, or a network.
58
+
59
+ ## This repository is generated
60
+
61
+ `provider/` is the source. Everything under `packages/` is emitted from it and
62
+ **must not be hand-edited** — CI regenerates and diffs on every push, and the
63
+ next protocol sync destroys anything it finds. See [`AGENTS.md`](AGENTS.md).
64
+
65
+ ## Two namespaces, which do not match on purpose
66
+
67
+ The repo is `github.com/Fancy-Friends/amazon-ses`; the packages publish under
68
+ `particle-academy`. Nothing derives one from the other — the names come from
69
+ weaver's `friends.json` and nowhere else.
70
+
71
+ ## Licence
72
+
73
+ MIT.
@@ -0,0 +1,51 @@
1
+ # Amazon SES
2
+
3
+ Amazon SES for [fancy-flow][flow] — as **four imported, versioned packages**, one
4
+ per runtime. Not vendored source: a copy cannot be upgraded, and third-party APIs
5
+ change.
6
+
7
+ [flow]: https://github.com/Particle-Academy/fancy-flow
8
+
9
+ | Runtime | Package | Install |
10
+ |---|---|---|
11
+ | Authoring surface (every host) | `@particle-academy/amazon-ses-ui` | `npm install @particle-academy/amazon-ses-ui` |
12
+ | Node | `@particle-academy/amazon-ses-js` | `npm install @particle-academy/amazon-ses-js` |
13
+ | PHP 8.4+ | `particle-academy/amazon-ses-php` | `composer require particle-academy/amazon-ses-php` |
14
+ | Python 3.11+ | `fancy-amazon-ses` | `pip install fancy-amazon-ses` |
15
+
16
+ The `ui` package is the editor surface and is React on every host — a PHP or
17
+ Python project installs it *and* its own runtime package, and never the `js` one.
18
+
19
+ ## What it costs you
20
+
21
+ One dependency: `@particle-academy/fancy-connector-core` (or
22
+ `particle-academy/fancy-connector-core` on Composer), which the `js` and `php`
23
+ packages pull in themselves. The Python package has **zero** runtime
24
+ dependencies.
25
+
26
+ **No Amazon SES SDK.** Plain HTTP, deliberately: a vendor SDK is third-party code
27
+ subject to the kit's full approval bar, and one per provider is hundreds of
28
+ dependencies nobody is tracking.
29
+
30
+ ## Run it before you have credentials
31
+
32
+ Every operation ships a **faker**, whether or not Amazon SES has a sandbox. Set a
33
+ node's mode to `fake` and it returns the shape Amazon SES actually publishes — the
34
+ same field names, deterministically — so you can wire the downstream nodes before
35
+ touching an account, a key, or a network.
36
+
37
+ ## This repository is generated
38
+
39
+ `provider/` is the source. Everything under `packages/` is emitted from it and
40
+ **must not be hand-edited** — CI regenerates and diffs on every push, and the
41
+ next protocol sync destroys anything it finds. See [`AGENTS.md`](AGENTS.md).
42
+
43
+ ## Two namespaces, which do not match on purpose
44
+
45
+ The repo is `github.com/Fancy-Friends/amazon-ses`; the packages publish under
46
+ `particle-academy`. Nothing derives one from the other — the names come from
47
+ weaver's `friends.json` and nowhere else.
48
+
49
+ ## Licence
50
+
51
+ MIT.
@@ -0,0 +1,87 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "fancy-amazon-ses"
7
+ version = "0.1.0"
8
+ description = "Amazon SES for Python — the service descriptor, its faker, its webhook verification, and one function per operation. Plain HTTP; no vendor SDK."
9
+ readme = "README.md"
10
+ # 3.11 matches fancy-flow-py's floor: 3.10 reaches end of life on 2026-10-31,
11
+ # and a floor that dies before the package's second release is not a floor.
12
+ requires-python = ">=3.11"
13
+ license = "MIT"
14
+ license-files = ["LICENSE"]
15
+ authors = [{ name = "Particle Academy" }]
16
+ keywords = ["amazon_ses", "email", "connector", "api", "fancy-flow", "particle-academy"]
17
+ classifiers = [
18
+ "Development Status :: 3 - Alpha",
19
+ "Intended Audience :: Developers",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Topic :: Software Development :: Libraries",
25
+ "Typing :: Typed",
26
+ ]
27
+
28
+ # ZERO runtime dependencies, and that is a design constraint rather than an
29
+ # accident. There is no Python twin of fancy-connector-core to depend on, and a
30
+ # vendor SDK is third-party code subject to the kit's full approval bar — one
31
+ # SDK per provider is hundreds of dependencies nobody is tracking. The HTTP is
32
+ # stdlib `urllib`; the HMAC is stdlib `hmac`.
33
+ dependencies = []
34
+
35
+ [project.urls]
36
+ Homepage = "https://github.com/Fancy-Friends/amazon-ses"
37
+ Issues = "https://github.com/Fancy-Friends/amazon-ses/issues"
38
+ Source = "https://github.com/Fancy-Friends/amazon-ses"
39
+
40
+ [dependency-groups]
41
+ # Not optional. A package with no way to run its tests reports green by doing
42
+ # nothing, which is the one defect that hides itself.
43
+ test = ["pytest>=8.0"]
44
+ lint = ["ruff>=0.16"]
45
+ typecheck = ["mypy>=1.11"]
46
+ dev = [{ include-group = "test" }, { include-group = "lint" }, { include-group = "typecheck" }]
47
+
48
+ [tool.hatch.build.targets.wheel]
49
+ packages = ["src/fancy_amazon_ses"]
50
+
51
+ [tool.hatch.build.targets.sdist]
52
+ include = ["/src", "/tests", "/README.md", "/CHANGELOG.md", "/LICENSE"]
53
+
54
+ [tool.pytest.ini_options]
55
+ testpaths = ["tests"]
56
+ # importlib mode pairs with src-layout: the working tree is never on sys.path,
57
+ # so the tests exercise the INSTALLED package. Under the default mode a missing
58
+ # py.typed or an unshipped file passes locally and breaks for every user.
59
+ addopts = "--import-mode=importlib -ra"
60
+
61
+ [tool.ruff]
62
+ line-length = 100
63
+ src = ["src", "tests"]
64
+ target-version = "py311"
65
+
66
+ [tool.ruff.lint]
67
+ # `S` — flake8-bandit — is ON, and it is the one addition worth arguing for: this
68
+ # package handles a credential, builds an HMAC, and opens a URL. Security lint
69
+ # belongs on exactly this code.
70
+ #
71
+ # It also makes the two `# noqa: S310` in _runtime.py MEANINGFUL. Without `S`
72
+ # selected, ruff reports them as unused directives (RUF100) and the obvious fix
73
+ # is to delete them — which quietly removes a security annotation because a
74
+ # linter was not looking for it.
75
+ select = ["E", "F", "I", "UP", "B", "SIM", "RUF", "N", "C4", "PT", "S"]
76
+
77
+ [tool.ruff.lint.per-file-ignores]
78
+ # pytest's whole idiom is bare `assert`. S101 would fail every test file.
79
+ "tests/*" = ["S101"]
80
+
81
+ [tool.mypy]
82
+ python_version = "3.11"
83
+ packages = ["fancy_amazon_ses"]
84
+ mypy_path = "src"
85
+ strict = true
86
+ disallow_any_expr = false
87
+ disallow_any_explicit = false
@@ -0,0 +1,37 @@
1
+ # GENERATED FILE — do not edit.
2
+ #
3
+ # Emitted from provider/manifest.json by weaver's generator.
4
+ # A hand-edit here is destroyed by the next protocol sync, which is worse than
5
+ # being rejected, because it works until it silently does not. Fix
6
+ # provider/manifest.json (or weaver's template/) and regenerate:
7
+ #
8
+ # npm run provider -- amazon_ses
9
+
10
+ """Amazon SES for Python.
11
+
12
+ The service descriptor, its faker, its delivery contract, and one function
13
+ per operation — plain HTTP on the stdlib, no vendor SDK and no runtime
14
+ dependency.
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ from ._fake import FakeValues
20
+ from .actions.email_send import email_send
21
+ from .faker import respond
22
+ from .service import BASE_URLS, CONNECTOR_API_VERSION, REQUIRES, SANDBOX, SERVICE, TITLE, descriptor
23
+
24
+ __version__ = "0.1.0"
25
+
26
+ __all__ = [
27
+ "BASE_URLS",
28
+ "CONNECTOR_API_VERSION",
29
+ "REQUIRES",
30
+ "SANDBOX",
31
+ "SERVICE",
32
+ "TITLE",
33
+ "FakeValues",
34
+ "descriptor",
35
+ "email_send",
36
+ "respond",
37
+ ]
@@ -0,0 +1,170 @@
1
+ # GENERATED FILE — do not edit.
2
+ #
3
+ # Emitted from provider/manifest.json (via weaver's
4
+ # template/embed/py/_fake.py) by weaver's generator.
5
+ # A hand-edit here is destroyed by the next protocol sync, which is worse than
6
+ # being rejected, because it works until it silently does not. Fix
7
+ # provider/manifest.json (via weaver's template/embed/py/_fake.py) (or
8
+ # weaver's template/) and regenerate:
9
+ #
10
+ # npm run provider -- amazon_ses
11
+
12
+ """Deterministic faker values — bit-for-bit with TypeScript and PHP.
13
+
14
+ PROVENANCE — read before editing.
15
+
16
+ This is the SINGLE SOURCE for the Python faker helpers. It exists because
17
+ ``fancy-connector-core`` has a TypeScript implementation and a PHP twin and
18
+ **no Python twin at all**, so a generated ``fancy-<provider>`` package has no
19
+ shared runtime to import. Every generated package carries a copy emitted from
20
+ this file, and ``new-provider.mjs --check`` fails CI when a copy differs.
21
+
22
+ The permanent fix is a Python ``fancy-connector-core``. When it exists, this
23
+ file becomes a re-export and every provider picks it up on the next protocol
24
+ sync.
25
+
26
+ ## Bit-for-bit identical is the whole point
27
+
28
+ Not "similar": the same FNV-1a seed and the same xorshift32 sequence, so a
29
+ golden fixture asserts the exact faked payload and ALL THREE runtimes have to
30
+ produce it. That turns the faker into a parity test rather than a convenience —
31
+ which matters, because cross-runtime drift does not fail loudly. It completes,
32
+ down one path, with no error.
33
+
34
+ Python integers are unbounded, so every 32-bit operation is masked back into
35
+ range. Dropping one of those masks does not break anything visibly; it just
36
+ makes the runtimes diverge after a few hundred calls, which is the worst
37
+ possible way for this to fail.
38
+
39
+ ## Deterministic, and obviously fake
40
+
41
+ Same inputs, same output — always. A faker returning a fresh uuid every call
42
+ cannot be asserted on, so its fixtures degrade to "it did not throw", which is
43
+ the assertion that catches nothing. And the values are obviously synthetic ON
44
+ PURPOSE — ``fake_``-prefixed ids, ``example.test`` hosts, round numbers. Nobody
45
+ should ever look at a faked result and wonder whether it moved real money.
46
+ """
47
+
48
+ from __future__ import annotations
49
+
50
+ import json
51
+ from datetime import UTC, datetime, timedelta
52
+ from typing import Any
53
+
54
+ MASK = 0xFFFFFFFF
55
+
56
+ # `FakeValues.int` is part of the cross-runtime faker API — `fake.int(min, max)`
57
+ # in TypeScript, PHP and here — so the method keeps that name. Inside the class
58
+ # body it then shadows the builtin, and every LATER annotation reading `int`
59
+ # resolves to the method instead of the type. This alias is what the annotations
60
+ # after it use.
61
+ _Int = int
62
+
63
+ #: The instant every faker counts from. A constant rather than the clock,
64
+ #: because a fixture asserting on ``created`` must not start failing tomorrow.
65
+ FAKE_EPOCH = "2026-01-01T00:00:00.000Z"
66
+
67
+ _FNV_OFFSET = 0x811C9DC5
68
+ _FNV_PRIME = 0x01000193
69
+
70
+
71
+ def _stable_json(value: Any) -> str:
72
+ """Render a value the way ``JSON.stringify`` would, with sorted object keys.
73
+
74
+ Key order must not change a seed. ``json.dumps`` preserves insertion order,
75
+ so ``{a, b}`` and ``{b, a}`` would hash differently and "same inputs, same
76
+ output" would hold only for dicts that happened to be built in the same
77
+ order — the kind of almost-true that survives review and fails in a fixture
78
+ months later.
79
+ """
80
+ if isinstance(value, dict):
81
+ parts = [
82
+ f"{json.dumps(str(key))}:{_stable_json(item)}"
83
+ for key, item in sorted(value.items(), key=lambda pair: str(pair[0]))
84
+ if item is not ...
85
+ ]
86
+ return "{" + ",".join(parts) + "}"
87
+
88
+ if isinstance(value, (list, tuple)):
89
+ return "[" + ",".join(_stable_json(item) for item in value) + "]"
90
+
91
+ # `separators` matters: JavaScript emits no spaces, and a space here would
92
+ # change every seed.
93
+ return json.dumps(value, separators=(",", ":"), ensure_ascii=False)
94
+
95
+
96
+ def seed_from(*parts: Any) -> int:
97
+ """FNV-1a over the stable rendering of the parts. Twin of ``seedFrom``."""
98
+ text = "|".join(part if isinstance(part, str) else _stable_json(part) for part in parts)
99
+
100
+ hash_ = _FNV_OFFSET
101
+ # JavaScript hashes UTF-16 code units, so a character outside the BMP
102
+ # contributes two of them. Encoding to UTF-16-LE and reading pairs is what
103
+ # keeps a provider name with an emoji in it seeding identically.
104
+ for unit in _utf16_units(text):
105
+ hash_ ^= unit
106
+ hash_ = (hash_ * _FNV_PRIME) & MASK
107
+
108
+ return hash_
109
+
110
+
111
+ def _utf16_units(text: str) -> list[int]:
112
+ raw = text.encode("utf-16-le")
113
+
114
+ return [raw[i] | (raw[i + 1] << 8) for i in range(0, len(raw), 2)]
115
+
116
+
117
+ def seed_for_call(service: str, operation: str, config: dict[str, Any] | None) -> int:
118
+ """The seed for one faked call: service, operation, and the caller's config."""
119
+ return seed_from(service, operation, config or {})
120
+
121
+
122
+ class FakeValues:
123
+ """Deterministic value helpers handed to a faker.
124
+
125
+ Small on purpose. A faker's job is to return the SHAPE the provider returns
126
+ — the field names a downstream node will reference — not to simulate the
127
+ provider's business logic.
128
+ """
129
+
130
+ def __init__(self, seed: int) -> None:
131
+ masked = seed & MASK
132
+ self._state = masked if masked != 0 else 0x9E3779B9
133
+
134
+ def _next(self) -> int:
135
+ """xorshift32, matching the JS generator step for step."""
136
+ state = self._state
137
+ state ^= (state << 13) & MASK
138
+ state &= MASK
139
+ state ^= state >> 17
140
+ state ^= (state << 5) & MASK
141
+ state &= MASK
142
+ self._state = state
143
+
144
+ return state
145
+
146
+ def hex(self, length: _Int) -> str:
147
+ """A stable lowercase hex string of ``length`` characters."""
148
+ out = ""
149
+ while len(out) < length:
150
+ out += format(self._next(), "08x")
151
+
152
+ return out[:length]
153
+
154
+ def id(self, prefix: str) -> str:
155
+ """A stable id with the provider's usual prefix: ``id("ch")`` -> ``ch_fake_1a2b3c``."""
156
+ return f"{prefix}_fake_{self.hex(12)}"
157
+
158
+ def int(self, minimum: int, maximum: int) -> int:
159
+ """A stable integer in ``[minimum, maximum]``."""
160
+ return minimum + (self._next() % max(1, maximum - minimum + 1))
161
+
162
+ def pick(self, options: list[Any]) -> Any:
163
+ """Pick a stable element of a list."""
164
+ return options[self._next() % len(options)]
165
+
166
+ def timestamp(self, offset_seconds: _Int = 0) -> str:
167
+ """A fixed ISO-8601 instant, offset by whole seconds. Never ``now()``."""
168
+ base = datetime(2026, 1, 1, tzinfo=UTC) + timedelta(seconds=offset_seconds)
169
+
170
+ return base.strftime("%Y-%m-%dT%H:%M:%S") + ".000Z"