@djangocfg/api 2.1.327 → 2.1.332

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 (174) hide show
  1. package/dist/auth-server.cjs +328 -3553
  2. package/dist/auth-server.cjs.map +1 -1
  3. package/dist/auth-server.mjs +328 -3553
  4. package/dist/auth-server.mjs.map +1 -1
  5. package/dist/auth.cjs +744 -3036
  6. package/dist/auth.cjs.map +1 -1
  7. package/dist/auth.d.cts +35 -35
  8. package/dist/auth.d.ts +35 -35
  9. package/dist/auth.mjs +744 -3036
  10. package/dist/auth.mjs.map +1 -1
  11. package/dist/clients.cjs +303 -3548
  12. package/dist/clients.cjs.map +1 -1
  13. package/dist/clients.d.cts +28 -2557
  14. package/dist/clients.d.ts +28 -2557
  15. package/dist/clients.mjs +303 -3548
  16. package/dist/clients.mjs.map +1 -1
  17. package/dist/index.cjs +1130 -3099
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +1807 -2165
  20. package/dist/index.d.ts +1807 -2165
  21. package/dist/index.mjs +1130 -3099
  22. package/dist/index.mjs.map +1 -1
  23. package/package.json +2 -2
  24. package/src/_api/generated/_cfg_accounts/api.ts +67 -0
  25. package/src/_api/generated/{cfg_totp → _cfg_accounts}/events.ts +3 -3
  26. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/index.ts +1 -1
  27. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthConnectionsList.ts +5 -6
  28. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthDisconnectCreate.ts +3 -3
  29. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthGithubAuthorizeCreate.ts +3 -3
  30. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthGithubCallbackCreate.ts +3 -3
  31. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthProvidersRetrieve.ts +5 -6
  32. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOtpRequestCreate.ts +3 -3
  33. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOtpVerifyCreate.ts +3 -3
  34. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileAvatarCreate.ts +3 -3
  35. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileDeleteCreate.ts +3 -3
  36. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfilePartialPartialUpdate.ts +3 -3
  37. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfilePartialUpdate.ts +3 -3
  38. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileRetrieve.ts +5 -6
  39. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileUpdatePartialUpdate.ts +3 -3
  40. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileUpdateUpdate.ts +3 -3
  41. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsTokenRefreshCreate.ts +3 -3
  42. package/src/_api/generated/{cfg_centrifugo → _cfg_accounts}/index.ts +6 -6
  43. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/AccountDeleteResponse.ts +3 -3
  44. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/CentrifugoToken.ts +4 -4
  45. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/CfgUserUpdateRequest.ts +4 -4
  46. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthAuthorizeRequestRequest.ts +2 -2
  47. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthAuthorizeResponse.ts +2 -2
  48. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthCallbackRequestRequest.ts +3 -3
  49. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthConnection.ts +6 -6
  50. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthDisconnectRequestRequest.ts +2 -2
  51. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthError.ts +2 -2
  52. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthProvidersResponse.ts +3 -3
  53. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthTokenResponse.ts +7 -7
  54. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPErrorResponse.ts +2 -2
  55. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPRequestRequest.ts +2 -2
  56. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPRequestResponse.ts +2 -2
  57. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPVerifyRequest.ts +2 -2
  58. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPVerifyResponse.ts +6 -6
  59. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/PatchedCfgUserUpdateRequest.ts +4 -4
  60. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/ProviderEnum.ts +2 -2
  61. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/TokenRefresh.ts +2 -2
  62. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/TokenRefreshRequest.ts +2 -2
  63. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/User.ts +13 -13
  64. package/src/_api/generated/_cfg_accounts/sdk.gen.ts +5 -0
  65. package/src/_api/generated/_cfg_accounts/types.gen.ts +5 -0
  66. package/src/_api/generated/_cfg_centrifugo/api.ts +67 -0
  67. package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/events.ts +3 -3
  68. package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/hooks/index.ts +1 -1
  69. package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/hooks/useCfgCentrifugoAuthTokenRetrieve.ts +5 -6
  70. package/src/_api/generated/{cfg_accounts → _cfg_centrifugo}/index.ts +6 -6
  71. package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/schemas/ConnectionTokenResponse.ts +4 -4
  72. package/src/_api/generated/_cfg_centrifugo/sdk.gen.ts +5 -0
  73. package/src/_api/generated/_cfg_centrifugo/types.gen.ts +5 -0
  74. package/src/_api/generated/_cfg_totp/api.ts +67 -0
  75. package/src/_api/generated/{cfg_accounts → _cfg_totp}/events.ts +3 -3
  76. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/index.ts +1 -1
  77. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpBackupCodesRegenerateCreate.ts +3 -3
  78. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpBackupCodesRetrieve.ts +5 -6
  79. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpDevicesDestroy.ts +3 -3
  80. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpDevicesRetrieve.ts +5 -6
  81. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpDisableCreate.ts +3 -3
  82. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpSetupConfirmCreate.ts +3 -3
  83. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpSetupCreate.ts +3 -3
  84. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpVerifyBackupCreate.ts +3 -3
  85. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpVerifyCreate.ts +3 -3
  86. package/src/_api/generated/{cfg_totp → _cfg_totp}/index.ts +6 -6
  87. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/BackupCodesRegenerateRequest.ts +2 -2
  88. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/BackupCodesRegenerateResponse.ts +2 -2
  89. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/BackupCodesStatus.ts +2 -2
  90. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/ConfirmSetupRequest.ts +3 -3
  91. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/ConfirmSetupResponse.ts +3 -3
  92. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/DeviceList.ts +6 -6
  93. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/DeviceListResponse.ts +2 -2
  94. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/DeviceListStatusEnum.ts +2 -2
  95. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/DisableRequest.ts +2 -2
  96. package/src/_api/generated/_cfg_totp/schemas/SetupRequest.ts +11 -0
  97. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/SetupResponse.ts +4 -4
  98. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/TotpVerifyUser.ts +12 -12
  99. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/VerifyBackupRequest.ts +3 -3
  100. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/VerifyRequest.ts +3 -3
  101. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/VerifyResponse.ts +4 -4
  102. package/src/_api/generated/_cfg_totp/sdk.gen.ts +5 -0
  103. package/src/_api/generated/_cfg_totp/types.gen.ts +5 -0
  104. package/src/_api/generated/{cfg_centrifugo/client.gen.ts → client.gen.ts} +3 -0
  105. package/src/_api/generated/helpers/auth.ts +223 -0
  106. package/src/_api/generated/{_shared → helpers}/index.ts +1 -0
  107. package/src/_api/generated/index.ts +22 -20
  108. package/src/_api/generated/{cfg_accounts/sdk.gen.ts → sdk.gen.ts} +455 -1
  109. package/src/_api/generated/{cfg_accounts/types.gen.ts → types.gen.ts} +607 -77
  110. package/src/auth/context/AccountsContext.tsx +10 -10
  111. package/src/auth/context/AuthContext.tsx +1 -1
  112. package/src/auth/hooks/useDeleteAccount.ts +2 -1
  113. package/src/auth/hooks/useGithubAuth.ts +3 -2
  114. package/src/auth/hooks/useTokenRefresh.ts +2 -1
  115. package/src/auth/hooks/useTwoFactor.ts +4 -3
  116. package/src/auth/hooks/useTwoFactorSetup.ts +3 -2
  117. package/src/auth/hooks/useTwoFactorStatus.ts +4 -3
  118. package/src/auth/middlewares/tokenRefresh.ts +2 -1
  119. package/src/clients.ts +3 -3
  120. package/src/index.ts +22 -5
  121. package/src/server.ts +9 -9
  122. package/src/_api/generated/cfg_accounts/api.ts +0 -187
  123. package/src/_api/generated/cfg_accounts/client.gen.ts +0 -16
  124. package/src/_api/generated/cfg_centrifugo/api.ts +0 -164
  125. package/src/_api/generated/cfg_centrifugo/client/client.gen.ts +0 -280
  126. package/src/_api/generated/cfg_centrifugo/client/index.ts +0 -25
  127. package/src/_api/generated/cfg_centrifugo/client/types.gen.ts +0 -217
  128. package/src/_api/generated/cfg_centrifugo/client/utils.gen.ts +0 -318
  129. package/src/_api/generated/cfg_centrifugo/core/auth.gen.ts +0 -41
  130. package/src/_api/generated/cfg_centrifugo/core/bodySerializer.gen.ts +0 -82
  131. package/src/_api/generated/cfg_centrifugo/core/params.gen.ts +0 -169
  132. package/src/_api/generated/cfg_centrifugo/core/pathSerializer.gen.ts +0 -171
  133. package/src/_api/generated/cfg_centrifugo/core/queryKeySerializer.gen.ts +0 -117
  134. package/src/_api/generated/cfg_centrifugo/core/serverSentEvents.gen.ts +0 -242
  135. package/src/_api/generated/cfg_centrifugo/core/types.gen.ts +0 -104
  136. package/src/_api/generated/cfg_centrifugo/core/utils.gen.ts +0 -140
  137. package/src/_api/generated/cfg_centrifugo/sdk.gen.ts +0 -64
  138. package/src/_api/generated/cfg_centrifugo/types.gen.ts +0 -61
  139. package/src/_api/generated/cfg_totp/api.ts +0 -181
  140. package/src/_api/generated/cfg_totp/client/client.gen.ts +0 -280
  141. package/src/_api/generated/cfg_totp/client/index.ts +0 -25
  142. package/src/_api/generated/cfg_totp/client/types.gen.ts +0 -217
  143. package/src/_api/generated/cfg_totp/client/utils.gen.ts +0 -318
  144. package/src/_api/generated/cfg_totp/client.gen.ts +0 -16
  145. package/src/_api/generated/cfg_totp/core/auth.gen.ts +0 -41
  146. package/src/_api/generated/cfg_totp/core/bodySerializer.gen.ts +0 -82
  147. package/src/_api/generated/cfg_totp/core/params.gen.ts +0 -169
  148. package/src/_api/generated/cfg_totp/core/pathSerializer.gen.ts +0 -171
  149. package/src/_api/generated/cfg_totp/core/queryKeySerializer.gen.ts +0 -117
  150. package/src/_api/generated/cfg_totp/core/serverSentEvents.gen.ts +0 -242
  151. package/src/_api/generated/cfg_totp/core/types.gen.ts +0 -104
  152. package/src/_api/generated/cfg_totp/core/utils.gen.ts +0 -140
  153. package/src/_api/generated/cfg_totp/schemas/SetupRequest.ts +0 -11
  154. package/src/_api/generated/cfg_totp/sdk.gen.ts +0 -432
  155. package/src/_api/generated/cfg_totp/types.gen.ts +0 -479
  156. /package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/index.ts +0 -0
  157. /package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/schemas/index.ts +0 -0
  158. /package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/index.ts +0 -0
  159. /package/src/_api/generated/{cfg_accounts/client → client}/client.gen.ts +0 -0
  160. /package/src/_api/generated/{cfg_accounts/client → client}/index.ts +0 -0
  161. /package/src/_api/generated/{cfg_accounts/client → client}/types.gen.ts +0 -0
  162. /package/src/_api/generated/{cfg_accounts/client → client}/utils.gen.ts +0 -0
  163. /package/src/_api/generated/{cfg_accounts/core → core}/auth.gen.ts +0 -0
  164. /package/src/_api/generated/{cfg_accounts/core → core}/bodySerializer.gen.ts +0 -0
  165. /package/src/_api/generated/{cfg_accounts/core → core}/params.gen.ts +0 -0
  166. /package/src/_api/generated/{cfg_accounts/core → core}/pathSerializer.gen.ts +0 -0
  167. /package/src/_api/generated/{cfg_accounts/core → core}/queryKeySerializer.gen.ts +0 -0
  168. /package/src/_api/generated/{cfg_accounts/core → core}/serverSentEvents.gen.ts +0 -0
  169. /package/src/_api/generated/{cfg_accounts/core → core}/types.gen.ts +0 -0
  170. /package/src/_api/generated/{cfg_accounts/core → core}/utils.gen.ts +0 -0
  171. /package/src/_api/generated/{_shared → helpers}/errors.ts +0 -0
  172. /package/src/_api/generated/{_shared → helpers}/logger.ts +0 -0
  173. /package/src/_api/generated/{_shared → helpers}/storage.ts +0 -0
  174. /package/src/_api/generated/{_shared → helpers}/validation-events.ts +0 -0
