tripaulx-sdk 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.
Files changed (400) hide show
  1. tripaulx_sdk-0.1.0/.gitignore +20 -0
  2. tripaulx_sdk-0.1.0/LICENSE +21 -0
  3. tripaulx_sdk-0.1.0/PKG-INFO +80 -0
  4. tripaulx_sdk-0.1.0/README.md +35 -0
  5. tripaulx_sdk-0.1.0/pyproject.toml +70 -0
  6. tripaulx_sdk-0.1.0/src/tripaulx/__init__.py +3 -0
  7. tripaulx_sdk-0.1.0/src/tripaulx/accounts/__init__.py +1 -0
  8. tripaulx_sdk-0.1.0/src/tripaulx/accounts/admin/__init__.py +25 -0
  9. tripaulx_sdk-0.1.0/src/tripaulx/accounts/admin/security.py +92 -0
  10. tripaulx_sdk-0.1.0/src/tripaulx/accounts/admin/user.py +33 -0
  11. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/__init__.py +1 -0
  12. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/authentication.py +27 -0
  13. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/permissions.py +21 -0
  14. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/schema.py +22 -0
  15. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/serializers/__init__.py +55 -0
  16. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/serializers/auth.py +82 -0
  17. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/serializers/devices.py +64 -0
  18. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/serializers/user.py +63 -0
  19. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/serializers/workspace.py +58 -0
  20. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/urls.py +88 -0
  21. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/urls_public.py +17 -0
  22. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/urls_workspace.py +22 -0
  23. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/__init__.py +64 -0
  24. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/base.py +55 -0
  25. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/devices.py +42 -0
  26. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/email.py +44 -0
  27. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/invitations.py +83 -0
  28. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/login.py +74 -0
  29. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/members.py +48 -0
  30. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/mfa.py +120 -0
  31. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/passkeys.py +136 -0
  32. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/password.py +65 -0
  33. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/session.py +68 -0
  34. tripaulx_sdk-0.1.0/src/tripaulx/accounts/api/views/signup.py +62 -0
  35. tripaulx_sdk-0.1.0/src/tripaulx/accounts/apps.py +17 -0
  36. tripaulx_sdk-0.1.0/src/tripaulx/accounts/conf.py +41 -0
  37. tripaulx_sdk-0.1.0/src/tripaulx/accounts/locale/pt_BR/LC_MESSAGES/django.mo +0 -0
  38. tripaulx_sdk-0.1.0/src/tripaulx/accounts/locale/pt_BR/LC_MESSAGES/django.po +566 -0
  39. tripaulx_sdk-0.1.0/src/tripaulx/accounts/management/__init__.py +1 -0
  40. tripaulx_sdk-0.1.0/src/tripaulx/accounts/management/commands/__init__.py +1 -0
  41. tripaulx_sdk-0.1.0/src/tripaulx/accounts/management/commands/generate_recovery_codes.py +66 -0
  42. tripaulx_sdk-0.1.0/src/tripaulx/accounts/migrations/0001_initial.py +483 -0
  43. tripaulx_sdk-0.1.0/src/tripaulx/accounts/migrations/__init__.py +0 -0
  44. tripaulx_sdk-0.1.0/src/tripaulx/accounts/models/__init__.py +25 -0
  45. tripaulx_sdk-0.1.0/src/tripaulx/accounts/models/email_code.py +54 -0
  46. tripaulx_sdk-0.1.0/src/tripaulx/accounts/models/invitation.py +53 -0
  47. tripaulx_sdk-0.1.0/src/tripaulx/accounts/models/managers.py +44 -0
  48. tripaulx_sdk-0.1.0/src/tripaulx/accounts/models/passkey.py +39 -0
  49. tripaulx_sdk-0.1.0/src/tripaulx/accounts/models/recovery_code.py +44 -0
  50. tripaulx_sdk-0.1.0/src/tripaulx/accounts/models/roles.py +17 -0
  51. tripaulx_sdk-0.1.0/src/tripaulx/accounts/models/totp_device.py +50 -0
  52. tripaulx_sdk-0.1.0/src/tripaulx/accounts/models/trusted_device.py +53 -0
  53. tripaulx_sdk-0.1.0/src/tripaulx/accounts/models/user.py +55 -0
  54. tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/__init__.py +4 -0
  55. tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/email_codes.py +84 -0
  56. tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/errors.py +79 -0
  57. tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/invitations.py +103 -0
  58. tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/login/__init__.py +26 -0
  59. tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/login/flow.py +131 -0
  60. tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/login/second_factor.py +66 -0
  61. tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/login/tickets.py +39 -0
  62. tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/members.py +85 -0
  63. tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/notifications.py +57 -0
  64. tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/passkeys/__init__.py +31 -0
  65. tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/passkeys/ceremonies.py +140 -0
  66. tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/passkeys/relying_party.py +62 -0
  67. tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/passkeys/rules.py +71 -0
  68. tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/passwords.py +87 -0
  69. tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/recovery_codes.py +95 -0
  70. tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/signup.py +76 -0
  71. tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/tokens.py +75 -0
  72. tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/totp/__init__.py +39 -0
  73. tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/totp/algorithm.py +95 -0
  74. tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/totp/devices.py +122 -0
  75. tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/trusted_devices.py +99 -0
  76. tripaulx_sdk-0.1.0/src/tripaulx/accounts/services/verification.py +38 -0
  77. tripaulx_sdk-0.1.0/src/tripaulx/accounts/signals.py +12 -0
  78. tripaulx_sdk-0.1.0/src/tripaulx/accounts/templates/tripaulx/mail/code_base.html +9 -0
  79. tripaulx_sdk-0.1.0/src/tripaulx/accounts/templates/tripaulx/mail/code_base.txt +8 -0
  80. tripaulx_sdk-0.1.0/src/tripaulx/accounts/templates/tripaulx/mail/email_verify.html +5 -0
  81. tripaulx_sdk-0.1.0/src/tripaulx/accounts/templates/tripaulx/mail/email_verify.txt +3 -0
  82. tripaulx_sdk-0.1.0/src/tripaulx/accounts/templates/tripaulx/mail/greeting.txt +1 -0
  83. tripaulx_sdk-0.1.0/src/tripaulx/accounts/templates/tripaulx/mail/invite.html +13 -0
  84. tripaulx_sdk-0.1.0/src/tripaulx/accounts/templates/tripaulx/mail/invite.txt +8 -0
  85. tripaulx_sdk-0.1.0/src/tripaulx/accounts/templates/tripaulx/mail/login_2fa.html +5 -0
  86. tripaulx_sdk-0.1.0/src/tripaulx/accounts/templates/tripaulx/mail/login_2fa.txt +3 -0
  87. tripaulx_sdk-0.1.0/src/tripaulx/accounts/templates/tripaulx/mail/password_reset.html +5 -0
  88. tripaulx_sdk-0.1.0/src/tripaulx/accounts/templates/tripaulx/mail/password_reset.txt +3 -0
  89. tripaulx_sdk-0.1.0/src/tripaulx/ai/__init__.py +9 -0
  90. tripaulx_sdk-0.1.0/src/tripaulx/ai/admin/__init__.py +6 -0
  91. tripaulx_sdk-0.1.0/src/tripaulx/ai/admin/agents.py +125 -0
  92. tripaulx_sdk-0.1.0/src/tripaulx/ai/admin/readonly.py +76 -0
  93. tripaulx_sdk-0.1.0/src/tripaulx/ai/admin/settings.py +136 -0
  94. tripaulx_sdk-0.1.0/src/tripaulx/ai/api/__init__.py +1 -0
  95. tripaulx_sdk-0.1.0/src/tripaulx/ai/api/pagination.py +11 -0
  96. tripaulx_sdk-0.1.0/src/tripaulx/ai/api/permissions.py +33 -0
  97. tripaulx_sdk-0.1.0/src/tripaulx/ai/api/serializers/__init__.py +32 -0
  98. tripaulx_sdk-0.1.0/src/tripaulx/ai/api/serializers/agent_links.py +115 -0
  99. tripaulx_sdk-0.1.0/src/tripaulx/ai/api/serializers/agents.py +197 -0
  100. tripaulx_sdk-0.1.0/src/tripaulx/ai/api/serializers/common.py +57 -0
  101. tripaulx_sdk-0.1.0/src/tripaulx/ai/api/serializers/events.py +94 -0
  102. tripaulx_sdk-0.1.0/src/tripaulx/ai/api/serializers/keys.py +66 -0
  103. tripaulx_sdk-0.1.0/src/tripaulx/ai/api/serializers/runs.py +111 -0
  104. tripaulx_sdk-0.1.0/src/tripaulx/ai/api/serializers/settings.py +158 -0
  105. tripaulx_sdk-0.1.0/src/tripaulx/ai/api/serializers/skills.py +114 -0
  106. tripaulx_sdk-0.1.0/src/tripaulx/ai/api/urls.py +40 -0
  107. tripaulx_sdk-0.1.0/src/tripaulx/ai/api/views/__init__.py +20 -0
  108. tripaulx_sdk-0.1.0/src/tripaulx/ai/api/views/agents.py +91 -0
  109. tripaulx_sdk-0.1.0/src/tripaulx/ai/api/views/common.py +8 -0
  110. tripaulx_sdk-0.1.0/src/tripaulx/ai/api/views/events.py +116 -0
  111. tripaulx_sdk-0.1.0/src/tripaulx/ai/api/views/executions.py +74 -0
  112. tripaulx_sdk-0.1.0/src/tripaulx/ai/api/views/keys.py +65 -0
  113. tripaulx_sdk-0.1.0/src/tripaulx/ai/api/views/run_response.py +67 -0
  114. tripaulx_sdk-0.1.0/src/tripaulx/ai/api/views/settings.py +121 -0
  115. tripaulx_sdk-0.1.0/src/tripaulx/ai/api/views/skills.py +79 -0
  116. tripaulx_sdk-0.1.0/src/tripaulx/ai/apps.py +13 -0
  117. tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/__init__.py +1 -0
  118. tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/admin/__init__.py +90 -0
  119. tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/apps.py +13 -0
  120. tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/management/__init__.py +1 -0
  121. tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/management/commands/__init__.py +1 -0
  122. tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/management/commands/ai_sync_catalog.py +44 -0
  123. tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/migrations/0001_initial.py +186 -0
  124. tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/migrations/0002_seed_models.py +246 -0
  125. tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/migrations/__init__.py +0 -0
  126. tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/models/__init__.py +5 -0
  127. tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/models/ai_model.py +145 -0
  128. tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/services/__init__.py +31 -0
  129. tripaulx_sdk-0.1.0/src/tripaulx/ai/catalog/services/sync.py +125 -0
  130. tripaulx_sdk-0.1.0/src/tripaulx/ai/conf.py +43 -0
  131. tripaulx_sdk-0.1.0/src/tripaulx/ai/locale/pt_BR/LC_MESSAGES/django.mo +0 -0
  132. tripaulx_sdk-0.1.0/src/tripaulx/ai/locale/pt_BR/LC_MESSAGES/django.po +1167 -0
  133. tripaulx_sdk-0.1.0/src/tripaulx/ai/management/__init__.py +1 -0
  134. tripaulx_sdk-0.1.0/src/tripaulx/ai/management/commands/__init__.py +1 -0
  135. tripaulx_sdk-0.1.0/src/tripaulx/ai/management/commands/ai_purge_content.py +42 -0
  136. tripaulx_sdk-0.1.0/src/tripaulx/ai/migrations/0001_initial.py +1009 -0
  137. tripaulx_sdk-0.1.0/src/tripaulx/ai/migrations/__init__.py +0 -0
  138. tripaulx_sdk-0.1.0/src/tripaulx/ai/models/__init__.py +34 -0
  139. tripaulx_sdk-0.1.0/src/tripaulx/ai/models/agent.py +172 -0
  140. tripaulx_sdk-0.1.0/src/tripaulx/ai/models/choices.py +58 -0
  141. tripaulx_sdk-0.1.0/src/tripaulx/ai/models/event.py +140 -0
  142. tripaulx_sdk-0.1.0/src/tripaulx/ai/models/key.py +108 -0
  143. tripaulx_sdk-0.1.0/src/tripaulx/ai/models/settings.py +142 -0
  144. tripaulx_sdk-0.1.0/src/tripaulx/ai/models/skill.py +143 -0
  145. tripaulx_sdk-0.1.0/src/tripaulx/ai/models/slug.py +26 -0
  146. tripaulx_sdk-0.1.0/src/tripaulx/ai/models/team.py +72 -0
  147. tripaulx_sdk-0.1.0/src/tripaulx/ai/providers/__init__.py +94 -0
  148. tripaulx_sdk-0.1.0/src/tripaulx/ai/providers/anthropic_messages.py +178 -0
  149. tripaulx_sdk-0.1.0/src/tripaulx/ai/providers/base.py +193 -0
  150. tripaulx_sdk-0.1.0/src/tripaulx/ai/providers/common.py +108 -0
  151. tripaulx_sdk-0.1.0/src/tripaulx/ai/providers/errors.py +170 -0
  152. tripaulx_sdk-0.1.0/src/tripaulx/ai/providers/openai_responses.py +153 -0
  153. tripaulx_sdk-0.1.0/src/tripaulx/ai/services/__init__.py +1 -0
  154. tripaulx_sdk-0.1.0/src/tripaulx/ai/services/agents.py +94 -0
  155. tripaulx_sdk-0.1.0/src/tripaulx/ai/services/budget.py +55 -0
  156. tripaulx_sdk-0.1.0/src/tripaulx/ai/services/dashboard.py +81 -0
  157. tripaulx_sdk-0.1.0/src/tripaulx/ai/services/events.py +135 -0
  158. tripaulx_sdk-0.1.0/src/tripaulx/ai/services/execution/__init__.py +149 -0
  159. tripaulx_sdk-0.1.0/src/tripaulx/ai/services/execution/params.py +96 -0
  160. tripaulx_sdk-0.1.0/src/tripaulx/ai/services/execution/results.py +97 -0
  161. tripaulx_sdk-0.1.0/src/tripaulx/ai/services/execution/steps.py +153 -0
  162. tripaulx_sdk-0.1.0/src/tripaulx/ai/services/keys.py +125 -0
  163. tripaulx_sdk-0.1.0/src/tripaulx/ai/services/model_choice.py +50 -0
  164. tripaulx_sdk-0.1.0/src/tripaulx/ai/services/origins.py +54 -0
  165. tripaulx_sdk-0.1.0/src/tripaulx/ai/services/prices.py +90 -0
  166. tripaulx_sdk-0.1.0/src/tripaulx/ai/services/probe.py +96 -0
  167. tripaulx_sdk-0.1.0/src/tripaulx/ai/services/prompt.py +106 -0
  168. tripaulx_sdk-0.1.0/src/tripaulx/ai/services/report.py +183 -0
  169. tripaulx_sdk-0.1.0/src/tripaulx/ai/services/retention.py +68 -0
  170. tripaulx_sdk-0.1.0/src/tripaulx/ai/services/skills.py +74 -0
  171. tripaulx_sdk-0.1.0/src/tripaulx/ai/tasks/__init__.py +12 -0
  172. tripaulx_sdk-0.1.0/src/tripaulx/ai/tasks/purge.py +13 -0
  173. tripaulx_sdk-0.1.0/src/tripaulx/ai/tasks/run.py +132 -0
  174. tripaulx_sdk-0.1.0/src/tripaulx/ai/validators/__init__.py +60 -0
  175. tripaulx_sdk-0.1.0/src/tripaulx/core/__init__.py +1 -0
  176. tripaulx_sdk-0.1.0/src/tripaulx/core/apps.py +13 -0
  177. tripaulx_sdk-0.1.0/src/tripaulx/core/conf.py +42 -0
  178. tripaulx_sdk-0.1.0/src/tripaulx/core/crypto.py +79 -0
  179. tripaulx_sdk-0.1.0/src/tripaulx/core/locale/pt_BR/LC_MESSAGES/django.mo +0 -0
  180. tripaulx_sdk-0.1.0/src/tripaulx/core/locale/pt_BR/LC_MESSAGES/django.po +35 -0
  181. tripaulx_sdk-0.1.0/src/tripaulx/core/logs/__init__.py +1 -0
  182. tripaulx_sdk-0.1.0/src/tripaulx/core/logs/redaction.py +66 -0
  183. tripaulx_sdk-0.1.0/src/tripaulx/core/middleware/__init__.py +5 -0
  184. tripaulx_sdk-0.1.0/src/tripaulx/core/middleware/tenant.py +38 -0
  185. tripaulx_sdk-0.1.0/src/tripaulx/core/models/__init__.py +6 -0
  186. tripaulx_sdk-0.1.0/src/tripaulx/core/models/base.py +56 -0
  187. tripaulx_sdk-0.1.0/src/tripaulx/core/models/managers.py +18 -0
  188. tripaulx_sdk-0.1.0/src/tripaulx/core/testing/__init__.py +5 -0
  189. tripaulx_sdk-0.1.0/src/tripaulx/core/testing/cases.py +69 -0
  190. tripaulx_sdk-0.1.0/src/tripaulx/core/urls.py +12 -0
  191. tripaulx_sdk-0.1.0/src/tripaulx/core/views/__init__.py +5 -0
  192. tripaulx_sdk-0.1.0/src/tripaulx/core/views/health.py +31 -0
  193. tripaulx_sdk-0.1.0/src/tripaulx/legal/__init__.py +7 -0
  194. tripaulx_sdk-0.1.0/src/tripaulx/legal/api/__init__.py +1 -0
  195. tripaulx_sdk-0.1.0/src/tripaulx/legal/api/permissions.py +21 -0
  196. tripaulx_sdk-0.1.0/src/tripaulx/legal/api/serializers/__init__.py +13 -0
  197. tripaulx_sdk-0.1.0/src/tripaulx/legal/api/serializers/documents.py +31 -0
  198. tripaulx_sdk-0.1.0/src/tripaulx/legal/api/urls.py +19 -0
  199. tripaulx_sdk-0.1.0/src/tripaulx/legal/api/urls_public.py +21 -0
  200. tripaulx_sdk-0.1.0/src/tripaulx/legal/api/views/__init__.py +4 -0
  201. tripaulx_sdk-0.1.0/src/tripaulx/legal/api/views/base.py +44 -0
  202. tripaulx_sdk-0.1.0/src/tripaulx/legal/api/views/public.py +52 -0
  203. tripaulx_sdk-0.1.0/src/tripaulx/legal/api/views/restricted.py +43 -0
  204. tripaulx_sdk-0.1.0/src/tripaulx/legal/apps.py +13 -0
  205. tripaulx_sdk-0.1.0/src/tripaulx/legal/conf.py +59 -0
  206. tripaulx_sdk-0.1.0/src/tripaulx/legal/content/en/data-inventory.md +48 -0
  207. tripaulx_sdk-0.1.0/src/tripaulx/legal/content/en/governance-backlog.md +38 -0
  208. tripaulx_sdk-0.1.0/src/tripaulx/legal/content/en/incident-record-template.md +61 -0
  209. tripaulx_sdk-0.1.0/src/tripaulx/legal/content/en/incident-register.md +41 -0
  210. tripaulx_sdk-0.1.0/src/tripaulx/legal/content/en/incident-response-plan.md +59 -0
  211. tripaulx_sdk-0.1.0/src/tripaulx/legal/content/en/privacy-policy.md +81 -0
  212. tripaulx_sdk-0.1.0/src/tripaulx/legal/content/en/risk-matrix.md +49 -0
  213. tripaulx_sdk-0.1.0/src/tripaulx/legal/content/en/terms-of-use.md +69 -0
  214. tripaulx_sdk-0.1.0/src/tripaulx/legal/content/pt_BR/data-inventory.md +48 -0
  215. tripaulx_sdk-0.1.0/src/tripaulx/legal/content/pt_BR/governance-backlog.md +38 -0
  216. tripaulx_sdk-0.1.0/src/tripaulx/legal/content/pt_BR/incident-record-template.md +61 -0
  217. tripaulx_sdk-0.1.0/src/tripaulx/legal/content/pt_BR/incident-register.md +41 -0
  218. tripaulx_sdk-0.1.0/src/tripaulx/legal/content/pt_BR/incident-response-plan.md +59 -0
  219. tripaulx_sdk-0.1.0/src/tripaulx/legal/content/pt_BR/privacy-policy.md +81 -0
  220. tripaulx_sdk-0.1.0/src/tripaulx/legal/content/pt_BR/risk-matrix.md +49 -0
  221. tripaulx_sdk-0.1.0/src/tripaulx/legal/content/pt_BR/terms-of-use.md +69 -0
  222. tripaulx_sdk-0.1.0/src/tripaulx/legal/locale/pt_BR/LC_MESSAGES/django.mo +0 -0
  223. tripaulx_sdk-0.1.0/src/tripaulx/legal/locale/pt_BR/LC_MESSAGES/django.po +119 -0
  224. tripaulx_sdk-0.1.0/src/tripaulx/legal/management/__init__.py +1 -0
  225. tripaulx_sdk-0.1.0/src/tripaulx/legal/management/commands/__init__.py +1 -0
  226. tripaulx_sdk-0.1.0/src/tripaulx/legal/management/commands/legal_check.py +85 -0
  227. tripaulx_sdk-0.1.0/src/tripaulx/legal/services/__init__.py +41 -0
  228. tripaulx_sdk-0.1.0/src/tripaulx/legal/services/access.py +53 -0
  229. tripaulx_sdk-0.1.0/src/tripaulx/legal/services/catalog.py +55 -0
  230. tripaulx_sdk-0.1.0/src/tripaulx/legal/services/defaults.py +74 -0
  231. tripaulx_sdk-0.1.0/src/tripaulx/legal/services/document.py +49 -0
  232. tripaulx_sdk-0.1.0/src/tripaulx/legal/services/markdown/__init__.py +87 -0
  233. tripaulx_sdk-0.1.0/src/tripaulx/legal/services/markdown/blocks.py +131 -0
  234. tripaulx_sdk-0.1.0/src/tripaulx/legal/services/markdown/inline.py +71 -0
  235. tripaulx_sdk-0.1.0/src/tripaulx/legal/services/markdown/tables.py +108 -0
  236. tripaulx_sdk-0.1.0/src/tripaulx/legal/services/placeholders.py +45 -0
  237. tripaulx_sdk-0.1.0/src/tripaulx/legal/services/render.py +41 -0
  238. tripaulx_sdk-0.1.0/src/tripaulx/legal/services/sources.py +90 -0
  239. tripaulx_sdk-0.1.0/src/tripaulx/mail/__init__.py +1 -0
  240. tripaulx_sdk-0.1.0/src/tripaulx/mail/admin/__init__.py +5 -0
  241. tripaulx_sdk-0.1.0/src/tripaulx/mail/admin/mailgun_config.py +91 -0
  242. tripaulx_sdk-0.1.0/src/tripaulx/mail/apps.py +13 -0
  243. tripaulx_sdk-0.1.0/src/tripaulx/mail/backends/__init__.py +5 -0
  244. tripaulx_sdk-0.1.0/src/tripaulx/mail/backends/mailgun.py +122 -0
  245. tripaulx_sdk-0.1.0/src/tripaulx/mail/backends/multipart.py +24 -0
  246. tripaulx_sdk-0.1.0/src/tripaulx/mail/conf.py +11 -0
  247. tripaulx_sdk-0.1.0/src/tripaulx/mail/locale/pt_BR/LC_MESSAGES/django.mo +0 -0
  248. tripaulx_sdk-0.1.0/src/tripaulx/mail/locale/pt_BR/LC_MESSAGES/django.po +91 -0
  249. tripaulx_sdk-0.1.0/src/tripaulx/mail/migrations/0001_initial.py +78 -0
  250. tripaulx_sdk-0.1.0/src/tripaulx/mail/migrations/__init__.py +0 -0
  251. tripaulx_sdk-0.1.0/src/tripaulx/mail/models/__init__.py +5 -0
  252. tripaulx_sdk-0.1.0/src/tripaulx/mail/models/mailgun_config.py +92 -0
  253. tripaulx_sdk-0.1.0/src/tripaulx/mail/services/__init__.py +5 -0
  254. tripaulx_sdk-0.1.0/src/tripaulx/mail/services/templated.py +51 -0
  255. tripaulx_sdk-0.1.0/src/tripaulx/mail/templates/tripaulx/mail/base.html +32 -0
  256. tripaulx_sdk-0.1.0/src/tripaulx/settings/__init__.py +6 -0
  257. tripaulx_sdk-0.1.0/src/tripaulx/settings/apps.py +81 -0
  258. tripaulx_sdk-0.1.0/src/tripaulx/settings/env.py +110 -0
  259. tripaulx_sdk-0.1.0/src/tripaulx/settings/middleware.py +30 -0
  260. tripaulx_sdk-0.1.0/src/tripaulx/settings/observability.py +38 -0
  261. tripaulx_sdk-0.1.0/src/tripaulx/settings/rest.py +120 -0
  262. tripaulx_sdk-0.1.0/src/tripaulx/settings/security.py +30 -0
  263. tripaulx_sdk-0.1.0/src/tripaulx/storage/__init__.py +5 -0
  264. tripaulx_sdk-0.1.0/src/tripaulx/storage/apps.py +13 -0
  265. tripaulx_sdk-0.1.0/src/tripaulx/storage/client.py +73 -0
  266. tripaulx_sdk-0.1.0/src/tripaulx/storage/conf.py +43 -0
  267. tripaulx_sdk-0.1.0/src/tripaulx/storage/crypto/__init__.py +40 -0
  268. tripaulx_sdk-0.1.0/src/tripaulx/storage/crypto/envelope.py +135 -0
  269. tripaulx_sdk-0.1.0/src/tripaulx/storage/crypto/keys.py +56 -0
  270. tripaulx_sdk-0.1.0/src/tripaulx/storage/exceptions.py +15 -0
  271. tripaulx_sdk-0.1.0/src/tripaulx/storage/locale/pt_BR/LC_MESSAGES/django.mo +0 -0
  272. tripaulx_sdk-0.1.0/src/tripaulx/storage/locale/pt_BR/LC_MESSAGES/django.po +125 -0
  273. tripaulx_sdk-0.1.0/src/tripaulx/storage/management/__init__.py +1 -0
  274. tripaulx_sdk-0.1.0/src/tripaulx/storage/management/commands/__init__.py +1 -0
  275. tripaulx_sdk-0.1.0/src/tripaulx/storage/management/commands/check_bucket.py +148 -0
  276. tripaulx_sdk-0.1.0/src/tripaulx/storage/management/commands/generate_file_key.py +35 -0
  277. tripaulx_sdk-0.1.0/src/tripaulx/storage/services/__init__.py +34 -0
  278. tripaulx_sdk-0.1.0/src/tripaulx/storage/services/access.py +95 -0
  279. tripaulx_sdk-0.1.0/src/tripaulx/storage/services/keys.py +65 -0
  280. tripaulx_sdk-0.1.0/src/tripaulx/storage/services/policy.py +126 -0
  281. tripaulx_sdk-0.1.0/src/tripaulx/storage/services/streams.py +64 -0
  282. tripaulx_sdk-0.1.0/src/tripaulx/storage/services/upload.py +115 -0
  283. tripaulx_sdk-0.1.0/src/tripaulx/tenants/__init__.py +1 -0
  284. tripaulx_sdk-0.1.0/src/tripaulx/tenants/admin/__init__.py +5 -0
  285. tripaulx_sdk-0.1.0/src/tripaulx/tenants/admin/workspace.py +36 -0
  286. tripaulx_sdk-0.1.0/src/tripaulx/tenants/apps.py +13 -0
  287. tripaulx_sdk-0.1.0/src/tripaulx/tenants/conf.py +18 -0
  288. tripaulx_sdk-0.1.0/src/tripaulx/tenants/locale/pt_BR/LC_MESSAGES/django.mo +0 -0
  289. tripaulx_sdk-0.1.0/src/tripaulx/tenants/locale/pt_BR/LC_MESSAGES/django.po +70 -0
  290. tripaulx_sdk-0.1.0/src/tripaulx/tenants/management/__init__.py +1 -0
  291. tripaulx_sdk-0.1.0/src/tripaulx/tenants/management/commands/__init__.py +1 -0
  292. tripaulx_sdk-0.1.0/src/tripaulx/tenants/management/commands/bootstrap_workspace.py +75 -0
  293. tripaulx_sdk-0.1.0/src/tripaulx/tenants/migrations/0001_initial.py +86 -0
  294. tripaulx_sdk-0.1.0/src/tripaulx/tenants/migrations/__init__.py +0 -0
  295. tripaulx_sdk-0.1.0/src/tripaulx/tenants/models/__init__.py +6 -0
  296. tripaulx_sdk-0.1.0/src/tripaulx/tenants/models/domain.py +18 -0
  297. tripaulx_sdk-0.1.0/src/tripaulx/tenants/models/workspace.py +30 -0
  298. tripaulx_sdk-0.1.0/src/tripaulx/tenants/services/__init__.py +1 -0
  299. tripaulx_sdk-0.1.0/src/tripaulx/tenants/services/bootstrap.py +53 -0
  300. tripaulx_sdk-0.1.0/src/tripaulx/tenants/services/domains.py +18 -0
  301. tripaulx_sdk-0.1.0/src/tripaulx/tenants/services/provisioning.py +65 -0
  302. tripaulx_sdk-0.1.0/src/tripaulx/tenants/services/slugs.py +36 -0
  303. tripaulx_sdk-0.1.0/src/tripaulx/tenants/signals.py +11 -0
  304. tripaulx_sdk-0.1.0/src/tripaulx/tenants/validators/__init__.py +5 -0
  305. tripaulx_sdk-0.1.0/src/tripaulx/tenants/validators/slug.py +48 -0
  306. tripaulx_sdk-0.1.0/tests/__init__.py +0 -0
  307. tripaulx_sdk-0.1.0/tests/accounts/__init__.py +0 -0
  308. tripaulx_sdk-0.1.0/tests/accounts/helpers.py +56 -0
  309. tripaulx_sdk-0.1.0/tests/accounts/test_command.py +43 -0
  310. tripaulx_sdk-0.1.0/tests/accounts/test_email_verify.py +53 -0
  311. tripaulx_sdk-0.1.0/tests/accounts/test_invitations.py +95 -0
  312. tripaulx_sdk-0.1.0/tests/accounts/test_jwt_tenant.py +76 -0
  313. tripaulx_sdk-0.1.0/tests/accounts/test_login_flow.py +117 -0
  314. tripaulx_sdk-0.1.0/tests/accounts/test_members.py +102 -0
  315. tripaulx_sdk-0.1.0/tests/accounts/test_passkey_rp.py +74 -0
  316. tripaulx_sdk-0.1.0/tests/accounts/test_passkey_rules.py +113 -0
  317. tripaulx_sdk-0.1.0/tests/accounts/test_password_change.py +44 -0
  318. tripaulx_sdk-0.1.0/tests/accounts/test_password_reset.py +65 -0
  319. tripaulx_sdk-0.1.0/tests/accounts/test_privileged_mfa.py +48 -0
  320. tripaulx_sdk-0.1.0/tests/accounts/test_recovery_codes.py +101 -0
  321. tripaulx_sdk-0.1.0/tests/accounts/test_refresh_throttle.py +36 -0
  322. tripaulx_sdk-0.1.0/tests/accounts/test_signup.py +91 -0
  323. tripaulx_sdk-0.1.0/tests/accounts/test_totp_algorithm.py +61 -0
  324. tripaulx_sdk-0.1.0/tests/accounts/test_totp_api.py +83 -0
  325. tripaulx_sdk-0.1.0/tests/accounts/test_totp_login.py +97 -0
  326. tripaulx_sdk-0.1.0/tests/accounts/test_trusted_devices.py +59 -0
  327. tripaulx_sdk-0.1.0/tests/ai/__init__.py +0 -0
  328. tripaulx_sdk-0.1.0/tests/ai/helpers.py +174 -0
  329. tripaulx_sdk-0.1.0/tests/ai/test_admin.py +64 -0
  330. tripaulx_sdk-0.1.0/tests/ai/test_agents_api.py +160 -0
  331. tripaulx_sdk-0.1.0/tests/ai/test_anthropic_client.py +155 -0
  332. tripaulx_sdk-0.1.0/tests/ai/test_catalog.py +133 -0
  333. tripaulx_sdk-0.1.0/tests/ai/test_events_api.py +86 -0
  334. tripaulx_sdk-0.1.0/tests/ai/test_events_budget.py +143 -0
  335. tripaulx_sdk-0.1.0/tests/ai/test_execution_prechecks.py +90 -0
  336. tripaulx_sdk-0.1.0/tests/ai/test_execution_runs.py +148 -0
  337. tripaulx_sdk-0.1.0/tests/ai/test_i18n.py +13 -0
  338. tripaulx_sdk-0.1.0/tests/ai/test_keys_api.py +82 -0
  339. tripaulx_sdk-0.1.0/tests/ai/test_keys_service.py +99 -0
  340. tripaulx_sdk-0.1.0/tests/ai/test_models.py +71 -0
  341. tripaulx_sdk-0.1.0/tests/ai/test_openai_call.py +136 -0
  342. tripaulx_sdk-0.1.0/tests/ai/test_openai_params.py +135 -0
  343. tripaulx_sdk-0.1.0/tests/ai/test_prices_prompt.py +98 -0
  344. tripaulx_sdk-0.1.0/tests/ai/test_probe.py +110 -0
  345. tripaulx_sdk-0.1.0/tests/ai/test_registry.py +86 -0
  346. tripaulx_sdk-0.1.0/tests/ai/test_report.py +86 -0
  347. tripaulx_sdk-0.1.0/tests/ai/test_retention.py +80 -0
  348. tripaulx_sdk-0.1.0/tests/ai/test_settings_api.py +107 -0
  349. tripaulx_sdk-0.1.0/tests/ai/test_skills_api.py +71 -0
  350. tripaulx_sdk-0.1.0/tests/ai/test_tasks.py +166 -0
  351. tripaulx_sdk-0.1.0/tests/conftest.py +27 -0
  352. tripaulx_sdk-0.1.0/tests/legal/__init__.py +0 -0
  353. tripaulx_sdk-0.1.0/tests/legal/test_access.py +29 -0
  354. tripaulx_sdk-0.1.0/tests/legal/test_api_public.py +51 -0
  355. tripaulx_sdk-0.1.0/tests/legal/test_api_restricted.py +97 -0
  356. tripaulx_sdk-0.1.0/tests/legal/test_catalog.py +65 -0
  357. tripaulx_sdk-0.1.0/tests/legal/test_markdown.py +67 -0
  358. tripaulx_sdk-0.1.0/tests/legal/test_placeholders.py +69 -0
  359. tripaulx_sdk-0.1.0/tests/legal/test_sources.py +90 -0
  360. tripaulx_sdk-0.1.0/tests/legal/test_tables.py +57 -0
  361. tripaulx_sdk-0.1.0/tests/mail/__init__.py +0 -0
  362. tripaulx_sdk-0.1.0/tests/mail/test_backend.py +104 -0
  363. tripaulx_sdk-0.1.0/tests/mail/test_config.py +46 -0
  364. tripaulx_sdk-0.1.0/tests/mail/test_mailers.py +47 -0
  365. tripaulx_sdk-0.1.0/tests/mail/test_templated.py +50 -0
  366. tripaulx_sdk-0.1.0/tests/project/__init__.py +0 -0
  367. tripaulx_sdk-0.1.0/tests/project/sample/__init__.py +1 -0
  368. tripaulx_sdk-0.1.0/tests/project/sample/apps.py +10 -0
  369. tripaulx_sdk-0.1.0/tests/project/sample/migrations/0001_initial.py +52 -0
  370. tripaulx_sdk-0.1.0/tests/project/sample/migrations/__init__.py +0 -0
  371. tripaulx_sdk-0.1.0/tests/project/sample/models.py +11 -0
  372. tripaulx_sdk-0.1.0/tests/project/settings.py +71 -0
  373. tripaulx_sdk-0.1.0/tests/project/urls.py +14 -0
  374. tripaulx_sdk-0.1.0/tests/project/urls_public.py +12 -0
  375. tripaulx_sdk-0.1.0/tests/project/users/__init__.py +1 -0
  376. tripaulx_sdk-0.1.0/tests/project/users/apps.py +11 -0
  377. tripaulx_sdk-0.1.0/tests/project/users/migrations/0001_initial.py +145 -0
  378. tripaulx_sdk-0.1.0/tests/project/users/migrations/__init__.py +0 -0
  379. tripaulx_sdk-0.1.0/tests/project/users/models.py +7 -0
  380. tripaulx_sdk-0.1.0/tests/storage/__init__.py +0 -0
  381. tripaulx_sdk-0.1.0/tests/storage/conftest.py +21 -0
  382. tripaulx_sdk-0.1.0/tests/storage/helpers.py +77 -0
  383. tripaulx_sdk-0.1.0/tests/storage/test_access.py +112 -0
  384. tripaulx_sdk-0.1.0/tests/storage/test_client.py +67 -0
  385. tripaulx_sdk-0.1.0/tests/storage/test_commands.py +109 -0
  386. tripaulx_sdk-0.1.0/tests/storage/test_crypto.py +139 -0
  387. tripaulx_sdk-0.1.0/tests/storage/test_keys.py +79 -0
  388. tripaulx_sdk-0.1.0/tests/storage/test_upload.py +140 -0
  389. tripaulx_sdk-0.1.0/tests/storage/test_upload_image.py +126 -0
  390. tripaulx_sdk-0.1.0/tests/test_bootstrap.py +43 -0
  391. tripaulx_sdk-0.1.0/tests/test_crypto.py +53 -0
  392. tripaulx_sdk-0.1.0/tests/test_domains.py +14 -0
  393. tripaulx_sdk-0.1.0/tests/test_env.py +57 -0
  394. tripaulx_sdk-0.1.0/tests/test_health.py +22 -0
  395. tripaulx_sdk-0.1.0/tests/test_i18n.py +10 -0
  396. tripaulx_sdk-0.1.0/tests/test_redaction.py +33 -0
  397. tripaulx_sdk-0.1.0/tests/test_rest_settings.py +54 -0
  398. tripaulx_sdk-0.1.0/tests/test_settings_helpers.py +33 -0
  399. tripaulx_sdk-0.1.0/tests/test_slugs.py +47 -0
  400. tripaulx_sdk-0.1.0/tests/test_tenant_models.py +37 -0
