@djangocfg/api 2.1.327 → 2.1.331

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 (170) hide show
  1. package/dist/auth-server.cjs +185 -3471
  2. package/dist/auth-server.cjs.map +1 -1
  3. package/dist/auth-server.mjs +185 -3471
  4. package/dist/auth-server.mjs.map +1 -1
  5. package/dist/auth.cjs +952 -3305
  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 +952 -3305
  10. package/dist/auth.mjs.map +1 -1
  11. package/dist/clients.cjs +90 -3396
  12. package/dist/clients.cjs.map +1 -1
  13. package/dist/clients.d.cts +4 -2508
  14. package/dist/clients.d.ts +4 -2508
  15. package/dist/clients.mjs +90 -3396
  16. package/dist/clients.mjs.map +1 -1
  17. package/dist/index.cjs +985 -3052
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +1544 -1938
  20. package/dist/index.d.ts +1544 -1938
  21. package/dist/index.mjs +985 -3052
  22. package/dist/index.mjs.map +1 -1
  23. package/package.json +2 -2
  24. package/src/_api/generated/{cfg_centrifugo → _cfg_accounts}/api.ts +11 -55
  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 +3 -3
  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_totp → _cfg_centrifugo}/api.ts +11 -72
  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 +3 -3
  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_accounts → _cfg_totp}/api.ts +11 -78
  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 +3 -3
  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/index.ts +11 -13
  105. package/src/_api/generated/{cfg_accounts/sdk.gen.ts → sdk.gen.ts} +455 -1
  106. package/src/_api/generated/{cfg_accounts/types.gen.ts → types.gen.ts} +607 -77
  107. package/src/auth/context/AccountsContext.tsx +10 -10
  108. package/src/auth/context/AuthContext.tsx +1 -1
  109. package/src/auth/hooks/useDeleteAccount.ts +2 -1
  110. package/src/auth/hooks/useGithubAuth.ts +3 -2
  111. package/src/auth/hooks/useTokenRefresh.ts +2 -1
  112. package/src/auth/hooks/useTwoFactor.ts +4 -3
  113. package/src/auth/hooks/useTwoFactorSetup.ts +3 -2
  114. package/src/auth/hooks/useTwoFactorStatus.ts +4 -3
  115. package/src/auth/middlewares/tokenRefresh.ts +2 -1
  116. package/src/clients.ts +3 -3
  117. package/src/index.ts +22 -5
  118. package/src/server.ts +9 -9
  119. package/src/_api/generated/cfg_centrifugo/client/client.gen.ts +0 -280
  120. package/src/_api/generated/cfg_centrifugo/client/index.ts +0 -25
  121. package/src/_api/generated/cfg_centrifugo/client/types.gen.ts +0 -217
  122. package/src/_api/generated/cfg_centrifugo/client/utils.gen.ts +0 -318
  123. package/src/_api/generated/cfg_centrifugo/client.gen.ts +0 -16
  124. package/src/_api/generated/cfg_centrifugo/core/auth.gen.ts +0 -41
  125. package/src/_api/generated/cfg_centrifugo/core/bodySerializer.gen.ts +0 -82
  126. package/src/_api/generated/cfg_centrifugo/core/params.gen.ts +0 -169
  127. package/src/_api/generated/cfg_centrifugo/core/pathSerializer.gen.ts +0 -171
  128. package/src/_api/generated/cfg_centrifugo/core/queryKeySerializer.gen.ts +0 -117
  129. package/src/_api/generated/cfg_centrifugo/core/serverSentEvents.gen.ts +0 -242
  130. package/src/_api/generated/cfg_centrifugo/core/types.gen.ts +0 -104
  131. package/src/_api/generated/cfg_centrifugo/core/utils.gen.ts +0 -140
  132. package/src/_api/generated/cfg_centrifugo/sdk.gen.ts +0 -64
  133. package/src/_api/generated/cfg_centrifugo/types.gen.ts +0 -61
  134. package/src/_api/generated/cfg_totp/client/client.gen.ts +0 -280
  135. package/src/_api/generated/cfg_totp/client/index.ts +0 -25
  136. package/src/_api/generated/cfg_totp/client/types.gen.ts +0 -217
  137. package/src/_api/generated/cfg_totp/client/utils.gen.ts +0 -318
  138. package/src/_api/generated/cfg_totp/client.gen.ts +0 -16
  139. package/src/_api/generated/cfg_totp/core/auth.gen.ts +0 -41
  140. package/src/_api/generated/cfg_totp/core/bodySerializer.gen.ts +0 -82
  141. package/src/_api/generated/cfg_totp/core/params.gen.ts +0 -169
  142. package/src/_api/generated/cfg_totp/core/pathSerializer.gen.ts +0 -171
  143. package/src/_api/generated/cfg_totp/core/queryKeySerializer.gen.ts +0 -117
  144. package/src/_api/generated/cfg_totp/core/serverSentEvents.gen.ts +0 -242
  145. package/src/_api/generated/cfg_totp/core/types.gen.ts +0 -104
  146. package/src/_api/generated/cfg_totp/core/utils.gen.ts +0 -140
  147. package/src/_api/generated/cfg_totp/schemas/SetupRequest.ts +0 -11
  148. package/src/_api/generated/cfg_totp/sdk.gen.ts +0 -432
  149. package/src/_api/generated/cfg_totp/types.gen.ts +0 -479
  150. /package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/index.ts +0 -0
  151. /package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/schemas/index.ts +0 -0
  152. /package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/index.ts +0 -0
  153. /package/src/_api/generated/{cfg_accounts/client → client}/client.gen.ts +0 -0
  154. /package/src/_api/generated/{cfg_accounts/client → client}/index.ts +0 -0
  155. /package/src/_api/generated/{cfg_accounts/client → client}/types.gen.ts +0 -0
  156. /package/src/_api/generated/{cfg_accounts/client → client}/utils.gen.ts +0 -0
  157. /package/src/_api/generated/{cfg_accounts/client.gen.ts → client.gen.ts} +0 -0
  158. /package/src/_api/generated/{cfg_accounts/core → core}/auth.gen.ts +0 -0
  159. /package/src/_api/generated/{cfg_accounts/core → core}/bodySerializer.gen.ts +0 -0
  160. /package/src/_api/generated/{cfg_accounts/core → core}/params.gen.ts +0 -0
  161. /package/src/_api/generated/{cfg_accounts/core → core}/pathSerializer.gen.ts +0 -0
  162. /package/src/_api/generated/{cfg_accounts/core → core}/queryKeySerializer.gen.ts +0 -0
  163. /package/src/_api/generated/{cfg_accounts/core → core}/serverSentEvents.gen.ts +0 -0
  164. /package/src/_api/generated/{cfg_accounts/core → core}/types.gen.ts +0 -0
  165. /package/src/_api/generated/{cfg_accounts/core → core}/utils.gen.ts +0 -0
  166. /package/src/_api/generated/{_shared → helpers}/errors.ts +0 -0
  167. /package/src/_api/generated/{_shared → helpers}/index.ts +0 -0
  168. /package/src/_api/generated/{_shared → helpers}/logger.ts +0 -0
  169. /package/src/_api/generated/{_shared → helpers}/storage.ts +0 -0
  170. /package/src/_api/generated/{_shared → helpers}/validation-events.ts +0 -0