@@ -1,6 +1,6 @@
1
- // AUTO-GENERATED by django-cfg / django_generator.ts_extras
1
+ // AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
2
2
  // Source: OpenAPI 3.1 components.schemas
3
- // DO NOT EDIT — re-run `make gen`.
3
+ // DO NOT EDIT — re-run `make gen-clients`.
4
4
 
5
5
  import { z } from "zod";
6
6
 
@@ -1,6 +1,6 @@
1
- // AUTO-GENERATED by django-cfg / django_generator.ts_extras
1
+ // AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
2
2
  // Source: OpenAPI 3.1 components.schemas
3
- // DO NOT EDIT — re-run `make gen`.
3
+ // DO NOT EDIT — re-run `make gen-clients`.
4
4
 
5
5
  import { z } from "zod";
6
6
 
@@ -1,12 +1,12 @@
1
- // AUTO-GENERATED by django-cfg / django_generator.ts_extras
1
+ // AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
2
2
  // Source: OpenAPI 3.1 components.schemas
3
- // DO NOT EDIT — re-run `make gen`.
3
+ // DO NOT EDIT — re-run `make gen-clients`.
4
4
 
5
5
  import { z } from "zod";
6
6
 
7
7
  export const ConfirmSetupRequestSchema = z.object({
8
- device_id: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
9
8
  code: z.string().min(6).max(6),
9
+ device_id: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
10
10
  });
