omkit 0.0.2__tar.gz → 0.1.2__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.
- omkit-0.1.2/LICENSE +201 -0
- omkit-0.1.2/PKG-INFO +216 -0
- omkit-0.1.2/README.md +168 -0
- {omkit-0.0.2 → omkit-0.1.2}/omkit/cleanup.py +1 -1
- omkit-0.1.2/omkit/crypto/__init__.py +52 -0
- omkit-0.1.2/omkit/crypto/aad.py +42 -0
- omkit-0.1.2/omkit/crypto/aes_gcm.py +140 -0
- omkit-0.1.2/omkit/crypto/kuser.py +100 -0
- {omkit-0.0.2 → omkit-0.1.2}/omkit/data/__init__.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/omkit/dbpool.py +1 -1
- omkit-0.1.2/omkit/encryption.py +115 -0
- {omkit-0.0.2 → omkit-0.1.2}/omkit/eventbus.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/omkit/events.py +4 -4
- {omkit-0.0.2 → omkit-0.1.2}/omkit/health.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/omkit/http.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/omkit/internal/__init__.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/omkit/internal/crypto.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/omkit/jobqueue/__init__.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/omkit/jobqueue/envelope.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/omkit/jobqueue/streaq.py +4 -1
- omkit-0.1.2/omkit/kms/__init__.py +35 -0
- omkit-0.1.2/omkit/kms/base.py +115 -0
- omkit-0.1.2/omkit/kms/localdev.py +166 -0
- omkit-0.1.2/omkit/kms/openbao.py +316 -0
- {omkit-0.0.2 → omkit-0.1.2}/omkit/logging.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/omkit/providers/__init__.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/omkit/providers/base.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/omkit/providers/registry.py +9 -3
- {omkit-0.0.2 → omkit-0.1.2}/omkit/quota.py +54 -2
- {omkit-0.0.2 → omkit-0.1.2}/omkit/resilience.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/omkit/sanitize.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/omkit/security/__init__.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/omkit/security/events.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/omkit/sessions.py +3 -3
- {omkit-0.0.2 → omkit-0.1.2}/omkit/settings.py +8 -6
- {omkit-0.0.2 → omkit-0.1.2}/omkit/sync_notifier.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/omkit/tenant.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/omkit/tracing.py +21 -1
- {omkit-0.0.2 → omkit-0.1.2}/omkit/transport/__init__.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/omkit/valkey.py +1 -1
- omkit-0.1.2/omkit/valkeystream.py +181 -0
- omkit-0.1.2/omkit/valkeysub.py +98 -0
- omkit-0.1.2/omkit.egg-info/PKG-INFO +216 -0
- {omkit-0.0.2 → omkit-0.1.2}/omkit.egg-info/SOURCES.txt +15 -1
- {omkit-0.0.2 → omkit-0.1.2}/omkit.egg-info/requires.txt +3 -0
- omkit-0.1.2/pyproject.toml +103 -0
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_base.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_cleanup.py +1 -1
- omkit-0.1.2/tests/test_crypto_envelope_interop.py +301 -0
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_data_facade.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_dbpool.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_dbpool_role.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_encryption.py +44 -9
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_eventbus.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_events_shim.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_health.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_http.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_jobqueue_envelope.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_jobqueue_streaq.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_logging.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_metrics.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_quota.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_registry_polling.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_resilience.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_sanitize.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_security_events.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_security_facade.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_sessions.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_settings_cache.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_settings_manager.py +2 -2
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_settings_polling.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_tenant.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_tracing.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_transport_facade.py +1 -1
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_valkey.py +1 -1
- omkit-0.1.2/tests/test_valkeystream.py +130 -0
- omkit-0.1.2/tests/test_valkeysub.py +90 -0
- omkit-0.0.2/PKG-INFO +0 -29
- omkit-0.0.2/README.md +0 -17
- omkit-0.0.2/omkit/encryption.py +0 -58
- omkit-0.0.2/omkit.egg-info/PKG-INFO +0 -29
- omkit-0.0.2/pyproject.toml +0 -50
- {omkit-0.0.2 → omkit-0.1.2}/omkit/__init__.py +0 -0
- {omkit-0.0.2 → omkit-0.1.2}/omkit/config.py +0 -0
- {omkit-0.0.2 → omkit-0.1.2}/omkit/cost.py +0 -0
- {omkit-0.0.2 → omkit-0.1.2}/omkit/metrics.py +0 -0
- {omkit-0.0.2 → omkit-0.1.2}/omkit/model_lifecycle.py +0 -0
- {omkit-0.0.2 → omkit-0.1.2}/omkit/platform/__init__.py +0 -0
- {omkit-0.0.2 → omkit-0.1.2}/omkit/py.typed +0 -0
- {omkit-0.0.2 → omkit-0.1.2}/omkit.egg-info/dependency_links.txt +0 -0
- {omkit-0.0.2 → omkit-0.1.2}/omkit.egg-info/top_level.txt +0 -0
- {omkit-0.0.2 → omkit-0.1.2}/setup.cfg +0 -0
- {omkit-0.0.2 → omkit-0.1.2}/tests/test_cost.py +0 -0
omkit-0.1.2/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Omur Labs
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
omkit-0.1.2/PKG-INFO
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: omkit
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Multi-tenant SaaS scaffolding for Python services.
|
|
5
|
+
Author: Omur Labs
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/omurlabs/omkit-python
|
|
8
|
+
Project-URL: Repository, https://github.com/omurlabs/omkit-python
|
|
9
|
+
Project-URL: Issues, https://github.com/omurlabs/omkit-python/issues
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Typing :: Typed
|
|
17
|
+
Requires-Python: >=3.12
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: pydantic>=2.13
|
|
21
|
+
Requires-Dist: pydantic-settings>=2.13
|
|
22
|
+
Requires-Dist: asyncpg>=0.31
|
|
23
|
+
Requires-Dist: redis>=7.4
|
|
24
|
+
Requires-Dist: structlog>=25.5
|
|
25
|
+
Requires-Dist: cryptography>=47.0
|
|
26
|
+
Requires-Dist: tenacity>=9.1
|
|
27
|
+
Requires-Dist: prometheus_client>=0.25
|
|
28
|
+
Requires-Dist: httpx>=0.28.1
|
|
29
|
+
Requires-Dist: sqlalchemy[asyncio]>=2.0.49
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: fastapi>=0.136.0; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest>=9.0; extra == "dev"
|
|
33
|
+
Requires-Dist: pytest-asyncio>=1.3; extra == "dev"
|
|
34
|
+
Requires-Dist: redis>=7.4; extra == "dev"
|
|
35
|
+
Requires-Dist: respx>=0.21; extra == "dev"
|
|
36
|
+
Requires-Dist: mypy>=1.13; extra == "dev"
|
|
37
|
+
Requires-Dist: opentelemetry-sdk>=1.41.0; extra == "dev"
|
|
38
|
+
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.41.0; extra == "dev"
|
|
39
|
+
Provides-Extra: tracing
|
|
40
|
+
Requires-Dist: opentelemetry-api>=1.41.0; extra == "tracing"
|
|
41
|
+
Requires-Dist: opentelemetry-sdk>=1.41.0; extra == "tracing"
|
|
42
|
+
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.41.0; extra == "tracing"
|
|
43
|
+
Requires-Dist: opentelemetry-instrumentation-fastapi>=0.62b0; extra == "tracing"
|
|
44
|
+
Requires-Dist: opentelemetry-instrumentation-httpx>=0.62b0; extra == "tracing"
|
|
45
|
+
Provides-Extra: metrics
|
|
46
|
+
Requires-Dist: prometheus-fastapi-instrumentator>=7.1; extra == "metrics"
|
|
47
|
+
Dynamic: license-file
|
|
48
|
+
|
|
49
|
+
# omkit
|
|
50
|
+
|
|
51
|
+
Multi-tenant SaaS scaffolding for Python services.
|
|
52
|
+
|
|
53
|
+
`omkit` is the Python side of Omur Labs' shared service toolkit. It bundles the
|
|
54
|
+
boring-but-load-bearing pieces every tenant-isolated service needs: a Postgres
|
|
55
|
+
pool that enforces Row-Level Security per connection, a pluggable event bus
|
|
56
|
+
(Postgres `LISTEN/NOTIFY` or Valkey), session and settings stores, an LLM
|
|
57
|
+
provider registry, BYOK encryption helpers, FastAPI observability middleware,
|
|
58
|
+
and a cross-runtime job-queue envelope that interoperates with the Go sibling.
|
|
59
|
+
|
|
60
|
+
- **Status:** `v0.1.1` — internal API stable.
|
|
61
|
+
- **Python:** `>=3.12`
|
|
62
|
+
- **License:** Apache-2.0
|
|
63
|
+
- **Sibling:** [`omkit-go`](https://github.com/omurlabs/omkit-go) — same primitives, same envelope contract, same RLS conventions.
|
|
64
|
+
|
|
65
|
+
## Install
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install git+https://github.com/omurlabs/omkit-python@v0.1.1
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Optional extras:
|
|
72
|
+
|
|
73
|
+
| Extra | Adds | When you need it |
|
|
74
|
+
|------------|-------------------------------------------------------------------|----------------------------------------|
|
|
75
|
+
| `tracing` | `opentelemetry-{api,sdk}`, OTLP/HTTP exporter, FastAPI + httpx instrumentation | Distributed tracing |
|
|
76
|
+
| `metrics` | `prometheus-fastapi-instrumentator` | FastAPI request metrics |
|
|
77
|
+
| `dev` | `fastapi`, `pytest`, `pytest-asyncio`, `respx` | Local development and tests |
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pip install "omkit[tracing,metrics] @ git+https://github.com/omurlabs/omkit-python@v0.1.1"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Quickstart
|
|
84
|
+
|
|
85
|
+
A minimal tenant-aware FastAPI service wired up with the pieces omkit gives you:
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from fastapi import FastAPI
|
|
89
|
+
from omkit.dbpool import create_pool
|
|
90
|
+
from omkit.tenant import TenantMiddleware
|
|
91
|
+
from omkit.transport import (
|
|
92
|
+
configure_logging,
|
|
93
|
+
init_tracing,
|
|
94
|
+
instrument_fastapi,
|
|
95
|
+
mount_metrics,
|
|
96
|
+
mount_health_endpoints,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
configure_logging()
|
|
100
|
+
init_tracing(service_name="my-service")
|
|
101
|
+
|
|
102
|
+
app = FastAPI()
|
|
103
|
+
app.add_middleware(TenantMiddleware)
|
|
104
|
+
instrument_fastapi(app)
|
|
105
|
+
mount_metrics(app)
|
|
106
|
+
mount_health_endpoints(app)
|
|
107
|
+
|
|
108
|
+
pool = await create_pool("postgresql://...") # role-scoped, RLS-aware
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Tenant context is set by `TenantMiddleware` and read by everything downstream
|
|
112
|
+
(pool, event bus, logger, HTTP client, job envelope) via `omkit.tenant`.
|
|
113
|
+
|
|
114
|
+
## Module index
|
|
115
|
+
|
|
116
|
+
### Data & storage
|
|
117
|
+
|
|
118
|
+
| Module | What it does |
|
|
119
|
+
|-------------------------------|------------------------------------------------------------------------------|
|
|
120
|
+
| `omkit.dbpool` | Asyncpg pool that sets a Postgres role per connection so RLS policies apply. |
|
|
121
|
+
| `omkit.sessions` | `SessionStore` protocol with Postgres and Redis backends. |
|
|
122
|
+
| `omkit.encryption` | AES-256-GCM settings encryption — `generate_key`, `encrypt_value`, `decrypt_value`, `mask_secret`. Wire-compatible with `omkit-go/encryption`. |
|
|
123
|
+
| `omkit.data` *(facade)* | Re-exports pool + session primitives in one place. |
|
|
124
|
+
|
|
125
|
+
### Events & async
|
|
126
|
+
|
|
127
|
+
| Module | What it does |
|
|
128
|
+
|------------------|---------------------------------------------------------------------------------|
|
|
129
|
+
| `omkit.eventbus` | `EventBus` protocol (`PostgresEventBus`, `RedisEventBus`) with env-driven factory. |
|
|
130
|
+
| `omkit.valkey` | Async Redis/Valkey client factory. |
|
|
131
|
+
| `omkit.events` | Deprecated shim — imports from here warn; use `omkit.eventbus`. |
|
|
132
|
+
|
|
133
|
+
### Job queue
|
|
134
|
+
|
|
135
|
+
| Module | What it does |
|
|
136
|
+
|---------------------------|-------------------------------------------------------------------------------|
|
|
137
|
+
| `omkit.jobqueue` | `Envelope` contract — `wrap`/`unwrap` for tenant-scoped tasks. Same wire format as `omkit-go/jobqueue`. |
|
|
138
|
+
| `omkit.jobqueue.streaq` | streaq worker helpers (`make_worker`, `enqueue`, `mount_streaq_ui`, Prometheus collector). Import explicitly. |
|
|
139
|
+
| `omkit.model_lifecycle` | `ModelRegistry` + `ModelLifecycle` ABC — lazy model loading with polling. |
|
|
140
|
+
| `omkit.sync_notifier` | `SyncNotifier` — enqueue outbound HTTP callbacks. |
|
|
141
|
+
|
|
142
|
+
### Observability & resilience
|
|
143
|
+
|
|
144
|
+
| Module | What it does |
|
|
145
|
+
|-----------------------|---------------------------------------------------------------------------|
|
|
146
|
+
| `omkit.logging` | `configure_logging()` — structlog + JSON formatter. |
|
|
147
|
+
| `omkit.metrics` | `mount_metrics()` — Prometheus endpoint on a FastAPI app. |
|
|
148
|
+
| `omkit.tracing` | `init_tracing()`, `instrument_fastapi()` — OpenTelemetry over OTLP/HTTP. |
|
|
149
|
+
| `omkit.health` | `mount_health_endpoints()` — `/health` + `/ready` routes. |
|
|
150
|
+
| `omkit.resilience` | `CircuitBreaker`, `@resilient` decorator, `CircuitOpen` exception. |
|
|
151
|
+
| `omkit.quota` | `Resource`, `Limits`, `Usage`, `Decision`, `check_upload`, `check_query`. |
|
|
152
|
+
| `omkit.transport` *(facade)* | Re-exports the wire + observability set. |
|
|
153
|
+
|
|
154
|
+
### Multi-tenant & config
|
|
155
|
+
|
|
156
|
+
| Module | What it does |
|
|
157
|
+
|----------------------|---------------------------------------------------------------------------|
|
|
158
|
+
| `omkit.tenant` | Tenant context (`require`, `current_or_none`, `request_id`, `bind`) and ASGI/FastAPI middleware. |
|
|
159
|
+
| `omkit.config` | `BaseServiceSettings` — pydantic-settings base class for env-driven config. |
|
|
160
|
+
| `omkit.settings` | `SettingsManager` — async tenant-settings loader with polling. |
|
|
161
|
+
| `omkit.platform` *(facade)* | Re-exports config + lifecycle + sync notifier. |
|
|
162
|
+
|
|
163
|
+
### LLM & security
|
|
164
|
+
|
|
165
|
+
| Module | What it does |
|
|
166
|
+
|----------------------|---------------------------------------------------------------------------|
|
|
167
|
+
| `omkit.providers` | `ProviderBase` ABC + `ProviderRegistry` for pluggable LLM providers. |
|
|
168
|
+
| `omkit.sanitize` | `sanitize_llm_output`, `sanitize_llm_response`, `sanitize_html`, `extract_json`. |
|
|
169
|
+
| `omkit.security` *(facade)* | Sanitation re-exports plus `log_security_event`. |
|
|
170
|
+
| `omkit.cost` | `record_cost`, `COST_UNITS_TOTAL` Prometheus counter, `TenantBucket` enum. |
|
|
171
|
+
| `omkit.http` | `build_tenant_client()` — httpx `AsyncClient` that injects tenant headers. |
|
|
172
|
+
| `omkit.cleanup` | `Loop` context manager — ensure event-loop cleanup on shutdown. |
|
|
173
|
+
|
|
174
|
+
### Internal
|
|
175
|
+
|
|
176
|
+
`omkit.internal` holds private helpers (currently `crypto.py`). Not part of the
|
|
177
|
+
stable surface — do not import.
|
|
178
|
+
|
|
179
|
+
## Subpackage facades
|
|
180
|
+
|
|
181
|
+
Five subpackages re-export grouped primitives. Prefer importing from a facade
|
|
182
|
+
when you only need the "shape" of a concern; reach into a flat module when you
|
|
183
|
+
need a less common symbol.
|
|
184
|
+
|
|
185
|
+
| Facade | Re-exports |
|
|
186
|
+
|-------------------|----------------------------------------------------------------------------------|
|
|
187
|
+
| `omkit.data` | Pool + session primitives |
|
|
188
|
+
| `omkit.platform` | `BaseServiceSettings`, `SettingsManager`, `ModelLifecycle`, `ModelRegistry`, `SyncNotifier` |
|
|
189
|
+
| `omkit.security` | Sanitation + `log_security_event` *(does **not** re-export `omkit.encryption`)* |
|
|
190
|
+
| `omkit.transport` | `build_tenant_client`, `init_tracing`, `instrument_fastapi`, `mount_metrics`, `mount_health_endpoints`, `configure_logging`, `CircuitBreaker`, `resilient` |
|
|
191
|
+
| `omkit.jobqueue` | `Envelope`, `wrap`, `unwrap`, `ENVELOPE_VERSION`, `InvalidEnvelopeError` *(streaq helpers via `omkit.jobqueue.streaq`)* |
|
|
192
|
+
|
|
193
|
+
## Cross-SDK job envelope
|
|
194
|
+
|
|
195
|
+
`omkit.jobqueue.Envelope` is the same wire contract used by
|
|
196
|
+
`omkit-go/jobqueue`. A Python streaq worker and a Go Asynq worker can publish
|
|
197
|
+
and consume each other's jobs as long as they agree on `ENVELOPE_VERSION` and
|
|
198
|
+
share the tenant routing rules. Pair it with a shared Valkey instance and
|
|
199
|
+
either runtime can pick up either runtime's work.
|
|
200
|
+
|
|
201
|
+
## Development
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
git clone git@github.com:omurlabs/omkit-python.git
|
|
205
|
+
cd omkit-python
|
|
206
|
+
pip install -e ".[dev,tracing,metrics]"
|
|
207
|
+
|
|
208
|
+
# Unit tests (no external services)
|
|
209
|
+
pytest
|
|
210
|
+
|
|
211
|
+
# Integration tests against a real Postgres
|
|
212
|
+
./scripts/test-with-postgres.sh
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Test layout mirrors the module layout; every public module and facade has a
|
|
216
|
+
matching `tests/test_*.py`.
|
omkit-0.1.2/README.md
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# omkit
|
|
2
|
+
|
|
3
|
+
Multi-tenant SaaS scaffolding for Python services.
|
|
4
|
+
|
|
5
|
+
`omkit` is the Python side of Omur Labs' shared service toolkit. It bundles the
|
|
6
|
+
boring-but-load-bearing pieces every tenant-isolated service needs: a Postgres
|
|
7
|
+
pool that enforces Row-Level Security per connection, a pluggable event bus
|
|
8
|
+
(Postgres `LISTEN/NOTIFY` or Valkey), session and settings stores, an LLM
|
|
9
|
+
provider registry, BYOK encryption helpers, FastAPI observability middleware,
|
|
10
|
+
and a cross-runtime job-queue envelope that interoperates with the Go sibling.
|
|
11
|
+
|
|
12
|
+
- **Status:** `v0.1.1` — internal API stable.
|
|
13
|
+
- **Python:** `>=3.12`
|
|
14
|
+
- **License:** Apache-2.0
|
|
15
|
+
- **Sibling:** [`omkit-go`](https://github.com/omurlabs/omkit-go) — same primitives, same envelope contract, same RLS conventions.
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install git+https://github.com/omurlabs/omkit-python@v0.1.1
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Optional extras:
|
|
24
|
+
|
|
25
|
+
| Extra | Adds | When you need it |
|
|
26
|
+
|------------|-------------------------------------------------------------------|----------------------------------------|
|
|
27
|
+
| `tracing` | `opentelemetry-{api,sdk}`, OTLP/HTTP exporter, FastAPI + httpx instrumentation | Distributed tracing |
|
|
28
|
+
| `metrics` | `prometheus-fastapi-instrumentator` | FastAPI request metrics |
|
|
29
|
+
| `dev` | `fastapi`, `pytest`, `pytest-asyncio`, `respx` | Local development and tests |
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install "omkit[tracing,metrics] @ git+https://github.com/omurlabs/omkit-python@v0.1.1"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Quickstart
|
|
36
|
+
|
|
37
|
+
A minimal tenant-aware FastAPI service wired up with the pieces omkit gives you:
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
from fastapi import FastAPI
|
|
41
|
+
from omkit.dbpool import create_pool
|
|
42
|
+
from omkit.tenant import TenantMiddleware
|
|
43
|
+
from omkit.transport import (
|
|
44
|
+
configure_logging,
|
|
45
|
+
init_tracing,
|
|
46
|
+
instrument_fastapi,
|
|
47
|
+
mount_metrics,
|
|
48
|
+
mount_health_endpoints,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
configure_logging()
|
|
52
|
+
init_tracing(service_name="my-service")
|
|
53
|
+
|
|
54
|
+
app = FastAPI()
|
|
55
|
+
app.add_middleware(TenantMiddleware)
|
|
56
|
+
instrument_fastapi(app)
|
|
57
|
+
mount_metrics(app)
|
|
58
|
+
mount_health_endpoints(app)
|
|
59
|
+
|
|
60
|
+
pool = await create_pool("postgresql://...") # role-scoped, RLS-aware
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Tenant context is set by `TenantMiddleware` and read by everything downstream
|
|
64
|
+
(pool, event bus, logger, HTTP client, job envelope) via `omkit.tenant`.
|
|
65
|
+
|
|
66
|
+
## Module index
|
|
67
|
+
|
|
68
|
+
### Data & storage
|
|
69
|
+
|
|
70
|
+
| Module | What it does |
|
|
71
|
+
|-------------------------------|------------------------------------------------------------------------------|
|
|
72
|
+
| `omkit.dbpool` | Asyncpg pool that sets a Postgres role per connection so RLS policies apply. |
|
|
73
|
+
| `omkit.sessions` | `SessionStore` protocol with Postgres and Redis backends. |
|
|
74
|
+
| `omkit.encryption` | AES-256-GCM settings encryption — `generate_key`, `encrypt_value`, `decrypt_value`, `mask_secret`. Wire-compatible with `omkit-go/encryption`. |
|
|
75
|
+
| `omkit.data` *(facade)* | Re-exports pool + session primitives in one place. |
|
|
76
|
+
|
|
77
|
+
### Events & async
|
|
78
|
+
|
|
79
|
+
| Module | What it does |
|
|
80
|
+
|------------------|---------------------------------------------------------------------------------|
|
|
81
|
+
| `omkit.eventbus` | `EventBus` protocol (`PostgresEventBus`, `RedisEventBus`) with env-driven factory. |
|
|
82
|
+
| `omkit.valkey` | Async Redis/Valkey client factory. |
|
|
83
|
+
| `omkit.events` | Deprecated shim — imports from here warn; use `omkit.eventbus`. |
|
|
84
|
+
|
|
85
|
+
### Job queue
|
|
86
|
+
|
|
87
|
+
| Module | What it does |
|
|
88
|
+
|---------------------------|-------------------------------------------------------------------------------|
|
|
89
|
+
| `omkit.jobqueue` | `Envelope` contract — `wrap`/`unwrap` for tenant-scoped tasks. Same wire format as `omkit-go/jobqueue`. |
|
|
90
|
+
| `omkit.jobqueue.streaq` | streaq worker helpers (`make_worker`, `enqueue`, `mount_streaq_ui`, Prometheus collector). Import explicitly. |
|
|
91
|
+
| `omkit.model_lifecycle` | `ModelRegistry` + `ModelLifecycle` ABC — lazy model loading with polling. |
|
|
92
|
+
| `omkit.sync_notifier` | `SyncNotifier` — enqueue outbound HTTP callbacks. |
|
|
93
|
+
|
|
94
|
+
### Observability & resilience
|
|
95
|
+
|
|
96
|
+
| Module | What it does |
|
|
97
|
+
|-----------------------|---------------------------------------------------------------------------|
|
|
98
|
+
| `omkit.logging` | `configure_logging()` — structlog + JSON formatter. |
|
|
99
|
+
| `omkit.metrics` | `mount_metrics()` — Prometheus endpoint on a FastAPI app. |
|
|
100
|
+
| `omkit.tracing` | `init_tracing()`, `instrument_fastapi()` — OpenTelemetry over OTLP/HTTP. |
|
|
101
|
+
| `omkit.health` | `mount_health_endpoints()` — `/health` + `/ready` routes. |
|
|
102
|
+
| `omkit.resilience` | `CircuitBreaker`, `@resilient` decorator, `CircuitOpen` exception. |
|
|
103
|
+
| `omkit.quota` | `Resource`, `Limits`, `Usage`, `Decision`, `check_upload`, `check_query`. |
|
|
104
|
+
| `omkit.transport` *(facade)* | Re-exports the wire + observability set. |
|
|
105
|
+
|
|
106
|
+
### Multi-tenant & config
|
|
107
|
+
|
|
108
|
+
| Module | What it does |
|
|
109
|
+
|----------------------|---------------------------------------------------------------------------|
|
|
110
|
+
| `omkit.tenant` | Tenant context (`require`, `current_or_none`, `request_id`, `bind`) and ASGI/FastAPI middleware. |
|
|
111
|
+
| `omkit.config` | `BaseServiceSettings` — pydantic-settings base class for env-driven config. |
|
|
112
|
+
| `omkit.settings` | `SettingsManager` — async tenant-settings loader with polling. |
|
|
113
|
+
| `omkit.platform` *(facade)* | Re-exports config + lifecycle + sync notifier. |
|
|
114
|
+
|
|
115
|
+
### LLM & security
|
|
116
|
+
|
|
117
|
+
| Module | What it does |
|
|
118
|
+
|----------------------|---------------------------------------------------------------------------|
|
|
119
|
+
| `omkit.providers` | `ProviderBase` ABC + `ProviderRegistry` for pluggable LLM providers. |
|
|
120
|
+
| `omkit.sanitize` | `sanitize_llm_output`, `sanitize_llm_response`, `sanitize_html`, `extract_json`. |
|
|
121
|
+
| `omkit.security` *(facade)* | Sanitation re-exports plus `log_security_event`. |
|
|
122
|
+
| `omkit.cost` | `record_cost`, `COST_UNITS_TOTAL` Prometheus counter, `TenantBucket` enum. |
|
|
123
|
+
| `omkit.http` | `build_tenant_client()` — httpx `AsyncClient` that injects tenant headers. |
|
|
124
|
+
| `omkit.cleanup` | `Loop` context manager — ensure event-loop cleanup on shutdown. |
|
|
125
|
+
|
|
126
|
+
### Internal
|
|
127
|
+
|
|
128
|
+
`omkit.internal` holds private helpers (currently `crypto.py`). Not part of the
|
|
129
|
+
stable surface — do not import.
|
|
130
|
+
|
|
131
|
+
## Subpackage facades
|
|
132
|
+
|
|
133
|
+
Five subpackages re-export grouped primitives. Prefer importing from a facade
|
|
134
|
+
when you only need the "shape" of a concern; reach into a flat module when you
|
|
135
|
+
need a less common symbol.
|
|
136
|
+
|
|
137
|
+
| Facade | Re-exports |
|
|
138
|
+
|-------------------|----------------------------------------------------------------------------------|
|
|
139
|
+
| `omkit.data` | Pool + session primitives |
|
|
140
|
+
| `omkit.platform` | `BaseServiceSettings`, `SettingsManager`, `ModelLifecycle`, `ModelRegistry`, `SyncNotifier` |
|
|
141
|
+
| `omkit.security` | Sanitation + `log_security_event` *(does **not** re-export `omkit.encryption`)* |
|
|
142
|
+
| `omkit.transport` | `build_tenant_client`, `init_tracing`, `instrument_fastapi`, `mount_metrics`, `mount_health_endpoints`, `configure_logging`, `CircuitBreaker`, `resilient` |
|
|
143
|
+
| `omkit.jobqueue` | `Envelope`, `wrap`, `unwrap`, `ENVELOPE_VERSION`, `InvalidEnvelopeError` *(streaq helpers via `omkit.jobqueue.streaq`)* |
|
|
144
|
+
|
|
145
|
+
## Cross-SDK job envelope
|
|
146
|
+
|
|
147
|
+
`omkit.jobqueue.Envelope` is the same wire contract used by
|
|
148
|
+
`omkit-go/jobqueue`. A Python streaq worker and a Go Asynq worker can publish
|
|
149
|
+
and consume each other's jobs as long as they agree on `ENVELOPE_VERSION` and
|
|
150
|
+
share the tenant routing rules. Pair it with a shared Valkey instance and
|
|
151
|
+
either runtime can pick up either runtime's work.
|
|
152
|
+
|
|
153
|
+
## Development
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
git clone git@github.com:omurlabs/omkit-python.git
|
|
157
|
+
cd omkit-python
|
|
158
|
+
pip install -e ".[dev,tracing,metrics]"
|
|
159
|
+
|
|
160
|
+
# Unit tests (no external services)
|
|
161
|
+
pytest
|
|
162
|
+
|
|
163
|
+
# Integration tests against a real Postgres
|
|
164
|
+
./scripts/test-with-postgres.sh
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Test layout mirrors the module layout; every public module and facade has a
|
|
168
|
+
matching `tests/test_*.py`.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""omkit/cleanup.py — Coordinated periodic cleanup task runner.
|
|
2
2
|
|
|
3
3
|
Loop.run() fires the provided ``task`` coroutine every ``interval`` seconds
|
|
4
4
|
while holding ``pg_try_advisory_lock(lock_key)`` — horizontally scaled
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""omkit/crypto/__init__.py — AES-256-GCM envelope primitives shared with omkit-go/crypto.
|
|
2
|
+
|
|
3
|
+
Cross-SDK contract: byte-for-byte compatible with `github.com/omurlabs/omkit-go/crypto`.
|
|
4
|
+
Envelope layout: `nonce(12) || ciphertext || tag(16)` — no magic, no version
|
|
5
|
+
header, no key id; the calling KMS layer owns key identity.
|
|
6
|
+
|
|
7
|
+
For the short string/value encryption used by `omkit.encryption` (settings
|
|
8
|
+
secrets), use that module instead — it is a thin AES-256-GCM wrapper sharing
|
|
9
|
+
this primitive but ships a versioned URL-safe base64 token format.
|
|
10
|
+
|
|
11
|
+
exports: wrap | unwrap | AADMeta | AADMetrics | AADContent | AADEmbeddingsChunks | AAD_META | AAD_METRICS | AAD_CONTENT | AAD_EMBEDDINGS_CHUNKS | KUser | KUSER_SIZE | InvalidEnvelopeError | InvalidKeyError
|
|
12
|
+
rules: AES-256-GCM envelope must remain byte-for-byte compatible with omkit-go/crypto. Never change AAD constants without a versioned rotation (e.g. -v2). Pure-CPU sync API — KMS adapters add async on top.
|
|
13
|
+
agent: claude-opus-4-7 | anthropic | 2026-05-17 | claude-code | initial port from omkit-go/crypto
|
|
14
|
+
message:
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
from omkit.crypto.aad import (
|
|
20
|
+
AAD_CONTENT,
|
|
21
|
+
AAD_EMBEDDINGS_CHUNKS,
|
|
22
|
+
AAD_META,
|
|
23
|
+
AAD_METRICS,
|
|
24
|
+
AADContent,
|
|
25
|
+
AADEmbeddingsChunks,
|
|
26
|
+
AADMeta,
|
|
27
|
+
AADMetrics,
|
|
28
|
+
)
|
|
29
|
+
from omkit.crypto.aes_gcm import (
|
|
30
|
+
InvalidEnvelopeError,
|
|
31
|
+
InvalidKeyError,
|
|
32
|
+
unwrap,
|
|
33
|
+
wrap,
|
|
34
|
+
)
|
|
35
|
+
from omkit.crypto.kuser import KUSER_SIZE, KUser
|
|
36
|
+
|
|
37
|
+
__all__ = [
|
|
38
|
+
"wrap",
|
|
39
|
+
"unwrap",
|
|
40
|
+
"InvalidEnvelopeError",
|
|
41
|
+
"InvalidKeyError",
|
|
42
|
+
"AADMeta",
|
|
43
|
+
"AADMetrics",
|
|
44
|
+
"AADContent",
|
|
45
|
+
"AADEmbeddingsChunks",
|
|
46
|
+
"AAD_META",
|
|
47
|
+
"AAD_METRICS",
|
|
48
|
+
"AAD_CONTENT",
|
|
49
|
+
"AAD_EMBEDDINGS_CHUNKS",
|
|
50
|
+
"KUser",
|
|
51
|
+
"KUSER_SIZE",
|
|
52
|
+
]
|