@@ -17,8 +17,8 @@ import {
17
17
  createContext, ReactNode, useCallback, useContext, useEffect, useRef, useState
18
18
  } from 'react';
19
19
 
20
- import { cfgAccountsApi } from '../../';
21
- import { Accounts, Auth, UserProfile } from '../../_api/generated/cfg_accounts/sdk.gen';
20
+ import { CfgAccountsApi } from '../../';
21
+ import { Accounts, Auth, UserProfile } from '../../_api/generated/_cfg_accounts/sdk.gen';
22
22
  import {
23
23
  useCfgAccountsOtpRequestCreate,
24
24
  useCfgAccountsOtpVerifyCreate,
@@ -26,8 +26,8 @@ import {
26
26
  useCfgAccountsProfilePartialUpdate,
27
27
  useCfgAccountsProfileUpdateUpdate,
28
28
  useCfgAccountsTokenRefreshCreate,
29
- } from '../../_api/generated/cfg_accounts/hooks';
30
- import { PatchedCfgUserUpdateRequestSchema } from '../../_api/generated/cfg_accounts/schemas';
29
+ } from '../../_api/generated/_cfg_accounts/hooks';
30
+ import { PatchedCfgUserUpdateRequestSchema } from '../../_api/generated/_cfg_accounts/schemas';
31
31
  import { clearProfileCache, getCachedProfile, setCachedProfile } from '../hooks/useProfileCache';