11
11
 
12
12
  export type ConfirmSetupRequest = z.infer<typeof ConfirmSetupRequestSchema>;
@@ -1,13 +1,13 @@
1
- // AUTO-GENERATED by django-cfg / django_generator.ts_extras
1
+ // AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
2
2
  // Source: OpenAPI 3.1 components.schemas
3
- // DO NOT EDIT — re-run `make gen`.
3
+ // DO NOT EDIT — re-run `make gen-clients`.
4
4
 
5
5
  import { z } from "zod";
6
6
 
7
7
  export const ConfirmSetupResponseSchema = z.object({
8
- message: z.string(),
9
8
  backup_codes: z.array(z.string()),
10
9
  backup_codes_warning: z.string(),
10
+ message: z.string(),
11
11
  });
12
12
 
13
13
  export type ConfirmSetupResponse = z.infer<typeof ConfirmSetupResponseSchema>;
@@ -1,18 +1,18 @@
1
- // AUTO-GENERATED by django-cfg / django_generator.ts_extras
1
+ // AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
2
2
  // Source: OpenAPI 3.1 components.schemas
3
- // DO NOT EDIT — re-run `make gen`.
3
+ // DO NOT EDIT — re-run `make gen-clients`.
4
4
 
5
5
  import { z } from "zod";
