@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.
- package/dist/auth-server.cjs +328 -3553
- package/dist/auth-server.cjs.map +1 -1
- package/dist/auth-server.mjs +328 -3553
- package/dist/auth-server.mjs.map +1 -1
- package/dist/auth.cjs +744 -3036
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +35 -35
- package/dist/auth.d.ts +35 -35
- package/dist/auth.mjs +744 -3036
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +303 -3548
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +28 -2557
- package/dist/clients.d.ts +28 -2557
- package/dist/clients.mjs +303 -3548
- package/dist/clients.mjs.map +1 -1
- package/dist/index.cjs +1130 -3099
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1807 -2165
- package/dist/index.d.ts +1807 -2165
- package/dist/index.mjs +1130 -3099
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/_api/generated/_cfg_accounts/api.ts +67 -0
- package/src/_api/generated/{cfg_totp → _cfg_accounts}/events.ts +3 -3
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/index.ts +1 -1
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthConnectionsList.ts +5 -6
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthDisconnectCreate.ts +3 -3
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthGithubAuthorizeCreate.ts +3 -3
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthGithubCallbackCreate.ts +3 -3
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthProvidersRetrieve.ts +5 -6
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOtpRequestCreate.ts +3 -3
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOtpVerifyCreate.ts +3 -3
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileAvatarCreate.ts +3 -3
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileDeleteCreate.ts +3 -3
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfilePartialPartialUpdate.ts +3 -3
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfilePartialUpdate.ts +3 -3
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileRetrieve.ts +5 -6
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileUpdatePartialUpdate.ts +3 -3
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileUpdateUpdate.ts +3 -3
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsTokenRefreshCreate.ts +3 -3
- package/src/_api/generated/{cfg_centrifugo → _cfg_accounts}/index.ts +6 -6
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/AccountDeleteResponse.ts +3 -3
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/CentrifugoToken.ts +4 -4
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/CfgUserUpdateRequest.ts +4 -4
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthAuthorizeRequestRequest.ts +2 -2
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthAuthorizeResponse.ts +2 -2
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthCallbackRequestRequest.ts +3 -3
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthConnection.ts +6 -6
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthDisconnectRequestRequest.ts +2 -2
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthError.ts +2 -2
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthProvidersResponse.ts +3 -3
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthTokenResponse.ts +7 -7
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPErrorResponse.ts +2 -2
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPRequestRequest.ts +2 -2
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPRequestResponse.ts +2 -2
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPVerifyRequest.ts +2 -2
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPVerifyResponse.ts +6 -6
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/PatchedCfgUserUpdateRequest.ts +4 -4
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/ProviderEnum.ts +2 -2
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/TokenRefresh.ts +2 -2
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/TokenRefreshRequest.ts +2 -2
- package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/User.ts +13 -13
- package/src/_api/generated/_cfg_accounts/sdk.gen.ts +5 -0
- package/src/_api/generated/_cfg_accounts/types.gen.ts +5 -0
- package/src/_api/generated/_cfg_centrifugo/api.ts +67 -0
- package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/events.ts +3 -3
- package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/hooks/index.ts +1 -1
- package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/hooks/useCfgCentrifugoAuthTokenRetrieve.ts +5 -6
- package/src/_api/generated/{cfg_accounts → _cfg_centrifugo}/index.ts +6 -6
- package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/schemas/ConnectionTokenResponse.ts +4 -4
- package/src/_api/generated/_cfg_centrifugo/sdk.gen.ts +5 -0
- package/src/_api/generated/_cfg_centrifugo/types.gen.ts +5 -0
- package/src/_api/generated/_cfg_totp/api.ts +67 -0
- package/src/_api/generated/{cfg_accounts → _cfg_totp}/events.ts +3 -3
- package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/index.ts +1 -1
- package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpBackupCodesRegenerateCreate.ts +3 -3
- package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpBackupCodesRetrieve.ts +5 -6
- package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpDevicesDestroy.ts +3 -3
- package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpDevicesRetrieve.ts +5 -6
- package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpDisableCreate.ts +3 -3
- package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpSetupConfirmCreate.ts +3 -3
- package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpSetupCreate.ts +3 -3
- package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpVerifyBackupCreate.ts +3 -3
- package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpVerifyCreate.ts +3 -3
- package/src/_api/generated/{cfg_totp → _cfg_totp}/index.ts +6 -6
- package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/BackupCodesRegenerateRequest.ts +2 -2
- package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/BackupCodesRegenerateResponse.ts +2 -2
- package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/BackupCodesStatus.ts +2 -2
- package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/ConfirmSetupRequest.ts +3 -3
- package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/ConfirmSetupResponse.ts +3 -3
- package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/DeviceList.ts +6 -6
- package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/DeviceListResponse.ts +2 -2
- package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/DeviceListStatusEnum.ts +2 -2
- package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/DisableRequest.ts +2 -2
- package/src/_api/generated/_cfg_totp/schemas/SetupRequest.ts +11 -0
- package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/SetupResponse.ts +4 -4
- package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/TotpVerifyUser.ts +12 -12
- package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/VerifyBackupRequest.ts +3 -3
- package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/VerifyRequest.ts +3 -3
- package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/VerifyResponse.ts +4 -4
- package/src/_api/generated/_cfg_totp/sdk.gen.ts +5 -0
- package/src/_api/generated/_cfg_totp/types.gen.ts +5 -0
- package/src/_api/generated/{cfg_centrifugo/client.gen.ts → client.gen.ts} +3 -0
- package/src/_api/generated/helpers/auth.ts +223 -0
- package/src/_api/generated/{_shared → helpers}/index.ts +1 -0
- package/src/_api/generated/index.ts +22 -20
- package/src/_api/generated/{cfg_accounts/sdk.gen.ts → sdk.gen.ts} +455 -1
- package/src/_api/generated/{cfg_accounts/types.gen.ts → types.gen.ts} +607 -77
- package/src/auth/context/AccountsContext.tsx +10 -10
- package/src/auth/context/AuthContext.tsx +1 -1
- package/src/auth/hooks/useDeleteAccount.ts +2 -1
- package/src/auth/hooks/useGithubAuth.ts +3 -2
- package/src/auth/hooks/useTokenRefresh.ts +2 -1
- package/src/auth/hooks/useTwoFactor.ts +4 -3
- package/src/auth/hooks/useTwoFactorSetup.ts +3 -2
- package/src/auth/hooks/useTwoFactorStatus.ts +4 -3
- package/src/auth/middlewares/tokenRefresh.ts +2 -1
- package/src/clients.ts +3 -3
- package/src/index.ts +22 -5
- package/src/server.ts +9 -9
- package/src/_api/generated/cfg_accounts/api.ts +0 -187
- package/src/_api/generated/cfg_accounts/client.gen.ts +0 -16
- package/src/_api/generated/cfg_centrifugo/api.ts +0 -164
- package/src/_api/generated/cfg_centrifugo/client/client.gen.ts +0 -280
- package/src/_api/generated/cfg_centrifugo/client/index.ts +0 -25
- package/src/_api/generated/cfg_centrifugo/client/types.gen.ts +0 -217
- package/src/_api/generated/cfg_centrifugo/client/utils.gen.ts +0 -318
- package/src/_api/generated/cfg_centrifugo/core/auth.gen.ts +0 -41
- package/src/_api/generated/cfg_centrifugo/core/bodySerializer.gen.ts +0 -82
- package/src/_api/generated/cfg_centrifugo/core/params.gen.ts +0 -169
- package/src/_api/generated/cfg_centrifugo/core/pathSerializer.gen.ts +0 -171
- package/src/_api/generated/cfg_centrifugo/core/queryKeySerializer.gen.ts +0 -117
- package/src/_api/generated/cfg_centrifugo/core/serverSentEvents.gen.ts +0 -242
- package/src/_api/generated/cfg_centrifugo/core/types.gen.ts +0 -104
- package/src/_api/generated/cfg_centrifugo/core/utils.gen.ts +0 -140
- package/src/_api/generated/cfg_centrifugo/sdk.gen.ts +0 -64
- package/src/_api/generated/cfg_centrifugo/types.gen.ts +0 -61
- package/src/_api/generated/cfg_totp/api.ts +0 -181
- package/src/_api/generated/cfg_totp/client/client.gen.ts +0 -280
- package/src/_api/generated/cfg_totp/client/index.ts +0 -25
- package/src/_api/generated/cfg_totp/client/types.gen.ts +0 -217
- package/src/_api/generated/cfg_totp/client/utils.gen.ts +0 -318
- package/src/_api/generated/cfg_totp/client.gen.ts +0 -16
- package/src/_api/generated/cfg_totp/core/auth.gen.ts +0 -41
- package/src/_api/generated/cfg_totp/core/bodySerializer.gen.ts +0 -82
- package/src/_api/generated/cfg_totp/core/params.gen.ts +0 -169
- package/src/_api/generated/cfg_totp/core/pathSerializer.gen.ts +0 -171
- package/src/_api/generated/cfg_totp/core/queryKeySerializer.gen.ts +0 -117
- package/src/_api/generated/cfg_totp/core/serverSentEvents.gen.ts +0 -242
- package/src/_api/generated/cfg_totp/core/types.gen.ts +0 -104
- package/src/_api/generated/cfg_totp/core/utils.gen.ts +0 -140
- package/src/_api/generated/cfg_totp/schemas/SetupRequest.ts +0 -11
- package/src/_api/generated/cfg_totp/sdk.gen.ts +0 -432
- package/src/_api/generated/cfg_totp/types.gen.ts +0 -479
- /package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/index.ts +0 -0
- /package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/schemas/index.ts +0 -0
- /package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/index.ts +0 -0
- /package/src/_api/generated/{cfg_accounts/client → client}/client.gen.ts +0 -0
- /package/src/_api/generated/{cfg_accounts/client → client}/index.ts +0 -0
- /package/src/_api/generated/{cfg_accounts/client → client}/types.gen.ts +0 -0
- /package/src/_api/generated/{cfg_accounts/client → client}/utils.gen.ts +0 -0
- /package/src/_api/generated/{cfg_accounts/core → core}/auth.gen.ts +0 -0
- /package/src/_api/generated/{cfg_accounts/core → core}/bodySerializer.gen.ts +0 -0
- /package/src/_api/generated/{cfg_accounts/core → core}/params.gen.ts +0 -0
- /package/src/_api/generated/{cfg_accounts/core → core}/pathSerializer.gen.ts +0 -0
- /package/src/_api/generated/{cfg_accounts/core → core}/queryKeySerializer.gen.ts +0 -0
- /package/src/_api/generated/{cfg_accounts/core → core}/serverSentEvents.gen.ts +0 -0
- /package/src/_api/generated/{cfg_accounts/core → core}/types.gen.ts +0 -0
- /package/src/_api/generated/{cfg_accounts/core → core}/utils.gen.ts +0 -0
- /package/src/_api/generated/{_shared → helpers}/errors.ts +0 -0
- /package/src/_api/generated/{_shared → helpers}/logger.ts +0 -0
- /package/src/_api/generated/{_shared → helpers}/storage.ts +0 -0
- /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 {
|
|
21
|
-
import { Accounts, Auth, UserProfile } from '../../_api/generated/
|
|
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/
|
|
30
|
-
import { PatchedCfgUserUpdateRequestSchema } from '../../_api/generated/
|
|
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/
|
|
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
|
-
|
|
163
|
-
|
|
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
|
-
|
|
180
|
-
|
|
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
|
-
|
|
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/
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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/
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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/
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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/
|
|
16
|
-
export type * as TotpTypes from './_api/generated/
|
|
17
|
-
export type * as CentrifugoTypes from './_api/generated/
|
|
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/
|
|
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 {
|
|
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/
|
|
21
|
-
export * as TotpFetchers from './_api/generated/
|
|
22
|
-
export * as CentrifugoFetchers from './_api/generated/
|
|
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/
|
|
26
|
-
export * as TotpSchemas from './_api/generated/
|
|
27
|
-
export * as CentrifugoSchemas from './_api/generated/
|
|
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/
|
|
31
|
-
export type * as TotpTypes from './_api/generated/
|
|
32
|
-
export type * as CentrifugoTypes from './_api/generated/
|
|
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,187 +0,0 @@
|
|
|
1
|
-
// AUTO-GENERATED by django_generator / ts_extras.wrapper
|
|
2
|
-
// Self-contained API wrapper for this group. DO NOT EDIT — re-run `make gen`.
|
|
3
|
-
|
|
4
|
-
import { client } from './client.gen';
|
|
5
|
-
import type { StorageAdapter } from '../_shared/storage';
|
|
6
|
-
import { LocalStorageAdapter } from '../_shared/storage';
|
|
7
|
-
import { APILogger, type LoggerConfig } from '../_shared/logger';
|
|
8
|
-
|
|
9
|
-
import { Cfg } from './sdk.gen';
|
|
10
|
-
import { Accounts } from './sdk.gen';
|
|
11
|
-
import { OAuth } from './sdk.gen';
|
|
12
|
-
import { UserProfile } from './sdk.gen';
|
|
13
|
-
import { Auth } from './sdk.gen';
|
|
14
|
-
import type { ZodTypeAny } from 'zod';
|
|
15
|
-
import {
|
|
16
|
-
AccountDeleteResponseSchema,
|
|
17
|
-
OAuthAuthorizeResponseSchema,
|
|
18
|
-
OAuthProvidersResponseSchema,
|
|
19
|
-
OAuthTokenResponseSchema,
|
|
20
|
-
OTPRequestResponseSchema,
|
|
21
|
-
OTPVerifyResponseSchema,
|
|
22
|
-
TokenRefreshSchema,
|
|
23
|
-
UserSchema,
|
|
24
|
-
} from './schemas';
|
|
25
|
-
import { dispatchValidationError } from '../_shared/validation-events';
|
|
26
|
-
|
|
27
|
-
const ACCESS_KEY = 'cfg.access_token';
|
|
28
|
-
const REFRESH_KEY = 'cfg.refresh_token';
|
|
29
|
-
|
|
30
|
-
interface ValidationRoute {
|
|
31
|
-
method: string;
|
|
32
|
-
re: RegExp;
|
|
33
|
-
schema: ZodTypeAny;
|
|
34
|
-
path: string;
|
|
35
|
-
}
|
|
36
|
-
const VALIDATION_ROUTES: ReadonlyArray<ValidationRoute> = [
|
|
37
|
-
{ method: 'POST', re: new RegExp('^/cfg/accounts/oauth/github/authorize/?$'), schema: OAuthAuthorizeResponseSchema, path: '/cfg/accounts/oauth/github/authorize/' },
|
|
38
|
-
{ method: 'POST', re: new RegExp('^/cfg/accounts/oauth/github/callback/?$'), schema: OAuthTokenResponseSchema, path: '/cfg/accounts/oauth/github/callback/' },
|
|
39
|
-
{ method: 'GET', re: new RegExp('^/cfg/accounts/oauth/providers/?$'), schema: OAuthProvidersResponseSchema, path: '/cfg/accounts/oauth/providers/' },
|
|
40
|
-
{ method: 'POST', re: new RegExp('^/cfg/accounts/otp/request/?$'), schema: OTPRequestResponseSchema, path: '/cfg/accounts/otp/request/' },
|
|
41
|
-
{ method: 'POST', re: new RegExp('^/cfg/accounts/otp/verify/?$'), schema: OTPVerifyResponseSchema, path: '/cfg/accounts/otp/verify/' },
|
|
42
|
-
{ method: 'GET', re: new RegExp('^/cfg/accounts/profile/?$'), schema: UserSchema, path: '/cfg/accounts/profile/' },
|
|
43
|
-
{ method: 'POST', re: new RegExp('^/cfg/accounts/profile/avatar/?$'), schema: UserSchema, path: '/cfg/accounts/profile/avatar/' },
|
|
44
|
-
{ method: 'POST', re: new RegExp('^/cfg/accounts/profile/delete/?$'), schema: AccountDeleteResponseSchema, path: '/cfg/accounts/profile/delete/' },
|
|
45
|
-
{ method: 'PUT', re: new RegExp('^/cfg/accounts/profile/partial/?$'), schema: UserSchema, path: '/cfg/accounts/profile/partial/' },
|
|
46
|
-
{ method: 'PATCH', re: new RegExp('^/cfg/accounts/profile/partial/?$'), schema: UserSchema, path: '/cfg/accounts/profile/partial/' },
|
|
47
|
-
{ method: 'PUT', re: new RegExp('^/cfg/accounts/profile/update/?$'), schema: UserSchema, path: '/cfg/accounts/profile/update/' },
|
|
48
|
-
{ method: 'PATCH', re: new RegExp('^/cfg/accounts/profile/update/?$'), schema: UserSchema, path: '/cfg/accounts/profile/update/' },
|
|
49
|
-
{ method: 'POST', re: new RegExp('^/cfg/accounts/token/refresh/?$'), schema: TokenRefreshSchema, path: '/cfg/accounts/token/refresh/' }
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
/** Auto-detect locale from cookie NEXT_LOCALE or navigator.language. */
|
|
53
|
-
function detectLocale(): string | null {
|
|
54
|
-
try {
|
|
55
|
-
if (typeof document !== 'undefined') {
|
|
56
|
-
const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
|
|
57
|
-
if (m) return decodeURIComponent(m[1]);
|
|
58
|
-
}
|
|
59
|
-
if (typeof navigator !== 'undefined' && navigator.language) {
|
|
60
|
-
return navigator.language;
|
|
61
|
-
}
|
|
62
|
-
} catch {}
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface APIOptions {
|
|
67
|
-
/** Override storage backend (LocalStorage by default; Memory for SSR/tests). */
|
|
68
|
-
storage?: StorageAdapter;
|
|
69
|
-
/** Logger config (defaults to dev-only). */
|
|
70
|
-
logger?: Partial<LoggerConfig>;
|
|
71
|
-
/** Locale for `Accept-Language`. If omitted, auto-detected from cookie/navigator. */
|
|
72
|
-
locale?: string;
|
|
73
|
-
/** API key sent as `X-API-Key`. Falls back to NEXT_PUBLIC_API_KEY. */
|
|
74
|
-
apiKey?: string;
|
|
75
|
-
/** Send Django session/CSRF cookies cross-origin. Defaults to true. */
|
|
76
|
-
withCredentials?: boolean;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Self-contained API wrapper for this group.
|
|
81
|
-
*
|
|
82
|
-
* Each group has its own client + interceptor + token store. The interceptor
|
|
83
|
-
* automatically attaches:
|
|
84
|
-
* - `Authorization: Bearer <jwt>` from storage
|
|
85
|
-
* - `Accept-Language` from `opts.locale` or `NEXT_LOCALE` cookie
|
|
86
|
-
* - `X-API-Key` from `opts.apiKey` or `NEXT_PUBLIC_API_KEY`
|
|
87
|
-
* - `credentials: 'include'` for Django session/CSRF cookies (toggle via opts)
|
|
88
|
-
*/
|
|
89
|
-
export class API {
|
|
90
|
-
private baseUrl: string;
|
|
91
|
-
private storage: StorageAdapter;
|
|
92
|
-
private locale: string | null;
|
|
93
|
-
private apiKey: string | null;
|
|
94
|
-
readonly logger: APILogger;
|
|
95
|
-
|
|
96
|
-
readonly cfg = Cfg;
|
|
97
|
-
readonly accounts = Accounts;
|
|
98
|
-
readonly oAuth = OAuth;
|
|
99
|
-
readonly userProfile = UserProfile;
|
|
100
|
-
readonly auth = Auth;
|
|
101
|
-
|
|
102
|
-
constructor(baseUrl: string, opts: APIOptions = {}) {
|
|
103
|
-
this.baseUrl = baseUrl.replace(/\/$/, '');
|
|
104
|
-
this.storage = opts.storage ?? new LocalStorageAdapter();
|
|
105
|
-
this.logger = new APILogger(opts.logger);
|
|
106
|
-
this.locale = opts.locale ?? null;
|
|
107
|
-
this.apiKey = opts.apiKey ?? (typeof process !== 'undefined' ? (process.env?.NEXT_PUBLIC_API_KEY ?? null) : null);
|
|
108
|
-
|
|
109
|
-
const credentials: RequestCredentials = (opts.withCredentials ?? true) ? 'include' : 'same-origin';
|
|
110
|
-
client.setConfig({ baseUrl: this.baseUrl, credentials });
|
|
111
|
-
|
|
112
|
-
client.interceptors.request.use((request) => {
|
|
113
|
-
const access = this.getToken();
|
|
114
|
-
if (access) request.headers.set('Authorization', `Bearer ${access}`);
|
|
115
|
-
|
|
116
|
-
const locale = this.locale ?? detectLocale();
|
|
117
|
-
if (locale) request.headers.set('Accept-Language', locale);
|
|
118
|
-
|
|
119
|
-
if (this.apiKey) request.headers.set('X-API-Key', this.apiKey);
|
|
120
|
-
|
|
121
|
-
return request;
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
client.interceptors.response.use(async (response, request) => {
|
|
125
|
-
if (!response.ok) return response;
|
|
126
|
-
const ct = response.headers.get('content-type') || '';
|
|
127
|
-
if (!ct.includes('application/json')) return response;
|
|
128
|
-
const url = new URL(request.url);
|
|
129
|
-
const method = request.method.toUpperCase();
|
|
130
|
-
const route = VALIDATION_ROUTES.find(
|
|
131
|
-
(r) => r.method === method && r.re.test(url.pathname),
|
|
132
|
-
);
|
|
133
|
-
if (!route) return response;
|
|
134
|
-
let payload: unknown;
|
|
135
|
-
try {
|
|
136
|
-
payload = await response.clone().json();
|
|
137
|
-
} catch {
|
|
138
|
-
return response;
|
|
139
|
-
}
|
|
140
|
-
const result = route.schema.safeParse(payload);
|
|
141
|
-
if (!result.success) {
|
|
142
|
-
dispatchValidationError({
|
|
143
|
-
operation: `${method} ${route.path}`,
|
|
144
|
-
path: route.path,
|
|
145
|
-
method,
|
|
146
|
-
error: result.error,
|
|
147
|
-
response: payload,
|
|
148
|
-
timestamp: new Date(),
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
return response;
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// ── Base URL ────────────────────────────────────────────────────────────
|
|
156
|
-
getBaseUrl(): string { return this.baseUrl; }
|
|
157
|
-
setBaseUrl(url: string): void {
|
|
158
|
-
this.baseUrl = url.replace(/\/$/, '');
|
|
159
|
-
client.setConfig({ baseUrl: this.baseUrl });
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// ── Tokens ──────────────────────────────────────────────────────────────
|
|
163
|
-
getToken(): string | null { return this.storage.getItem(ACCESS_KEY); }
|
|
164
|
-
setToken(token: string | null): void {
|
|
165
|
-
if (token) this.storage.setItem(ACCESS_KEY, token);
|
|
166
|
-
else this.storage.removeItem(ACCESS_KEY);
|
|
167
|
-
}
|
|
168
|
-
getRefreshToken(): string | null { return this.storage.getItem(REFRESH_KEY); }
|
|
169
|
-
setRefreshToken(token: string | null): void {
|
|
170
|
-
if (token) this.storage.setItem(REFRESH_KEY, token);
|
|
171
|
-
else this.storage.removeItem(REFRESH_KEY);
|
|
172
|
-
}
|
|
173
|
-
clearToken(): void {
|
|
174
|
-
this.storage.removeItem(ACCESS_KEY);
|
|
175
|
-
this.storage.removeItem(REFRESH_KEY);
|
|
176
|
-
}
|
|
177
|
-
isAuthenticated(): boolean { return this.getToken() !== null; }
|
|
178
|
-
|
|
179
|
-
// ── Locale / API key ────────────────────────────────────────────────────
|
|
180
|
-
getLocale(): string | null { return this.locale ?? detectLocale(); }
|
|
181
|
-
setLocale(locale: string | null): void { this.locale = locale; }
|
|
182
|
-
getApiKey(): string | null { return this.apiKey; }
|
|
183
|
-
setApiKey(key: string | null): void { this.apiKey = key; }
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
export { Cfg, Accounts, OAuth, UserProfile, Auth };
|
|
187
|
-
export { client };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
|
|
3
|
-
import { type ClientOptions, type Config, createClient, createConfig } from './client';
|
|
4
|
-
import type { ClientOptions as ClientOptions2 } from './types.gen';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The `createClientConfig()` function will be called on client initialization
|
|
8
|
-
* and the returned object will become the client's initial configuration.
|
|
9
|
-
*
|
|
10
|
-
* You may want to initialize your client this way instead of calling
|
|
11
|
-
* `setConfig()`. This is useful for example if you're using Next.js
|
|
12
|
-
* to ensure your client always has the correct values.
|
|
13
|
-
*/
|
|
14
|
-
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
|
|
15
|
-
|
|
16
|
-
export const client = createClient(createConfig<ClientOptions2>({ baseUrl: 'http://localhost:8000' }));
|