32
32
  import { authLogger } from '../utils/logger';
33
33
 
@@ -41,7 +41,7 @@ import type {
41
41
  OtpVerifyResponse,
42
42
  TokenRefresh,
43
43
  TokenRefreshRequest,
44
- } from '../../_api/generated/cfg_accounts/types.gen';
44
+ } from '../../_api/generated/_cfg_accounts/types.gen';
45
45
 
46
46
  export { PatchedCfgUserUpdateRequestSchema };
47
47
  export type { PatchedCfgUserUpdateRequest, User, CfgUserUpdateRequest as UserProfileUpdateRequest };
@@ -159,8 +159,8 @@ export function AccountsProvider({ children }: AccountsProviderProps) {
159
159
  }
160
160
 
161
161
  if (result.access && result.refresh) {
162
- cfgAccountsApi.setToken(result.access);
163
- cfgAccountsApi.setRefreshToken(result.refresh);
162
+ CfgAccountsApi.setToken(result.access);
163
+ CfgAccountsApi.setRefreshToken(result.refresh);
164
164
  try {
165
165
  await refreshProfile({ callerId: 'verifyOTP', force: true });
166
166
  } catch (profileError) {
@@ -176,15 +176,15 @@ export function AccountsProvider({ children }: AccountsProviderProps) {
176
176
  const result = (await triggerTokenRefresh({ body })) as TokenRefresh;
177
177
 
178
178
  if (result.access) {
179
- cfgAccountsApi.setToken(result.access);
180
- cfgAccountsApi.setRefreshToken(refresh);
179
+ CfgAccountsApi.setToken(result.access);
180
+ CfgAccountsApi.setRefreshToken(refresh);
181
181
  }
182
182
 
183
183
  return result;
184
184
  };
185
185
 
186
186
  const logout = useCallback(() => {
187
- cfgAccountsApi.clearToken();
187
+ CfgAccountsApi.clearToken();
188
188
  setProfile(undefined);
189
189
  setProfileError(null);
190
190
  clearProfileCache();
@@ -11,7 +11,7 @@ import { SWRConfig } from 'swr';
11
11
  import { useCfgRouter, useLocalStorage, useQueryParams } from '../hooks';
12
12
 
13
13
  import { api as apiAccounts } from '../../';
14
- import { APIError } from '../../_api/generated/_shared';
14
+ import { APIError } from '../../_api/generated/helpers';
15
15
  import { clearProfileCache, getCachedProfile } from '../hooks/useProfileCache';
16
16
  import { useAuthRedirectManager } from '../hooks/useAuthRedirect';
17
17
  import { useTokenRefresh } from '../hooks/useTokenRefresh';
@@ -3,6 +3,7 @@
3
3
  import { useCallback, useState } from 'react';
4
4
 
5
5
  import { apiAccounts } from '../../clients';
6
+ import { UserProfile } from '../../_api/generated/sdk.gen';
6
7
  import { useAuth } from '../context';
7
8
  import { authLogger } from '../utils/logger';
8
9
 
@@ -60,7 +61,7 @@ export const useDeleteAccount = (): UseDeleteAccountReturn => {
60
61
  try {
61
62
  authLogger.info('Deleting account...');
62
63
 
63
- const result = await apiAccounts.userProfile.cfgAccountsProfileDeleteCreate({ throwOnError: true });
64
+ const result = await UserProfile.cfgAccountsProfileDeleteCreate({ throwOnError: true });
64
65
  const response = result.data;
65
66
 
66
67
  if (!response.success) {
@@ -3,6 +3,7 @@
3
3
  import { useCallback, useState } from 'react';
4
4
 
5
5
  import { apiAccounts } from '../../clients';
6
+ import { OAuth } from '../../_api/generated/sdk.gen';
6
7
  import { Analytics, AnalyticsCategory, AnalyticsEvent } from '../utils/analytics';
7
8
  import { authLogger } from '../utils/logger';
8
9
  import { useCfgRouter } from './useCfgRouter';
@@ -69,7 +70,7 @@ export const useGithubAuth = (options: UseGithubAuthOptions = {}): UseGithubAuth
69
70
 
70
71
  // Call API to get authorization URL
71
72
  // The API will auto-generate redirect_uri from config if not provided
72
- const result = await apiAccounts.oAuth.cfgAccountsOauthGithubAuthorizeCreate({
73
+ const result = await OAuth.cfgAccountsOauthGithubAuthorizeCreate({
73
74
  body: {
74
75
  source_url: sourceUrl || (typeof window !== 'undefined' ? window.location.href : ''),
75
76
  },
@@ -130,7 +131,7 @@ export const useGithubAuth = (options: UseGithubAuthOptions = {}): UseGithubAuth
130
131
  sessionStorage.removeItem('oauth_provider');
131
132
  }
132
133
 
133
- const result = await apiAccounts.oAuth.cfgAccountsOauthGithubCallbackCreate({
134
+ const result = await OAuth.cfgAccountsOauthGithubCallbackCreate({
134
135
  body: { code, state },
135
136
  throwOnError: true,
136
137
  });
@@ -12,6 +12,7 @@
12
12
  import { useCallback, useEffect, useRef } from 'react';
13
13
 
14
14
  import { api as apiAccounts } from '../../';
15
+ import { Auth } from '../../_api/generated/sdk.gen';
15
16
  import { authLogger } from '../utils/logger';
16
17
 
17
18
  // Configuration
@@ -77,7 +78,7 @@ export function useTokenRefresh(options: UseTokenRefreshOptions = {}) {
77
78
 
78
79
  try {
79
80
  // Use generated API client with correct URL (/cfg/accounts/token/refresh/)
80
- const result = await apiAccounts.auth.cfgAccountsTokenRefreshCreate({
81
+ const result = await Auth.cfgAccountsTokenRefreshCreate({
81
82
  body: { refresh: refreshTokenValue },
82
83
  throwOnError: true,
83
84
  });
@@ -3,7 +3,8 @@
3
3
  import { useCallback, useState } from 'react';
4
4
 
5
5
  import { apiAccounts, apiTotp } from '../../clients';
6
- import { APIError } from '../../_api/generated/_shared';
6
+ import { APIError } from '../../_api/generated/helpers';
7
+ import { TotpVerification } from '../../_api/generated/sdk.gen';
7
8
  import { Analytics, AnalyticsCategory, AnalyticsEvent } from '../utils/analytics';
8
9
  import { authLogger } from '../utils/logger';
9
10
  import { useCfgRouter } from './useCfgRouter';
@@ -147,7 +148,7 @@ export const useTwoFactor = (options: UseTwoFactorOptions = {}): UseTwoFactorRet
147
148
  try {
148
149
  authLogger.info('Verifying TOTP code...');
149
150
 
150
- const result = await apiTotp.totpVerification.cfgTotpVerifyCreate({
151
+ const result = await TotpVerification.cfgTotpVerifyCreate({
151
152
  body: { session_id: sessionId, code },
152
153
  throwOnError: true,
153
154
  });
@@ -207,7 +208,7 @@ export const useTwoFactor = (options: UseTwoFactorOptions = {}): UseTwoFactorRet
207
208
  try {
208
209
  authLogger.info('Verifying backup code...');
209
210
 
210
- const result = await apiTotp.totpVerification.cfgTotpVerifyBackupCreate({
211
+ const result = await TotpVerification.cfgTotpVerifyBackupCreate({
211
212
  body: {
212
213
  session_id: sessionId,
213
214
  backup_code: backupCode.replace(/\s+/g, ''),
@@ -3,6 +3,7 @@
3
3
  import { useCallback, useState } from 'react';
4
4
 
5
5
  import { apiTotp } from '../../clients';
6
+ import { TotpSetup } from '../../_api/generated/sdk.gen';
6
7
  import { authLogger } from '../utils/logger';
7
8
 
8
9
  export interface TwoFactorSetupData {
@@ -115,7 +116,7 @@ export const useTwoFactorSetup = (options: UseTwoFactorSetupOptions = {}): UseTw
115
116
  try {
116
117
  authLogger.info('Starting 2FA setup...');
117
118
 
118
- const result = await apiTotp.totpSetup.cfgTotpSetupCreate({
119
+ const result = await TotpSetup.cfgTotpSetupCreate({
119
120
  body: { device_name: deviceName },
120
121
  throwOnError: true,
121
122
  });
@@ -171,7 +172,7 @@ export const useTwoFactorSetup = (options: UseTwoFactorSetupOptions = {}): UseTw
171
172
  try {
172
173
  authLogger.info('Confirming 2FA setup...');
173
174
 
174
- const result = await apiTotp.totpSetup.cfgTotpSetupConfirmCreate({
175
+ const result = await TotpSetup.cfgTotpSetupConfirmCreate({
175
176
  body: { device_id: setupData.deviceId, code },
176
177
  throwOnError: true,
177
178
  });
@@ -3,7 +3,8 @@
3
3
  import { useCallback, useState } from 'react';
4
4
 
5
5
  import { apiTotp } from '../../clients';
6
- import { APIError } from '../../_api/generated/cfg_totp';
6
+ import { APIError } from '../../_api/generated/helpers';
7
+ import { TotpManagement } from '../../_api/generated/sdk.gen';
7
8
  import { authLogger } from '../utils/logger';
8
9
 
9
10
  export interface TwoFactorDevice {
@@ -82,7 +83,7 @@ export const useTwoFactorStatus = (): UseTwoFactorStatusReturn => {
82
83
  authLogger.info('Fetching 2FA status...');
83
84
 
84
85
  // API returns { devices: [...], has_2fa_enabled: bool }
85
- const result = await apiTotp.totpManagement.cfgTotpDevicesRetrieve({ throwOnError: true });
86
+ const result = await TotpManagement.cfgTotpDevicesRetrieve({ throwOnError: true });
86
87
  const response = result.data;
87
88
 
88
89
  const mappedDevices: TwoFactorDevice[] = response.devices.map((device) => ({
@@ -122,7 +123,7 @@ export const useTwoFactorStatus = (): UseTwoFactorStatusReturn => {
122
123
  try {
123
124
  authLogger.info('Disabling 2FA...');
124
125
 
125
- await apiTotp.totpManagement.cfgTotpDisableCreate({ body: { code }, throwOnError: true });
126
+ await TotpManagement.cfgTotpDisableCreate({ body: { code }, throwOnError: true });
126
127
 
127
128
  setHas2FAEnabled(false);
128
129
  setDevices([]);
@@ -6,6 +6,7 @@
6
6
  */
7
7
 
8
8
  import { api as apiAccounts } from '../../';
9
+ import { Auth } from '../../_api/generated/sdk.gen';
9
10
  import { authLogger } from '../utils/logger';
10
11
 
11
12
  // Refresh state management
@@ -51,7 +52,7 @@ export async function refreshAccessToken(): Promise<string | null> {
51
52
  }
52
53
 
53
54
  // Use generated API client with correct URL (/cfg/accounts/token/refresh/)
54
- const result = await apiAccounts.auth.cfgAccountsTokenRefreshCreate({
55
+ const result = await Auth.cfgAccountsTokenRefreshCreate({
55
56
  body: { refresh: refreshToken },
56
57
  throwOnError: true,
57
58
  });
package/src/clients.ts CHANGED
@@ -11,9 +11,9 @@
11
11
  */
12
12
 
13
13
  export {
14
- cfgAccountsApi as apiAccounts,
15
- cfgTotpApi as apiTotp,
16
- cfgCentrifugoApi as apiCentrifugo,
14
+ CfgAccountsApi as apiAccounts,
15
+ CfgTotpApi as apiTotp,
16
+ CfgCentrifugoApi as apiCentrifugo,
17
17
  CfgAccountsAPI as AccountsAPI,
18
18
  CfgTotpAPI as TotpAPI,
19
19
  CfgCentrifugoAPI as CentrifugoAPI,
package/src/index.ts CHANGED
@@ -11,13 +11,30 @@
11
11
 
12
12
  export * from './_api/generated';
13
13
 
14
+ // Hey API SDK classes (one per OpenAPI tag) — direct callable static methods,
15
+ // e.g. `CentrifugoAuth.cfgCentrifugoAuthTokenRetrieve(...)`.
16
+ export {
17
+ Cfg,
18
+ Accounts,
19
+ OAuth,
20
+ UserProfile,
21
+ Auth,
22
+ Centrifugo,
23
+ CentrifugoAuth,
24
+ Totp,
25
+ BackupCodes,
26
+ TotpManagement,
27
+ TotpSetup,
28
+ TotpVerification,
29
+ } from './_api/generated/sdk.gen';
30
+
14
31
  // Type namespaces (one per group) for code that needs `AccountsTypes.User`.
15
- export type * as AccountsTypes from './_api/generated/cfg_accounts/types.gen';
16
- export type * as TotpTypes from './_api/generated/cfg_totp/types.gen';
17
- export type * as CentrifugoTypes from './_api/generated/cfg_centrifugo/types.gen';
32
+ export type * as AccountsTypes from './_api/generated/_cfg_accounts/types.gen';
33
+ export type * as TotpTypes from './_api/generated/_cfg_totp/types.gen';
34
+ export type * as CentrifugoTypes from './_api/generated/_cfg_centrifugo/types.gen';
18
35
 
19
36
  // Convenience top-level type re-exports.
20
- export type { User } from './_api/generated/cfg_accounts/types.gen';
37
+ export type { User } from './_api/generated/_cfg_accounts/types.gen';
21
38
 
22
39
  // Legacy alias for code that still imports `api` (= cfg_accounts singleton).
23
- export { cfgAccountsApi as api } from './_api/generated';
40
+ export { CfgAccountsApi as api } from './_api/generated';
package/src/server.ts CHANGED
@@ -17,16 +17,16 @@ export {
17
17
  } from './_api/generated';
18
18
 
19
19
  // SDK fetchers (Hey API SDK classes — re-export as namespace modules).
20
- export * as AccountsFetchers from './_api/generated/cfg_accounts/sdk.gen';
21
- export * as TotpFetchers from './_api/generated/cfg_totp/sdk.gen';
22
- export * as CentrifugoFetchers from './_api/generated/cfg_centrifugo/sdk.gen';
20
+ export * as AccountsFetchers from './_api/generated/_cfg_accounts/sdk.gen';
21
+ export * as TotpFetchers from './_api/generated/_cfg_totp/sdk.gen';
22
+ export * as CentrifugoFetchers from './_api/generated/_cfg_centrifugo/sdk.gen';
23
23
 
24
24
  // Zod schemas.
25
- export * as AccountsSchemas from './_api/generated/cfg_accounts/schemas';
26
- export * as TotpSchemas from './_api/generated/cfg_totp/schemas';
27
- export * as CentrifugoSchemas from './_api/generated/cfg_centrifugo/schemas';
25
+ export * as AccountsSchemas from './_api/generated/_cfg_accounts/schemas';
26
+ export * as TotpSchemas from './_api/generated/_cfg_totp/schemas';
27
+ export * as CentrifugoSchemas from './_api/generated/_cfg_centrifugo/schemas';
28
28
 
29
29
  // Types.
30
- export type * as AccountsTypes from './_api/generated/cfg_accounts/types.gen';
31
- export type * as TotpTypes from './_api/generated/cfg_totp/types.gen';
32
- export type * as CentrifugoTypes from './_api/generated/cfg_centrifugo/types.gen';
30
+ export type * as AccountsTypes from './_api/generated/_cfg_accounts/types.gen';
31
+ export type * as TotpTypes from './_api/generated/_cfg_totp/types.gen';
32
+ export type * as CentrifugoTypes from './_api/generated/_cfg_centrifugo/types.gen';
@@ -1,280 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
-
3
- import { createSseClient } from '../core/serverSentEvents.gen';
4
- import type { HttpMethod } from '../core/types.gen';
5
- import { getValidRequestBody } from '../core/utils.gen';
6
- import type { Client, Config, RequestOptions, ResolvedRequestOptions } from './types.gen';
7
- import {
8
- buildUrl,
9
- createConfig,
10
- createInterceptors,
11
- getParseAs,
12
- mergeConfigs,
13
- mergeHeaders,
14
- setAuthParams,
15
- } from './utils.gen';
16
-
17
- type ReqInit = Omit<RequestInit, 'body' | 'headers'> & {
18
- body?: any;
19
- headers: ReturnType<typeof mergeHeaders>;
20
- };
21
-
22
- export const createClient = (config: Config = {}): Client => {
23
- let _config = mergeConfigs(createConfig(), config);
24
-
25
- const getConfig = (): Config => ({ ..._config });
26
-
27
- const setConfig = (config: Config): Config => {
28
- _config = mergeConfigs(_config, config);
29
- return getConfig();
30
- };
31
-
32
- const interceptors = createInterceptors<Request, Response, unknown, ResolvedRequestOptions>();
33
-
34
- const beforeRequest = async <
35
- TData = unknown,
36
- TResponseStyle extends 'data' | 'fields' = 'fields',
37
- ThrowOnError extends boolean = boolean,
38
- Url extends string = string,
39
- >(
40
- options: RequestOptions<TData, TResponseStyle, ThrowOnError, Url>,
41
- ) => {
42
- const opts = {
43
- ..._config,
44
- ...options,
45
- fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
46
- headers: mergeHeaders(_config.headers, options.headers),
47
- serializedBody: undefined as string | undefined,
48
- };
49
-
50
- if (opts.security) {
51
- await setAuthParams({
52
- ...opts,
53
- security: opts.security,
54
- });
55
- }
56
-
57
- if (opts.requestValidator) {
58
- await opts.requestValidator(opts);
59
- }
60
-
61
- if (opts.body !== undefined && opts.bodySerializer) {
62
- opts.serializedBody = opts.bodySerializer(opts.body) as string | undefined;
63
- }
64
-
65
- // remove Content-Type header if body is empty to avoid sending invalid requests
66
- if (opts.body === undefined || opts.serializedBody === '') {
67
- opts.headers.delete('Content-Type');
68
- }
69
-
70
- const resolvedOpts = opts as typeof opts &
71
- ResolvedRequestOptions<TResponseStyle, ThrowOnError, Url>;
72
- const url = buildUrl(resolvedOpts);
73
-
74
- return { opts: resolvedOpts, url };
75
- };
76
-
77
- const request: Client['request'] = async (options) => {
78
- const throwOnError = options.throwOnError ?? _config.throwOnError;
79
- const responseStyle = options.responseStyle ?? _config.responseStyle;
80
-
81
- let request: Request | undefined;
82
- let response: Response | undefined;
83
-
84
- try {
85
- const { opts, url } = await beforeRequest(options);
86
- const requestInit: ReqInit = {
87
- redirect: 'follow',
88
- ...opts,
89
- body: getValidRequestBody(opts),
90
- };
91
-
92
- request = new Request(url, requestInit);
93
-
94
- for (const fn of interceptors.request.fns) {
95
- if (fn) {
96
- request = await fn(request, opts);
97
- }
98
- }
99
-
100
- // fetch must be assigned here, otherwise it would throw the error:
101
- // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
102
- const _fetch = opts.fetch!;
103
-
104
- response = await _fetch(request);
105
-
106
- for (const fn of interceptors.response.fns) {
107
- if (fn) {
108
- response = await fn(response, request, opts);
109
- }
110
- }
111
-
112
- const result = {
113
- request,
114
- response,
115
- };
116
-
117
- if (response.ok) {
118
- const parseAs =
119
- (opts.parseAs === 'auto'
120
- ? getParseAs(response.headers.get('Content-Type'))
121
- : opts.parseAs) ?? 'json';
122
-
123
- if (response.status === 204 || response.headers.get('Content-Length') === '0') {
124
- let emptyData: any;
125
- switch (parseAs) {
126
- case 'arrayBuffer':
127
- case 'blob':
128
- case 'text':
129
- emptyData = await response[parseAs]();
130
- break;
131
- case 'formData':
132
- emptyData = new FormData();
133
- break;
134
- case 'stream':
135
- emptyData = response.body;
136
- break;
137
- case 'json':
138
- default:
139
- emptyData = {};
140
- break;
141
- }
142
- return opts.responseStyle === 'data'
143
- ? emptyData
144
- : {
145
- data: emptyData,
146
- ...result,
147
- };
148
- }
149
-
150
- let data: any;
151
- switch (parseAs) {
152
- case 'arrayBuffer':
153
- case 'blob':
154
- case 'formData':
155
- case 'text':
156
- data = await response[parseAs]();
157
- break;
158
- case 'json': {
159
- // Some servers return 200 with no Content-Length and empty body.
160
- // response.json() would throw; read as text and parse if non-empty.
161
- const text = await response.text();
162
- data = text ? JSON.parse(text) : {};
163
- break;
164
- }
165
- case 'stream':
166
- return opts.responseStyle === 'data'
167
- ? response.body
168
- : {
169
- data: response.body,
170
- ...result,
171
- };
172
- }
173
-
174
- if (parseAs === 'json') {
175
- if (opts.responseValidator) {
176
- await opts.responseValidator(data);
177
- }
178
-
179
- if (opts.responseTransformer) {
180
- data = await opts.responseTransformer(data);
181
- }
182
- }
183
-
184
- return opts.responseStyle === 'data'
185
- ? data
186
- : {
187
- data,
188
- ...result,
189
- };
190
- }
191
-
192
- const textError = await response.text();
193
- let jsonError: unknown;
194
-
195
- try {
196
- jsonError = JSON.parse(textError);
197
- } catch {
198
- // noop
199
- }
200
-
201
- throw jsonError ?? textError;
202
- } catch (error) {
203
- let finalError = error;
204
-
205
- for (const fn of interceptors.error.fns) {
206
- if (fn) {
207
- finalError = await fn(finalError, response, request, options as ResolvedRequestOptions);
208
- }
209
- }
210
-
211
- finalError = finalError || {};
212
-
213
- if (throwOnError) {
214
- throw finalError;
215
- }
216
-
217
- // TODO: we probably want to return error and improve types
218
- return responseStyle === 'data'
219
- ? undefined
220
- : {
221
- error: finalError,
222
- request,
223
- response,
224
- };
225
- }
226
- };
227
-
228
- const makeMethodFn = (method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
229
- request({ ...options, method });
230
-
231
- const makeSseFn = (method: Uppercase<HttpMethod>) => async (options: RequestOptions) => {
232
- const { opts, url } = await beforeRequest(options);
233
- return createSseClient({
234
- ...opts,
235
- body: opts.body as BodyInit | null | undefined,
236
- method,
237
- onRequest: async (url, init) => {
238
- let request = new Request(url, init);
239
- for (const fn of interceptors.request.fns) {
240
- if (fn) {
241
- request = await fn(request, opts);
242
- }
243
- }
244
- return request;
245
- },
246
- serializedBody: getValidRequestBody(opts) as BodyInit | null | undefined,
247
- url,
248
- });
249
- };
250
-
251
- const _buildUrl: Client['buildUrl'] = (options) => buildUrl({ ..._config, ...options });
252
-
253
- return {
254
- buildUrl: _buildUrl,
255
- connect: makeMethodFn('CONNECT'),
256
- delete: makeMethodFn('DELETE'),
257
- get: makeMethodFn('GET'),
258
- getConfig,
259
- head: makeMethodFn('HEAD'),
260
- interceptors,
261
- options: makeMethodFn('OPTIONS'),
262
- patch: makeMethodFn('PATCH'),
263
- post: makeMethodFn('POST'),
264
- put: makeMethodFn('PUT'),
265
- request,
266
- setConfig,
267
- sse: {
268
- connect: makeSseFn('CONNECT'),
269
- delete: makeSseFn('DELETE'),
270
- get: makeSseFn('GET'),
271
- head: makeSseFn('HEAD'),
272
- options: makeSseFn('OPTIONS'),
273
- patch: makeSseFn('PATCH'),
274
- post: makeSseFn('POST'),
275
- put: makeSseFn('PUT'),
276
- trace: makeSseFn('TRACE'),
277
- },
278
- trace: makeMethodFn('TRACE'),
279
- } as Client;
280
- };
@@ -1,25 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
-
3
- export type { Auth } from '../core/auth.gen';
4
- export type { QuerySerializerOptions } from '../core/bodySerializer.gen';
5
- export {
6
- formDataBodySerializer,
7
- jsonBodySerializer,
8
- urlSearchParamsBodySerializer,
9
- } from '../core/bodySerializer.gen';
10
- export { buildClientParams } from '../core/params.gen';
11
- export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen';
12
- export { createClient } from './client.gen';
13
- export type {
14
- Client,
15
- ClientOptions,
16
- Config,
17
- CreateClientConfig,
18
- Options,
19
- RequestOptions,
20
- RequestResult,
21
- ResolvedRequestOptions,
22
- ResponseStyle,
23
- TDataShape,
24
- } from './types.gen';
25
- export { createConfig, mergeHeaders } from './utils.gen';