6
6
  import { DeviceListStatusEnumSchema } from "./DeviceListStatusEnum";
7
7
 
8
8
  export const DeviceListSchema = z.object({
9
+ confirmed_at: z.string().datetime({ offset: true }).nullable(),
10
+ created_at: z.string().datetime({ offset: true }),
9
11
  id: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
10
- name: z.string(),
11
12
  is_primary: z.boolean(),
12
- status: DeviceListStatusEnumSchema,
13
- created_at: z.string().datetime({ offset: true }),
14
- confirmed_at: z.string().datetime({ offset: true }).nullable(),
15
13
  last_used_at: z.string().datetime({ offset: true }).nullable(),
14
+ name: z.string(),
15
+ status: DeviceListStatusEnumSchema,
16
16
  });
17
17
 
18
18
  export type DeviceList = z.infer<typeof DeviceListSchema>;
@@ -1,6 +1,6 @@
1
- // AUTO-GENERATED by django-cfg / django_generator.ts_extras
1
+ // AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
2
2
  // Source: OpenAPI 3.1 components.schemas
3
- // DO NOT EDIT — re-run `make gen`.
3
+ // DO NOT EDIT — re-run `make gen-clients`.
4
4
 
5
5
  import { z } from "zod";
6
6
  import { DeviceListSchema } from "./DeviceList";
@@ -1,6 +1,6 @@
1
- // AUTO-GENERATED by django-cfg / django_generator.ts_extras
1
+ // AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
2
2
  // Source: OpenAPI 3.1 components.schemas
3
- // DO NOT EDIT — re-run `make gen`.
3
+ // DO NOT EDIT — re-run `make gen-clients`.
4
4
 
5
5
  import { z } from "zod";
6
6
 
@@ -1,6 +1,6 @@
1
- // AUTO-GENERATED by django-cfg / django_generator.ts_extras
1
+ // AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
2
2
  // Source: OpenAPI 3.1 components.schemas
3
- // DO NOT EDIT — re-run `make gen`.
3
+ // DO NOT EDIT — re-run `make gen-clients`.
4
4
 
5
5
  import { z } from "zod";
6
6
 
@@ -0,0 +1,11 @@
1
+ // AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
2
+ // Source: OpenAPI 3.1 components.schemas
3
+ // DO NOT EDIT — re-run `make gen-clients`.
4
+
5
+ import { z } from "zod";
6
+
7
+ export const SetupRequestSchema = z.object({
8
+ device_name: z.string().min(1).max(100).default("Authenticator").optional(),
9
+ });
10
+
11
+ export type SetupRequest = z.infer<typeof SetupRequestSchema>;
@@ -1,15 +1,15 @@
1
- // AUTO-GENERATED by django-cfg / django_generator.ts_extras
1
+ // AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
2
2
  // Source: OpenAPI 3.1 components.schemas
3
- // DO NOT EDIT — re-run `make gen`.
3
+ // DO NOT EDIT — re-run `make gen-clients`.
4
4
 
5
5
  import { z } from "zod";
6
6
 
7
7
  export const SetupResponseSchema = z.object({
8
8
  device_id: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
9
- secret: z.string(),
9
+ expires_in: z.number().int(),
10
10
  provisioning_uri: z.string(),
11
11
  qr_code_base64: z.string(),
12
- expires_in: z.number().int(),
12
+ secret: z.string(),
13
13
  });
14
14
 
15
15
  export type SetupResponse = z.infer<typeof SetupResponseSchema>;
@@ -1,27 +1,27 @@
1
- // AUTO-GENERATED by django-cfg / django_generator.ts_extras
1
+ // AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
2
2
  // Source: OpenAPI 3.1 components.schemas
3
- // DO NOT EDIT — re-run `make gen`.
3
+ // DO NOT EDIT — re-run `make gen-clients`.
4
4
 