@@ -0,0 +1,20 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .venv/
5
+ .pytest_cache/
6
+ .ruff_cache/
7
+ .coverage
8
+ htmlcov/
9
+ dist/
10
+ build/
11
+ .env
12
+ .env.*
13
+ !.env.example
14
+ !.env.*.example
15
+ .DS_Store
16
+ .idea/
17
+ .vscode/
18
+ # Rendered from template/ by scripts/render_example.sh (never committed).
19
+ example/
20
+ .claude/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tripaulx
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,80 @@
1
+ Metadata-Version: 2.5
2
+ Name: tripaulx-sdk
3
+ Version: 0.1.0
4
+ Summary: Multi-tenant Django foundation: workspaces, accounts with mandatory 2FA and passkeys, AI providers, legal and storage.
5
+ Project-URL: Homepage, https://github.com/tripaulx/tripaulx-builder-init
6
+ Project-URL: Issues, https://github.com/tripaulx/tripaulx-builder-init/issues
7
+ Author-email: Flavio Almeida Paulino <f1@tripaulx.com>
8
+ Maintainer-email: Flavio Almeida Paulino <f1@tripaulx.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Classifier: Framework :: Django
12
+ Classifier: Framework :: Django :: 6.0
13
+ Classifier: Framework :: Django :: 6.1
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Natural Language :: English
16
+ Classifier: Natural Language :: Portuguese (Brazilian)
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Requires-Python: >=3.12
21
+ Requires-Dist: cryptography>=44
22
+ Requires-Dist: django-cors-headers<5,>=4.9
23
+ Requires-Dist: django-tenants<4,>=3.14
24
+ Requires-Dist: django<6.2,>=6.0
25
+ Requires-Dist: djangorestframework-simplejwt<6,>=5.5
26
+ Requires-Dist: djangorestframework<4,>=3.16
27
+ Requires-Dist: drf-spectacular<1,>=0.28
28
+ Requires-Dist: nh3<1,>=0.2.17
29
+ Requires-Dist: psycopg[binary]<4,>=3.2
30
+ Requires-Dist: python-dotenv>=1.1
31
+ Requires-Dist: qrcode<9,>=8
32
+ Requires-Dist: webauthn<4,>=3
33
+ Provides-Extra: ai
34
+ Requires-Dist: anthropic>=1.0; extra == 'ai'
35
+ Requires-Dist: openai>=2; extra == 'ai'
36
+ Provides-Extra: anthropic
37
+ Requires-Dist: anthropic>=1.0; extra == 'anthropic'
38
+ Provides-Extra: openai
39
+ Requires-Dist: openai>=2; extra == 'openai'
40
+ Provides-Extra: storage
41
+ Requires-Dist: boto3<2,>=1.36; extra == 'storage'
42
+ Requires-Dist: cryptography>=44; extra == 'storage'
43
+ Requires-Dist: pillow>=11; extra == 'storage'
44
+ Description-Content-Type: text/markdown
45
+
46
+ # tripaulx-sdk
47
+
48
+ The shared foundation of tripaulx-builders Django projects. It provides:
49
+
50
+ - multi-tenant Django 6 with **workspaces** (django-tenants, one PostgreSQL schema each);
51
+ - accounts with mandatory 2FA, an authenticator app (TOTP) and passkeys;
52
+ - AI providers, agents and skills with cost tracking;
53
+ - governance and legal documents;
54
+ - encrypted object storage.
55
+
56
+ It ships an API and the Django admin. There is no frontend.
57
+
58
+ > Version **0.1.0**. See the
59
+ > [project repository](https://github.com/tripaulx/tripaulx-builder-init) and its
60
+ > Copier template to start a new project.
61
+
62
+ ## Install
63
+
64
+ ```bash
65
+ uv add "tripaulx-sdk[storage,ai]" # extras: storage, openai, anthropic, ai
66
+ ```
67
+
68
+ Start new projects from the Copier template instead of wiring settings by hand:
69
+
70
+ ```bash
71
+ uvx copier copy --trust gh:tripaulx/tripaulx-builder-init my-project
72
+ ```
73
+
74
+ ## Maintainer
75
+
76
+ Flavio Almeida Paulino ([f1@tripaulx.com](mailto:f1@tripaulx.com?subject=%5Btripaulx-sdk%5D)).
77
+
78
+ ## License
79
+
80
+ MIT
@@ -0,0 +1,35 @@
1
+ # tripaulx-sdk
2
+
3
+ The shared foundation of tripaulx-builders Django projects. It provides:
4
+
5
+ - multi-tenant Django 6 with **workspaces** (django-tenants, one PostgreSQL schema each);
6
+ - accounts with mandatory 2FA, an authenticator app (TOTP) and passkeys;
7
+ - AI providers, agents and skills with cost tracking;
8
+ - governance and legal documents;
9
+ - encrypted object storage.
10
+
11
+ It ships an API and the Django admin. There is no frontend.
12
+
13
+ > Version **0.1.0**. See the
14
+ > [project repository](https://github.com/tripaulx/tripaulx-builder-init) and its
15
+ > Copier template to start a new project.
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ uv add "tripaulx-sdk[storage,ai]" # extras: storage, openai, anthropic, ai
21
+ ```
22
+
23
+ Start new projects from the Copier template instead of wiring settings by hand:
24
+
25
+ ```bash
26
+ uvx copier copy --trust gh:tripaulx/tripaulx-builder-init my-project
27
+ ```
28
+
29
+ ## Maintainer
30
+
31
+ Flavio Almeida Paulino ([f1@tripaulx.com](mailto:f1@tripaulx.com?subject=%5Btripaulx-sdk%5D)).
32
+
33
+ ## License
34
+
35
+ MIT
@@ -0,0 +1,70 @@
1
+ [project]
2
+ name = "tripaulx-sdk"
3
+ dynamic = ["version"]
4
+ description = "Multi-tenant Django foundation: workspaces, accounts with mandatory 2FA and passkeys, AI providers, legal and storage."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ authors = [{ name = "Flavio Almeida Paulino", email = "f1@tripaulx.com" }]
9
+ maintainers = [{ name = "Flavio Almeida Paulino", email = "f1@tripaulx.com" }]
10
+ requires-python = ">=3.12"
11
+ classifiers = [
12
+ "Framework :: Django",
13
+ "Framework :: Django :: 6.0",
14
+ "Framework :: Django :: 6.1",
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3.12",
17
+ "Programming Language :: Python :: 3.13",
18
+ "Intended Audience :: Developers",
19
+ "Natural Language :: English",
20
+ "Natural Language :: Portuguese (Brazilian)",
21
+ ]
22
+ dependencies = [
23
+ "cryptography>=44",
24
+ "django>=6.0,<6.2",
25
+ "django-cors-headers>=4.9,<5",
26
+ "django-tenants>=3.14,<4",
27
+ "djangorestframework>=3.16,<4",
28
+ "djangorestframework-simplejwt>=5.5,<6",
29
+ "drf-spectacular>=0.28,<1",
30
+ "nh3>=0.2.17,<1",
31
+ "psycopg[binary]>=3.2,<4",
32
+ "python-dotenv>=1.1",
33
+ "qrcode>=8,<9",
34
+ "webauthn>=3,<4",
35
+ ]
36
+
37
+ [project.optional-dependencies]
38
+ # S3-compatible object storage with envelope encryption (tripaulx.storage).
39
+ # boto3 >= 1.36 needs request_checksum_calculation="when_required" for
40
+ # non-AWS providers; tripaulx.storage.client sets it.
41
+ storage = [
42
+ "boto3>=1.36,<2",
43
+ "cryptography>=44",
44
+ "pillow>=11",
45
+ ]
46
+ # AI providers (tripaulx.ai). Each SDK is imported lazily, only when a call
47
+ # goes to that provider; "ai" installs both.
48
+ openai = ["openai>=2"]
49
+ anthropic = ["anthropic>=1.0"]
50
+ ai = ["openai>=2", "anthropic>=1.0"]
51
+
52
+ [project.urls]
53
+ Homepage = "https://github.com/tripaulx/tripaulx-builder-init"
54
+ Issues = "https://github.com/tripaulx/tripaulx-builder-init/issues"
55
+
56
+ [build-system]
57
+ requires = ["hatchling>=1.27"]
58
+ build-backend = "hatchling.build"
59
+
60
+ [tool.hatch.version]
61
+ path = "src/tripaulx/__init__.py"
62
+
63
+ [tool.hatch.build.targets.wheel]
64
+ packages = ["src/tripaulx"]
65
+
66
+ [tool.pytest.ini_options]
67
+ DJANGO_SETTINGS_MODULE = "tests.project.settings"
68
+ pythonpath = ["src", "."]
69
+ testpaths = ["tests"]
70
+ python_files = ["test_*.py"]
@@ -0,0 +1,3 @@
1
+ """tripaulx-sdk: the shared foundation of tripaulx-builders Django projects."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1 @@
1
+ """Accounts: e-mail login, roles, mandatory 2FA, TOTP and passkeys."""
@@ -0,0 +1,25 @@
1
+ """Admin of the accounts app.
2
+
3
+ The security records are registered here; the user admin base class is
4
+ registered by each project for its concrete user model.
5
+ """
6
+
7
+ from .security import (
8
+ EmailCodeAdmin,
9
+ InvitationAdmin,
10
+ RecoveryCodeAdmin,
11
+ TotpDeviceAdmin,
12
+ TrustedDeviceAdmin,
13
+ WebAuthnCredentialAdmin,
14
+ )
15
+ from .user import TripaulxUserAdmin
16
+
17
+ __all__ = [
18
+ "EmailCodeAdmin",
19
+ "InvitationAdmin",
20
+ "RecoveryCodeAdmin",
21
+ "TotpDeviceAdmin",
22
+ "TripaulxUserAdmin",
23
+ "TrustedDeviceAdmin",
24
+ "WebAuthnCredentialAdmin",
25
+ ]
@@ -0,0 +1,92 @@
1
+ """Read-only admin of the security records (codes, devices, passkeys).
2
+
3
+ Secrets never show: codes and tokens are hashes, the TOTP secret is
4
+ encrypted. Deleting a TOTP device is the way out for a user who lost both
5
+ the phone and the recovery codes: the login falls back to e-mail codes.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from typing import Any
11
+
12
+ from django.contrib import admin
13
+ from django.http import HttpRequest
14
+
15
+ from ..models import (
16
+ EmailCode,
17
+ Invitation,
18
+ RecoveryCode,
19
+ TotpDevice,
20
+ TrustedDevice,
21
+ WebAuthnCredential,
22
+ )
23
+
24
+
25
+ class ReadOnlyAdmin(admin.ModelAdmin):
26
+ """No add and no change; deletion stays available."""
27
+
28
+ def has_add_permission(self, request: HttpRequest) -> bool:
29
+ """Refuse: records are created by the account flows only."""
30
+ return False
31
+
32
+ def has_change_permission(self, request: HttpRequest, obj: Any = None) -> bool:
33
+ """Refuse: records are never edited by hand."""
34
+ return False
35
+
36
+
37
+ @admin.register(EmailCode)
38
+ class EmailCodeAdmin(ReadOnlyAdmin):
39
+ """E-mail codes (hash only)."""
40
+
41
+ list_display = ("user", "purpose", "expires_at", "attempts", "consumed_at")
42
+ list_filter = ("purpose",)
43
+ search_fields = ("user__email",)
44
+ exclude = ("code_hash",)
45
+
46
+
47
+ @admin.register(RecoveryCode)
48
+ class RecoveryCodeAdmin(ReadOnlyAdmin):
49
+ """Recovery codes; the plain text never exists after generation."""
50
+
51
+ list_display = ("prefix", "user", "label", "created_at", "used_at")
52
+ list_filter = ("used_at",)
53
+ search_fields = ("user__email", "prefix", "label")
54
+ exclude = ("code_hash",)
55
+
56
+
57
+ @admin.register(WebAuthnCredential)
58
+ class WebAuthnCredentialAdmin(ReadOnlyAdmin):
59
+ """Passkeys."""
60
+
61
+ list_display = ("name", "user", "sign_count", "created_at", "last_used_at")
62
+ search_fields = ("user__email", "name", "credential_id")
63
+
64
+
65
+ @admin.register(TotpDevice)
66
+ class TotpDeviceAdmin(ReadOnlyAdmin):
67
+ """Authenticator apps (the encrypted secret is hidden)."""
68
+
69
+ list_display = ("user", "confirmed_at", "created_at", "last_used_at")
70
+ list_filter = ("confirmed_at",)
71
+ search_fields = ("user__email",)
72
+ exclude = ("secret_encrypted",)
73
+
74
+
75
+ @admin.register(TrustedDevice)
76
+ class TrustedDeviceAdmin(ReadOnlyAdmin):
77
+ """Trusted devices (the token hash is hidden)."""
78
+
79
+ list_display = ("user", "device_label", "ip_address", "expires_at", "is_active")
80
+ list_filter = ("is_active",)
81
+ search_fields = ("user__email", "device_label")
82
+ exclude = ("token_hash",)
83
+
84
+
85
+ @admin.register(Invitation)
86
+ class InvitationAdmin(ReadOnlyAdmin):
87
+ """Invitations (the token hash is hidden)."""
88
+
89
+ list_display = ("email", "role", "invited_by", "expires_at", "accepted_at")
90
+ list_filter = ("role",)
91
+ search_fields = ("email",)
92
+ exclude = ("token_hash",)
@@ -0,0 +1,33 @@
1
+ """Base ``ModelAdmin`` for projects to register their concrete user with."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from django.contrib.auth.admin import UserAdmin
6
+ from django.utils.translation import gettext_lazy as _
7
+
8
+
9
+ class TripaulxUserAdmin(UserAdmin):
10
+ """User admin keyed by e-mail, with role and security flags.
11
+
12
+ Projects register it explicitly: ``admin.site.register(User,
13
+ TripaulxUserAdmin)``.
14
+ """
15
+
16
+ ordering = ("email",)
17
+ list_display = ("email", "role", "is_active", "email_verified", "is_staff")
18
+ list_filter = ("role", "is_active", "email_verified", "is_staff")
19
+ search_fields = ("email", "first_name", "last_name")
20
+ fieldsets = (
21
+ (None, {"fields": ("email", "password")}),
22
+ (_("Personal info"), {"fields": ("first_name", "last_name")}),
23
+ (_("Workspace"), {"fields": ("role",)}),
24
+ (_("Security"), {"fields": ("email_verified", "password_login_disabled")}),
25
+ (
26
+ _("Permissions"),
27
+ {"fields": ("is_active", "is_staff", "is_superuser", "groups")},
28
+ ),
29
+ (_("Important dates"), {"fields": ("last_login", "date_joined")}),
30
+ )
31
+ add_fieldsets = (
32
+ (None, {"classes": ("wide",), "fields": ("email", "password1", "password2")}),
33
+ )
@@ -0,0 +1 @@
1
+ """REST API of the accounts app."""
@@ -0,0 +1,27 @@
1
+ """DRF authentication: SimpleJWT plus the workspace (schema) check.
2
+
3
+ Use it instead of the plain ``JWTAuthentication`` in
4
+ ``DEFAULT_AUTHENTICATION_CLASSES`` (``tripaulx.settings.rest`` does). Why:
5
+ see :mod:`tripaulx.accounts.services.tokens`.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from rest_framework_simplejwt.authentication import JWTAuthentication
11
+ from rest_framework_simplejwt.tokens import Token
12
+
13
+ from ..services.tokens import check_schema
14
+
15
+
16
+ class TenantJWTAuthentication(JWTAuthentication):
17
+ """Accept only tokens issued in the current workspace schema.
18
+
19
+ The check runs in ``get_validated_token`` (not ``get_user``) so a foreign
20
+ token dies before any query hits this schema.
21
+ """
22
+
23
+ def get_validated_token(self, raw_token: bytes) -> Token:
24
+ """Validate the signature, then the schema claim."""
25
+ token = super().get_validated_token(raw_token)
26
+ check_schema(token)
27
+ return token
@@ -0,0 +1,21 @@
1
+ """DRF permissions based on the workspace role."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ from rest_framework.permissions import BasePermission
8
+ from rest_framework.request import Request
9
+
10
+
11
+ class IsWorkspaceAdmin(BasePermission):
12
+ """Allow active owners and admins of the current workspace."""
13
+
14
+ def has_permission(self, request: Request, view: Any) -> bool:
15
+ """Check ``user.is_workspace_admin``."""
16
+ user = request.user
17
+ return bool(
18
+ user
19
+ and user.is_authenticated
20
+ and getattr(user, "is_workspace_admin", False)
21
+ )
@@ -0,0 +1,22 @@
1
+ """OpenAPI (drf-spectacular) glue for the accounts API.
2
+
3
+ Imported by ``AccountsConfig.ready`` so the authentication extension is
4
+ registered before any schema is generated.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from drf_spectacular.contrib.rest_framework_simplejwt import SimpleJWTScheme
10
+ from drf_spectacular.types import OpenApiTypes
11
+ from drf_spectacular.utils import extend_schema
12
+
13
+
14
+ class TenantJWTScheme(SimpleJWTScheme):
15
+ """Describe ``TenantJWTAuthentication`` as a plain bearer JWT."""
16
+
17
+ target_class = "tripaulx.accounts.api.authentication.TenantJWTAuthentication"
18
+ name = "jwtAuth"
19
+
20
+
21
+ #: For views without a request serializer that answer free-form JSON.
22
+ untyped = extend_schema(request=None, responses=OpenApiTypes.OBJECT)
@@ -0,0 +1,55 @@
1
+ """Serializers of the accounts API."""
2
+
3
+ from .auth import (
4
+ CodeSerializer,
5
+ EmailCodeSerializer,
6
+ EmailSerializer,
7
+ LoginSerializer,
8
+ LoginVerifySerializer,
9
+ PasswordChangeSerializer,
10
+ PasswordResetConfirmSerializer,
11
+ RecoveryCodesSerializer,
12
+ RefreshSerializer,
13
+ TicketSerializer,
14
+ )
15
+ from .devices import (
16
+ PasskeyLoginBeginSerializer,
17
+ PasskeyLoginCompleteSerializer,
18
+ PasskeyRegisterSerializer,
19
+ PasskeySerializer,
20
+ PasswordLoginToggleSerializer,
21
+ TrustedDeviceSerializer,
22
+ )
23
+ from .user import MemberRoleSerializer, MemberSerializer, UserSerializer
24
+ from .workspace import (
25
+ InvitationAcceptSerializer,
26
+ InvitationCreateSerializer,
27
+ InvitationSerializer,
28
+ SignupSerializer,
29
+ )
30
+
31
+ __all__ = [
32
+ "CodeSerializer",
33
+ "EmailCodeSerializer",
34
+ "EmailSerializer",
35
+ "InvitationAcceptSerializer",
36
+ "InvitationCreateSerializer",
37
+ "InvitationSerializer",
38
+ "LoginSerializer",
39
+ "LoginVerifySerializer",
40
+ "MemberRoleSerializer",
41
+ "MemberSerializer",
42
+ "PasskeyLoginBeginSerializer",
43
+ "PasskeyLoginCompleteSerializer",
44
+ "PasskeyRegisterSerializer",
45
+ "PasskeySerializer",
46
+ "PasswordChangeSerializer",
47
+ "PasswordLoginToggleSerializer",
48
+ "PasswordResetConfirmSerializer",
49
+ "RecoveryCodesSerializer",
50
+ "RefreshSerializer",
51
+ "SignupSerializer",
52
+ "TicketSerializer",
53
+ "TrustedDeviceSerializer",
54
+ "UserSerializer",
55
+ ]
@@ -0,0 +1,82 @@
1
+ """Input serializers of login, codes and passwords.
2
+
3
+ Password strength is checked by the services (one rule, one place), so the
4
+ serializers only check shapes.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from rest_framework import serializers
10
+
11
+
12
+ class EmailSerializer(serializers.Serializer):
13
+ """Just an e-mail address."""
14
+
15
+ email = serializers.EmailField()
16
+
17
+
18
+ class EmailCodeSerializer(serializers.Serializer):
19
+ """An e-mail address and the code sent to it."""
20
+
21
+ email = serializers.EmailField()
22
+ code = serializers.CharField(min_length=4, max_length=12)
23
+
24
+
25
+ class LoginSerializer(serializers.Serializer):
26
+ """E-mail, password and an optional trusted-device token."""
27
+
28
+ email = serializers.EmailField()
29
+ password = serializers.CharField(write_only=True, trim_whitespace=False)
30
+ device_token = serializers.CharField(required=False, allow_blank=True, default="")
31
+
32
+
33
+ class LoginVerifySerializer(serializers.Serializer):
34
+ """Second factor: app or e-mail code, or a recovery code (longer)."""
35
+
36
+ ticket = serializers.CharField()
37
+ code = serializers.CharField(min_length=4, max_length=24)
38
+ trust_device = serializers.BooleanField(required=False, default=False)
39
+ device_label = serializers.CharField(
40
+ required=False, allow_blank=True, default="", max_length=120
41
+ )
42
+
43
+
44
+ class TicketSerializer(serializers.Serializer):
45
+ """The login ticket alone (resend)."""
46
+
47
+ ticket = serializers.CharField(required=False, allow_blank=True, default="")
48
+
49
+
50
+ class CodeSerializer(serializers.Serializer):
51
+ """An authenticator code or, where accepted, a recovery code."""
52
+
53
+ code = serializers.CharField(min_length=4, max_length=24)
54
+
55
+
56
+ class RecoveryCodesSerializer(serializers.Serializer):
57
+ """How many recovery codes to generate."""
58
+
59
+ quantity = serializers.IntegerField(
60
+ required=False, default=None, min_value=1, max_value=20
61
+ )
62
+
63
+
64
+ class PasswordResetConfirmSerializer(serializers.Serializer):
65
+ """E-mail, reset code and the new password."""
66
+
67
+ email = serializers.EmailField()
68
+ code = serializers.CharField(min_length=4, max_length=12)
69
+ password = serializers.CharField(write_only=True, trim_whitespace=False)
70
+
71
+
72
+ class PasswordChangeSerializer(serializers.Serializer):
73
+ """Current and new password of the logged-in user."""
74
+
75
+ current_password = serializers.CharField(write_only=True, trim_whitespace=False)
76
+ new_password = serializers.CharField(write_only=True, trim_whitespace=False)
77
+
78
+
79
+ class RefreshSerializer(serializers.Serializer):
80
+ """A refresh token (logout)."""
81
+
82
+ refresh = serializers.CharField(required=False, allow_blank=True, default="")
@@ -0,0 +1,64 @@
1
+ """Serializers of passkeys and trusted devices."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from rest_framework import serializers
6
+
7
+ from ...models import TrustedDevice, WebAuthnCredential
8
+
9
+
10
+ class PasskeySerializer(serializers.ModelSerializer):
11
+ """A passkey as listed to its owner; ``name`` is the only editable field."""
12
+
13
+ class Meta:
14
+ model = WebAuthnCredential
15
+ fields = ["id", "name", "created_at", "last_used_at"]
16
+ read_only_fields = ["id", "created_at", "last_used_at"]
17
+
18
+
19
+ DEFAULT_PASSKEY_NAME = "Passkey"
20
+
21
+
22
+ class PasskeyRegisterSerializer(serializers.Serializer):
23
+ """The browser's registration response and a name for the passkey."""
24
+
25
+ credential = serializers.JSONField()
26
+ name = serializers.CharField(
27
+ required=False, allow_blank=True, default=DEFAULT_PASSKEY_NAME, max_length=120
28
+ )
29
+
30
+
31
+ class PasswordLoginToggleSerializer(serializers.Serializer):
32
+ """``disabled=True`` closes e-mail and password login."""
33
+
34
+ disabled = serializers.BooleanField()
35
+
36
+
37
+ class PasskeyLoginBeginSerializer(serializers.Serializer):
38
+ """Optional e-mail; without it any passkey of the workspace may answer."""
39
+
40
+ email = serializers.EmailField(required=False, allow_blank=True, default="")
41
+
42
+
43
+ class PasskeyLoginCompleteSerializer(serializers.Serializer):
44
+ """The ticket from "begin" and the browser's assertion."""
45
+
46
+ ticket = serializers.CharField()
47
+ credential = serializers.JSONField()
48
+
49
+
50
+ class TrustedDeviceSerializer(serializers.ModelSerializer):
51
+ """A trusted device as listed to its owner (never the token)."""
52
+
53
+ class Meta:
54
+ model = TrustedDevice
55
+ fields = [
56
+ "id",
57
+ "device_label",
58
+ "ip_address",
59
+ "user_agent",
60
+ "created_at",
61
+ "last_used_at",
62
+ "expires_at",
63
+ ]
64
+ read_only_fields = fields