5
5
  import { z } from "zod";
6
6
 
7
7
  export const TotpVerifyUserSchema = z.object({
8
- id: z.number().int(),
8
+ avatar: z.string().nullable(),
9
+ company: z.string().max(100).optional(),
10
+ date_joined: z.string().datetime({ offset: true }),
11
+ display_username: z.string(),
9
12
  email: z.email(),
10
13
  first_name: z.string().max(50).optional(),
11
- last_name: z.string().max(50).optional(),
12
14
  full_name: z.string(),
15
+ id: z.number().int(),
13
16
  initials: z.string(),
14
- display_username: z.string(),
15
- company: z.string().max(100).optional(),
16
- phone: z.string().max(20).optional(),
17
- position: z.string().max(100).optional(),
18
- language: z.string().max(10).optional(),
19
- avatar: z.string().nullable(),
20
17
  is_staff: z.boolean(),
21
18
  is_superuser: z.boolean(),
22
- date_joined: z.string().datetime({ offset: true }),
19
+ language: z.string().max(10).optional(),
23
20
  last_login: z.string().datetime({ offset: true }).nullable(),
24
- unanswered_messages_count: z.number().int(),
21
+ last_name: z.string().max(50).optional(),
22
+ phone: z.string().max(20).optional(),
23
+ position: z.string().max(100).optional(),
24
+ unanswered_messages_count: z.number().int().default(0),
25
25
  });
26
26
 
27
27
  export type TotpVerifyUser = z.infer<typeof TotpVerifyUserSchema>;
@@ -1,12 +1,12 @@
1
- // AUTO-GENERATED by django-cfg / django_generator.ts_extras
1
+ // AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
2
2
  // Source: OpenAPI 3.1 components.schemas
3
- // DO NOT EDIT — re-run `make gen`.
3
+ // DO NOT EDIT — re-run `make gen-clients`.
4
4
 
5
5
  import { z } from "zod";
6
6
 
7
7
  export const VerifyBackupRequestSchema = z.object({
8
- session_id: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
9
8
  backup_code: z.string().min(8).max(8),
9
+ session_id: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
10
10
  });
11
11
 
12
12
  export type VerifyBackupRequest = z.infer<typeof VerifyBackupRequestSchema>;
@@ -1,12 +1,12 @@
1
- // AUTO-GENERATED by django-cfg / django_generator.ts_extras
1
+ // AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
2
2
  // Source: OpenAPI 3.1 components.schemas
3
- // DO NOT EDIT — re-run `make gen`.
3
+ // DO NOT EDIT — re-run `make gen-clients`.
4
4
 
5
5
  import { z } from "zod";
6
6
 
7
7
  export const VerifyRequestSchema = z.object({
8
- session_id: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
9
8
  code: z.string().min(6).max(6),
9
+ session_id: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
10
10
  });
11
11
 
12
12
  export type VerifyRequest = z.infer<typeof VerifyRequestSchema>;
@@ -1,16 +1,16 @@
1
- // AUTO-GENERATED by django-cfg / django_generator.ts_extras
1
+ // AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
2
2
  // Source: OpenAPI 3.1 components.schemas
3
- // DO NOT EDIT — re-run `make gen`.
3
+ // DO NOT EDIT — re-run `make gen-clients`.
4
4
 
5
5
  import { z } from "zod";
6
6
  import { TotpVerifyUserSchema } from "./TotpVerifyUser";
7
7
 
8
8
  export const VerifyResponseSchema = z.object({
9
- message: z.string(),
10
9
  access_token: z.string(),
10
+ message: z.string(),
11
11
  refresh_token: z.string(),
12
- user: TotpVerifyUserSchema,
13
12
  remaining_backup_codes: z.number().int().optional(),
13
+ user: TotpVerifyUserSchema,
14
14
  warning: z.string().optional(),
15
15
  });
16
16
 
@@ -0,0 +1,5 @@
1
+ // AUTO-GENERATED by openapi_processor / ts.tool
2
+ // Re-exports the top-level Hey API SDK so group-scoped imports work:
3
+ // import { Foo } from "@api/generated/_<group>/sdk.gen";
4
+ // DO NOT EDIT — re-run `make gen`.
5
+ export * from "../sdk.gen";
@@ -0,0 +1,5 @@
1
+ // AUTO-GENERATED by openapi_processor / ts.tool
2
+ // Re-exports the top-level Hey API types so group-scoped imports work:
3
+ // import type { Foo } from "@api/generated/_<group>/types.gen";
4
+ // DO NOT EDIT — re-run `make gen`.
5
+ export * from "../types.gen";
@@ -14,3 +14,6 @@ import type { ClientOptions as ClientOptions2 } from './types.gen';
14
14
  export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
15
15
 
16
16
  export const client = createClient(createConfig<ClientOptions2>({ baseUrl: 'http://localhost:8000' }));
17
+
18
+ // auto-init: load auth interceptor
19
+ import './helpers/auth';
@@ -0,0 +1,223 @@
1
+ // AUTO-GENERATED by django_generator / ts_extras.wrapper
2
+ // Global auth store. ONE source of truth for token / API key / locale /
3
+ // baseUrl. Installs the request interceptor as a side-effect on import.
4
+ // DO NOT EDIT — re-run `make gen`.
5
+
6
+ import { client } from '../client.gen';
7
+
8
+ const ACCESS_KEY = 'cfg.access_token';
9
+ const REFRESH_KEY = 'cfg.refresh_token';
10
+ const API_KEY_KEY = 'cfg.api_key';
11
+
12
+ const isBrowser = typeof window !== 'undefined';
13
+
14
+ export type StorageMode = 'localStorage' | 'cookie';
15
+
16
+ // ── Storage backends (browser-only; server-side reads return null) ─────────
17
+
18
+ interface KVStore {
19
+ get(key: string): string | null;
20
+ set(key: string, value: string | null): void;
21
+ }
22
+
23
+ const localStorageBackend: KVStore = {
24
+ get(key) {
25
+ if (!isBrowser) return null;
26
+ try { return window.localStorage.getItem(key); } catch { return null; }
27
+ },
28
+ set(key, value) {
29
+ if (!isBrowser) return;
30
+ try {
31
+ if (value === null) window.localStorage.removeItem(key);
32
+ else window.localStorage.setItem(key, value);
33
+ } catch {}
34
+ },
35
+ };
36
+
37
+ /** 30 days, matches typical refresh-token lifetime. */
38
+ const COOKIE_MAX_AGE = 60 * 60 * 24 * 30;
39
+
40
+ const cookieBackend: KVStore = {
41
+ get(key) {
42
+ if (!isBrowser) return null;
43
+ try {
44
+ const re = new RegExp(`(?:^|;\\s*)${encodeURIComponent(key)}=([^;]*)`);
45
+ const m = document.cookie.match(re);
46
+ return m ? decodeURIComponent(m[1]) : null;
47
+ } catch { return null; }
48
+ },
49
+ set(key, value) {
50
+ if (!isBrowser) return;
51
+ try {
52
+ const k = encodeURIComponent(key);
53
+ const secure = window.location.protocol === 'https:' ? '; Secure' : '';
54
+ if (value === null) {
55
+ document.cookie = `${k}=; Path=/; Max-Age=0; SameSite=Lax${secure}`;
56
+ } else {
57
+ const v = encodeURIComponent(value);
58
+ document.cookie = `${k}=${v}; Path=/; Max-Age=${COOKIE_MAX_AGE}; SameSite=Lax${secure}`;
59
+ }
60
+ } catch {}
61
+ },
62
+ };
63
+
64
+ let _storage: KVStore = localStorageBackend;
65
+ let _storageMode: StorageMode = 'localStorage';
66
+
67
+ /** Detect locale from `NEXT_LOCALE` cookie or `navigator.language`. */
68
+ function detectLocale(): string | null {
69
+ try {
70
+ if (typeof document !== 'undefined') {
71
+ const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
72
+ if (m) return decodeURIComponent(m[1]);
73
+ }
74
+ if (typeof navigator !== 'undefined' && navigator.language) {
75
+ return navigator.language;
76
+ }
77
+ } catch {}
78
+ return null;
79
+ }
80
+
81
+ /** Default baseUrl from `NEXT_PUBLIC_API_URL` (empty for static builds). */
82
+ function defaultBaseUrl(): string {
83
+ try {
84
+ if (typeof process !== 'undefined' && process.env) {
85
+ if (process.env.NEXT_PUBLIC_STATIC_BUILD === 'true') return '';
86
+ return process.env.NEXT_PUBLIC_API_URL || '';
87
+ }
88
+ } catch {}
89
+ return '';
90
+ }
91
+
92
+ /** Default API key fallback from `NEXT_PUBLIC_API_KEY`. */
93
+ function defaultApiKey(): string | null {
94
+ try {
95
+ if (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_API_KEY) {
96
+ return process.env.NEXT_PUBLIC_API_KEY;
97
+ }
98
+ } catch {}
99
+ return null;
100
+ }
101
+
102
+ // ── In-memory overrides (win over storage / env) ───────────────────────────
103
+ let _localeOverride: string | null = null;
104
+ let _apiKeyOverride: string | null = null;
105
+ let _baseUrlOverride: string | null = null;
106
+ let _withCredentials = true;
107
+ let _onUnauthorized: ((response: Response) => void) | null = null;
108
+
109
+ /**
110
+ * Global auth/config store. All getters read live state every call —
111
+ * the interceptor below uses these to attach headers per-request.
112
+ *
113
+ * Default storage backend is `localStorage`. Switch to cookies (e.g.
114
+ * for Next.js SSR cookie access) via `auth.setStorageMode('cookie')`
115
+ * early in the app bootstrap.
116
+ *
117
+ * @example
118
+ * import { auth } from '@your/api';
119
+ *
120
+ * // After login
121
+ * auth.setToken(jwt);
122
+ * auth.setRefreshToken(refresh);
123
+ *
124
+ * // After logout
125
+ * auth.clearTokens();
126
+ *
127
+ * // Switch to cookie storage (call once during app init)
128
+ * auth.setStorageMode('cookie');
129
+ */
130
+ export const auth = {
131
+ // ── Storage mode ──────────────────────────────────────────────────
132
+ getStorageMode(): StorageMode { return _storageMode; },
133
+ /**
134
+ * Switch the storage backend. Existing values in the *previous*
135
+ * backend are NOT migrated — set fresh values after switching.
136
+ */
137
+ setStorageMode(mode: StorageMode): void {
138
+ _storageMode = mode;
139
+ _storage = mode === 'cookie' ? cookieBackend : localStorageBackend;
140
+ },
141
+
142
+ // ── Bearer token ──────────────────────────────────────────────────
143
+ getToken(): string | null { return _storage.get(ACCESS_KEY); },
144
+ setToken(token: string | null): void { _storage.set(ACCESS_KEY, token); },
145
+ getRefreshToken(): string | null { return _storage.get(REFRESH_KEY); },
146
+ setRefreshToken(token: string | null): void { _storage.set(REFRESH_KEY, token); },
147
+ clearTokens(): void { _storage.set(ACCESS_KEY, null); _storage.set(REFRESH_KEY, null); },
148
+ isAuthenticated(): boolean { return _storage.get(ACCESS_KEY) !== null; },
149
+
150
+ // ── API key ───────────────────────────────────────────────────────
151
+ /** In-memory API key. Falls back to storage, then NEXT_PUBLIC_API_KEY. */
152
+ getApiKey(): string | null {
153
+ return _apiKeyOverride ?? _storage.get(API_KEY_KEY) ?? defaultApiKey();
154
+ },
155
+ /** In-memory only (cleared on reload). */
156
+ setApiKey(key: string | null): void { _apiKeyOverride = key; },
157
+ /** Persist to active storage backend (localStorage or cookie). */
158
+ setApiKeyPersist(key: string | null): void {
159
+ _apiKeyOverride = key;
160
+ _storage.set(API_KEY_KEY, key);
161
+ },
162
+ clearApiKey(): void { _apiKeyOverride = null; _storage.set(API_KEY_KEY, null); },
163
+
164
+ // ── Locale ────────────────────────────────────────────────────────
165
+ /** Override locale → falls back to NEXT_LOCALE cookie / navigator.language. */
166
+ getLocale(): string | null { return _localeOverride ?? detectLocale(); },
167
+ setLocale(locale: string | null): void { _localeOverride = locale; },
168
+
169
+ // ── Base URL ──────────────────────────────────────────────────────
170
+ getBaseUrl(): string {
171
+ const url = (_baseUrlOverride ?? defaultBaseUrl());
172
+ return url.replace(/\/$/, '');
173
+ },
174
+ setBaseUrl(url: string | null): void {
175
+ _baseUrlOverride = url ? url.replace(/\/$/, '') : null;
176
+ client.setConfig({ baseUrl: this.getBaseUrl() });
177
+ },
178
+
179
+ // ── Credentials toggle (Django session/CSRF cross-origin) ─────────
180
+ getWithCredentials(): boolean { return _withCredentials; },
181
+ setWithCredentials(value: boolean): void {
182
+ _withCredentials = value;
183
+ client.setConfig({ credentials: value ? 'include' : 'same-origin' });
184
+ },
185
+
186
+ // ── 401 handler ───────────────────────────────────────────────────
187
+ /**
188
+ * Register a callback fired on every 401 response. Use this to wire
189
+ * a token-refresh flow or a forced logout. Setting `null` removes
190
+ * the handler.
191
+ */
192
+ onUnauthorized(cb: ((response: Response) => void) | null): void {
193
+ _onUnauthorized = cb;
194
+ },
195
+ };
196
+
197
+ // ── One-time client wiring (side-effect on first import) ───────────────────
198
+ client.setConfig({
199
+ baseUrl: auth.getBaseUrl(),
200
+ credentials: _withCredentials ? 'include' : 'same-origin',
201
+ });
202
+
203
+ client.interceptors.request.use((request) => {
204
+ const token = auth.getToken();
205
+ if (token) request.headers.set('Authorization', `Bearer ${token}`);
206
+
207
+ const locale = auth.getLocale();
208
+ if (locale) request.headers.set('Accept-Language', locale);
209
+
210
+ const apiKey = auth.getApiKey();
211
+ if (apiKey) request.headers.set('X-API-Key', apiKey);
212
+
213
+ return request;
214
+ });
215
+
216
+ client.interceptors.response.use((response) => {
217
+ if (response.status === 401 && _onUnauthorized) {
218
+ try { _onUnauthorized(response); } catch {}
219
+ }
220
+ return response;
221
+ });
222
+
223
+ export type Auth = typeof auth;
@@ -1,6 +1,7 @@
1
1
  // AUTO-GENERATED by django_generator / ts_extras.wrapper
2
2
  // Shared utilities barrel. DO NOT EDIT — re-run `make gen`.
3
3
 
4
+ export { auth, type Auth } from './auth';
4
5
  export {
5
6
  type StorageAdapter,
6
7
  LocalStorageAdapter,
@@ -1,30 +1,32 @@
1
1
  // AUTO-GENERATED by django_generator / ts_extras.wrapper
2
- // Top-level barrel — one singleton API per group, baseUrl from Next.js env.
2
+ // Top-level barrel — global `auth` + per-group facades.
3
3
  // DO NOT EDIT — re-run `make gen`.
4
4
 
5
- import { API as CfgAccountsAPI, LocalStorageAdapter as CfgAccountsStorage } from './cfg_accounts';
6
- import { API as CfgCentrifugoAPI, LocalStorageAdapter as CfgCentrifugoStorage } from './cfg_centrifugo';
7
- import { API as CfgTotpAPI, LocalStorageAdapter as CfgTotpStorage } from './cfg_totp';
5
+ // Side-effect: ensure auth interceptor is installed even if consumers
6
+ // only ever import this barrel (it'll also load via client.gen.ts).
7
+ import './helpers/auth';
8
8
 
9
- const isStaticBuild = process.env.NEXT_PUBLIC_STATIC_BUILD === 'true';
10
- const baseUrl = isStaticBuild ? '' : process.env.NEXT_PUBLIC_API_URL || '';
9
+ // Global auth/config store single source of truth.
10
+ export { auth, type Auth } from './helpers/auth';
11
11
 
12
- export const cfgAccountsApi = new CfgAccountsAPI(baseUrl, { storage: new CfgAccountsStorage() });
13
- export const cfgCentrifugoApi = new CfgCentrifugoAPI(baseUrl, { storage: new CfgCentrifugoStorage() });
14
- export const cfgTotpApi = new CfgTotpAPI(baseUrl, { storage: new CfgTotpStorage() });
12
+ import { API as CfgAccountsAPI } from './_cfg_accounts';
13
+ import { API as CfgCentrifugoAPI } from './_cfg_centrifugo';
14
+ import { API as CfgTotpAPI } from './_cfg_totp';
15
15
 
16
- // API wrapper classes for users who need to construct their own
17
- // instance (e.g. with MemoryStorageAdapter in SSR/tests).
18
- export { API as CfgAccountsAPI } from './cfg_accounts';
19
- export { API as CfgCentrifugoAPI } from './cfg_centrifugo';
20
- export { API as CfgTotpAPI } from './cfg_totp';
16
+ // Singletons for ergonomic access (`import { apiAccounts } from '@your/api'`).
17
+ // All instances share the same global `auth` store.
18
+ export const CfgAccountsApi = new CfgAccountsAPI();
19
+ export const CfgCentrifugoApi = new CfgCentrifugoAPI();
20
+ export const CfgTotpApi = new CfgTotpAPI();
21
+
22
+ // Per-group wrapper classes (e.g. for tests / SSR isolation of options).
23
+ export { API as CfgAccountsAPI } from './_cfg_accounts';
24
+ export { API as CfgCentrifugoAPI } from './_cfg_centrifugo';
25
+ export { API as CfgTotpAPI } from './_cfg_totp';
21
26
 
22
27
  // Hey API SDK classes — one per OpenAPI tag. Lets consumers call
23
- // `Centrifugo.cfgCentrifugoAuthTokenRetrieve({...})` directly without
24
- // going through the wrapper singleton.
25
- export { Accounts, OAuth, UserProfile, Auth } from './cfg_accounts';
26
- export { Centrifugo, CentrifugoAuth } from './cfg_centrifugo';
27
- export { Totp, BackupCodes, TotpManagement, TotpSetup, TotpVerification } from './cfg_totp';
28
+ // `Centrifugo.cfgCentrifugoAuthTokenRetrieve({...})` directly.
29
+
28
30
 
29
31
  // Shared utilities (errors, storage adapters, logger).
30
- export * from './_shared';
32
+ export * from './helpers';