@djangocfg/api 2.1.191 → 2.1.193
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 +37 -3
- package/dist/auth-server.cjs.map +1 -1
- package/dist/auth-server.mjs +37 -3
- package/dist/auth-server.mjs.map +1 -1
- package/dist/auth.cjs +116 -6
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +4 -0
- package/dist/auth.d.ts +4 -0
- package/dist/auth.mjs +116 -6
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +107 -10
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +47 -0
- package/dist/clients.d.ts +47 -0
- package/dist/clients.mjs +107 -10
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +37 -3
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +20 -0
- package/dist/hooks.d.ts +20 -0
- package/dist/hooks.mjs +37 -3
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +69 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.mjs +69 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/auth/context/AuthContext.tsx +25 -1
- package/src/generated/cfg_accounts/_utils/fetchers/accounts.ts +1 -0
- package/src/generated/cfg_accounts/_utils/fetchers/accounts__auth.ts +1 -0
- package/src/generated/cfg_accounts/_utils/fetchers/accounts__oauth.ts +1 -0
- package/src/generated/cfg_accounts/_utils/fetchers/accounts__user_profile.ts +1 -0
- package/src/generated/cfg_accounts/_utils/fetchers/index.ts +1 -0
- package/src/generated/cfg_accounts/_utils/hooks/accounts.ts +1 -0
- package/src/generated/cfg_accounts/_utils/hooks/accounts__auth.ts +1 -0
- package/src/generated/cfg_accounts/_utils/hooks/accounts__oauth.ts +1 -0
- package/src/generated/cfg_accounts/_utils/hooks/accounts__user_profile.ts +1 -0
- package/src/generated/cfg_accounts/_utils/hooks/index.ts +1 -0
- package/src/generated/cfg_accounts/_utils/schemas/PatchedUserProfileUpdateRequest.schema.ts +1 -0
- package/src/generated/cfg_accounts/_utils/schemas/User.schema.ts +1 -0
- package/src/generated/cfg_accounts/_utils/schemas/UserProfileUpdateRequest.schema.ts +1 -0
- package/src/generated/cfg_accounts/_utils/schemas/index.ts +1 -0
- package/src/generated/cfg_accounts/accounts/client.ts +1 -0
- package/src/generated/cfg_accounts/accounts/index.ts +1 -0
- package/src/generated/cfg_accounts/accounts/models.ts +2 -0
- package/src/generated/cfg_accounts/accounts__auth/client.ts +1 -0
- package/src/generated/cfg_accounts/accounts__auth/index.ts +1 -0
- package/src/generated/cfg_accounts/accounts__auth/models.ts +1 -0
- package/src/generated/cfg_accounts/accounts__oauth/client.ts +1 -0
- package/src/generated/cfg_accounts/accounts__oauth/index.ts +1 -0
- package/src/generated/cfg_accounts/accounts__oauth/models.ts +1 -0
- package/src/generated/cfg_accounts/accounts__user_profile/client.ts +1 -0
- package/src/generated/cfg_accounts/accounts__user_profile/index.ts +1 -0
- package/src/generated/cfg_accounts/accounts__user_profile/models.ts +4 -0
- package/src/generated/cfg_accounts/api-instance.ts +1 -0
- package/src/generated/cfg_accounts/enums.ts +1 -0
- package/src/generated/cfg_accounts/errors.ts +1 -0
- package/src/generated/cfg_accounts/http.ts +1 -0
- package/src/generated/cfg_accounts/index.ts +37 -0
- package/src/generated/cfg_accounts/logger.ts +1 -0
- package/src/generated/cfg_accounts/retry.ts +1 -0
- package/src/generated/cfg_accounts/schema.json +12 -0
- package/src/generated/cfg_accounts/storage.ts +1 -0
- package/src/generated/cfg_accounts/validation-events.ts +1 -0
- package/src/generated/cfg_centrifugo/_utils/fetchers/centrifugo__centrifugo_admin_api.ts +1 -0
- package/src/generated/cfg_centrifugo/_utils/fetchers/centrifugo__centrifugo_auth.ts +1 -0
- package/src/generated/cfg_centrifugo/_utils/fetchers/centrifugo__centrifugo_monitoring.ts +1 -0
- package/src/generated/cfg_centrifugo/_utils/fetchers/centrifugo__centrifugo_testing.ts +1 -0
- package/src/generated/cfg_centrifugo/_utils/fetchers/index.ts +1 -0
- package/src/generated/cfg_centrifugo/_utils/hooks/centrifugo__centrifugo_admin_api.ts +1 -0
- package/src/generated/cfg_centrifugo/_utils/hooks/centrifugo__centrifugo_auth.ts +1 -0
- package/src/generated/cfg_centrifugo/_utils/hooks/centrifugo__centrifugo_monitoring.ts +5 -4
- package/src/generated/cfg_centrifugo/_utils/hooks/centrifugo__centrifugo_testing.ts +1 -0
- package/src/generated/cfg_centrifugo/_utils/hooks/index.ts +1 -0
- package/src/generated/cfg_centrifugo/_utils/schemas/index.ts +1 -0
- package/src/generated/cfg_centrifugo/api-instance.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_admin_api/client.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_admin_api/index.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_admin_api/models.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_auth/client.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_auth/index.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_auth/models.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_monitoring/client.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_monitoring/index.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_monitoring/models.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_testing/client.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_testing/index.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_testing/models.ts +1 -0
- package/src/generated/cfg_centrifugo/errors.ts +1 -0
- package/src/generated/cfg_centrifugo/http.ts +1 -0
- package/src/generated/cfg_centrifugo/index.ts +37 -0
- package/src/generated/cfg_centrifugo/logger.ts +1 -0
- package/src/generated/cfg_centrifugo/retry.ts +1 -0
- package/src/generated/cfg_centrifugo/storage.ts +1 -0
- package/src/generated/cfg_centrifugo/validation-events.ts +1 -0
- package/src/generated/cfg_totp/_utils/fetchers/index.ts +1 -0
- package/src/generated/cfg_totp/_utils/fetchers/totp.ts +1 -0
- package/src/generated/cfg_totp/_utils/fetchers/totp__backup_codes.ts +1 -0
- package/src/generated/cfg_totp/_utils/fetchers/totp__totp_management.ts +1 -0
- package/src/generated/cfg_totp/_utils/fetchers/totp__totp_setup.ts +1 -0
- package/src/generated/cfg_totp/_utils/fetchers/totp__totp_verification.ts +1 -0
- package/src/generated/cfg_totp/_utils/hooks/index.ts +1 -0
- package/src/generated/cfg_totp/_utils/hooks/totp.ts +1 -0
- package/src/generated/cfg_totp/_utils/hooks/totp__backup_codes.ts +1 -0
- package/src/generated/cfg_totp/_utils/hooks/totp__totp_management.ts +2 -1
- package/src/generated/cfg_totp/_utils/hooks/totp__totp_setup.ts +1 -0
- package/src/generated/cfg_totp/_utils/hooks/totp__totp_verification.ts +1 -0
- package/src/generated/cfg_totp/_utils/schemas/TotpVerifyUser.schema.ts +1 -0
- package/src/generated/cfg_totp/_utils/schemas/index.ts +1 -0
- package/src/generated/cfg_totp/api-instance.ts +1 -0
- package/src/generated/cfg_totp/enums.ts +1 -0
- package/src/generated/cfg_totp/errors.ts +1 -0
- package/src/generated/cfg_totp/http.ts +1 -0
- package/src/generated/cfg_totp/index.ts +37 -0
- package/src/generated/cfg_totp/logger.ts +1 -0
- package/src/generated/cfg_totp/retry.ts +1 -0
- package/src/generated/cfg_totp/schema.json +4 -0
- package/src/generated/cfg_totp/storage.ts +1 -0
- package/src/generated/cfg_totp/totp/client.ts +1 -0
- package/src/generated/cfg_totp/totp/index.ts +1 -0
- package/src/generated/cfg_totp/totp/models.ts +1 -0
- package/src/generated/cfg_totp/totp__backup_codes/client.ts +1 -0
- package/src/generated/cfg_totp/totp__backup_codes/index.ts +1 -0
- package/src/generated/cfg_totp/totp__backup_codes/models.ts +1 -0
- package/src/generated/cfg_totp/totp__totp_management/client.ts +1 -0
- package/src/generated/cfg_totp/totp__totp_management/index.ts +1 -0
- package/src/generated/cfg_totp/totp__totp_management/models.ts +1 -0
- package/src/generated/cfg_totp/totp__totp_setup/client.ts +1 -0
- package/src/generated/cfg_totp/totp__totp_setup/index.ts +1 -0
- package/src/generated/cfg_totp/totp__totp_setup/models.ts +1 -0
- package/src/generated/cfg_totp/totp__totp_verification/client.ts +1 -0
- package/src/generated/cfg_totp/totp__totp_verification/index.ts +1 -0
- package/src/generated/cfg_totp/totp__totp_verification/models.ts +2 -0
- package/src/generated/cfg_totp/validation-events.ts +1 -0
package/dist/auth.d.cts
CHANGED
|
@@ -118,6 +118,7 @@ declare const OTPVerifyResponseSchema: z.ZodObject<{
|
|
|
118
118
|
company: z.ZodOptional<z.ZodString>;
|
|
119
119
|
phone: z.ZodOptional<z.ZodString>;
|
|
120
120
|
position: z.ZodOptional<z.ZodString>;
|
|
121
|
+
language: z.ZodOptional<z.ZodString>;
|
|
121
122
|
avatar: z.ZodNullable<z.ZodUnion<readonly [z.ZodURL, z.ZodLiteral<"">]>>;
|
|
122
123
|
is_staff: z.ZodBoolean;
|
|
123
124
|
is_superuser: z.ZodBoolean;
|
|
@@ -154,6 +155,7 @@ declare const PatchedUserProfileUpdateRequestSchema: z.ZodObject<{
|
|
|
154
155
|
company: z.ZodOptional<z.ZodString>;
|
|
155
156
|
phone: z.ZodOptional<z.ZodString>;
|
|
156
157
|
position: z.ZodOptional<z.ZodString>;
|
|
158
|
+
language: z.ZodOptional<z.ZodString>;
|
|
157
159
|
}, z.core.$strip>;
|
|
158
160
|
/**
|
|
159
161
|
* Infer TypeScript type from Zod schema
|
|
@@ -196,6 +198,7 @@ declare const UserSchema: z.ZodObject<{
|
|
|
196
198
|
company: z.ZodOptional<z.ZodString>;
|
|
197
199
|
phone: z.ZodOptional<z.ZodString>;
|
|
198
200
|
position: z.ZodOptional<z.ZodString>;
|
|
201
|
+
language: z.ZodOptional<z.ZodString>;
|
|
199
202
|
avatar: z.ZodNullable<z.ZodUnion<readonly [z.ZodURL, z.ZodLiteral<"">]>>;
|
|
200
203
|
is_staff: z.ZodBoolean;
|
|
201
204
|
is_superuser: z.ZodBoolean;
|
|
@@ -230,6 +233,7 @@ declare const UserProfileUpdateRequestSchema: z.ZodObject<{
|
|
|
230
233
|
company: z.ZodOptional<z.ZodString>;
|
|
231
234
|
phone: z.ZodOptional<z.ZodString>;
|
|
232
235
|
position: z.ZodOptional<z.ZodString>;
|
|
236
|
+
language: z.ZodOptional<z.ZodString>;
|
|
233
237
|
}, z.core.$strip>;
|
|
234
238
|
/**
|
|
235
239
|
* Infer TypeScript type from Zod schema
|
package/dist/auth.d.ts
CHANGED
|
@@ -118,6 +118,7 @@ declare const OTPVerifyResponseSchema: z.ZodObject<{
|
|
|
118
118
|
company: z.ZodOptional<z.ZodString>;
|
|
119
119
|
phone: z.ZodOptional<z.ZodString>;
|
|
120
120
|
position: z.ZodOptional<z.ZodString>;
|
|
121
|
+
language: z.ZodOptional<z.ZodString>;
|
|
121
122
|
avatar: z.ZodNullable<z.ZodUnion<readonly [z.ZodURL, z.ZodLiteral<"">]>>;
|
|
122
123
|
is_staff: z.ZodBoolean;
|
|
123
124
|
is_superuser: z.ZodBoolean;
|
|
@@ -154,6 +155,7 @@ declare const PatchedUserProfileUpdateRequestSchema: z.ZodObject<{
|
|
|
154
155
|
company: z.ZodOptional<z.ZodString>;
|
|
155
156
|
phone: z.ZodOptional<z.ZodString>;
|
|
156
157
|
position: z.ZodOptional<z.ZodString>;
|
|
158
|
+
language: z.ZodOptional<z.ZodString>;
|
|
157
159
|
}, z.core.$strip>;
|
|
158
160
|
/**
|
|
159
161
|
* Infer TypeScript type from Zod schema
|
|
@@ -196,6 +198,7 @@ declare const UserSchema: z.ZodObject<{
|
|
|
196
198
|
company: z.ZodOptional<z.ZodString>;
|
|
197
199
|
phone: z.ZodOptional<z.ZodString>;
|
|
198
200
|
position: z.ZodOptional<z.ZodString>;
|
|
201
|
+
language: z.ZodOptional<z.ZodString>;
|
|
199
202
|
avatar: z.ZodNullable<z.ZodUnion<readonly [z.ZodURL, z.ZodLiteral<"">]>>;
|
|
200
203
|
is_staff: z.ZodBoolean;
|
|
201
204
|
is_superuser: z.ZodBoolean;
|
|
@@ -230,6 +233,7 @@ declare const UserProfileUpdateRequestSchema: z.ZodObject<{
|
|
|
230
233
|
company: z.ZodOptional<z.ZodString>;
|
|
231
234
|
phone: z.ZodOptional<z.ZodString>;
|
|
232
235
|
position: z.ZodOptional<z.ZodString>;
|
|
236
|
+
language: z.ZodOptional<z.ZodString>;
|
|
233
237
|
}, z.core.$strip>;
|
|
234
238
|
/**
|
|
235
239
|
* Infer TypeScript type from Zod schema
|
package/dist/auth.mjs
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
useRef as useRef5,
|
|
18
18
|
useState as useState12
|
|
19
19
|
} from "react";
|
|
20
|
+
import { SWRConfig } from "swr";
|
|
20
21
|
|
|
21
22
|
// src/auth/hooks/useCfgRouter.ts
|
|
22
23
|
import { useRouter as useNextRouter } from "next/navigation";
|
|
@@ -1214,6 +1215,7 @@ var UserSchema = z16.object({
|
|
|
1214
1215
|
company: z16.string().max(100).optional(),
|
|
1215
1216
|
phone: z16.string().max(20).optional(),
|
|
1216
1217
|
position: z16.string().max(100).optional(),
|
|
1218
|
+
language: z16.string().max(10).optional(),
|
|
1217
1219
|
avatar: z16.union([z16.url(), z16.literal("")]).nullable(),
|
|
1218
1220
|
is_staff: z16.boolean(),
|
|
1219
1221
|
is_superuser: z16.boolean(),
|
|
@@ -1240,7 +1242,8 @@ var PatchedUserProfileUpdateRequestSchema = z18.object({
|
|
|
1240
1242
|
last_name: z18.string().max(50).optional(),
|
|
1241
1243
|
company: z18.string().max(100).optional(),
|
|
1242
1244
|
phone: z18.string().max(20).optional(),
|
|
1243
|
-
position: z18.string().max(100).optional()
|
|
1245
|
+
position: z18.string().max(100).optional(),
|
|
1246
|
+
language: z18.string().max(10).optional()
|
|
1244
1247
|
});
|
|
1245
1248
|
|
|
1246
1249
|
// src/generated/cfg_accounts/_utils/schemas/TokenRefresh.schema.ts
|
|
@@ -1263,7 +1266,8 @@ var UserProfileUpdateRequestSchema = z21.object({
|
|
|
1263
1266
|
last_name: z21.string().max(50).optional(),
|
|
1264
1267
|
company: z21.string().max(100).optional(),
|
|
1265
1268
|
phone: z21.string().max(20).optional(),
|
|
1266
|
-
position: z21.string().max(100).optional()
|
|
1269
|
+
position: z21.string().max(100).optional(),
|
|
1270
|
+
language: z21.string().max(10).optional()
|
|
1267
1271
|
});
|
|
1268
1272
|
|
|
1269
1273
|
// src/generated/cfg_accounts/_utils/fetchers/accounts.ts
|
|
@@ -1609,14 +1613,30 @@ __name(updateAccountsProfileUpdateUpdate, "updateAccountsProfileUpdateUpdate");
|
|
|
1609
1613
|
// src/generated/cfg_accounts/index.ts
|
|
1610
1614
|
var TOKEN_KEY = "auth_token";
|
|
1611
1615
|
var REFRESH_TOKEN_KEY = "refresh_token";
|
|
1616
|
+
function detectLocale() {
|
|
1617
|
+
try {
|
|
1618
|
+
if (typeof document !== "undefined") {
|
|
1619
|
+
const match = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
|
|
1620
|
+
if (match) return match[1];
|
|
1621
|
+
}
|
|
1622
|
+
if (typeof navigator !== "undefined" && navigator.language) {
|
|
1623
|
+
return navigator.language;
|
|
1624
|
+
}
|
|
1625
|
+
} catch {
|
|
1626
|
+
}
|
|
1627
|
+
return null;
|
|
1628
|
+
}
|
|
1629
|
+
__name(detectLocale, "detectLocale");
|
|
1612
1630
|
var API = class {
|
|
1613
1631
|
constructor(baseUrl, options) {
|
|
1614
1632
|
this._token = null;
|
|
1615
1633
|
this._refreshToken = null;
|
|
1634
|
+
this._locale = null;
|
|
1616
1635
|
this.baseUrl = baseUrl;
|
|
1617
1636
|
this.options = options;
|
|
1618
1637
|
const logger2 = options?.loggerConfig ? new APILogger(options.loggerConfig) : void 0;
|
|
1619
1638
|
this.storage = options?.storage || new LocalStorageAdapter(logger2);
|
|
1639
|
+
this._locale = options?.locale || null;
|
|
1620
1640
|
this._loadTokensFromStorage();
|
|
1621
1641
|
this._client = new APIClient(this.baseUrl, {
|
|
1622
1642
|
retryConfig: this.options?.retryConfig,
|
|
@@ -1652,11 +1672,13 @@ var API = class {
|
|
|
1652
1672
|
const originalRequest = this._client.request.bind(this._client);
|
|
1653
1673
|
this._client.request = async (method, path, options) => {
|
|
1654
1674
|
const token = this.getToken();
|
|
1675
|
+
const locale = this._locale || detectLocale();
|
|
1655
1676
|
const mergedOptions = {
|
|
1656
1677
|
...options,
|
|
1657
1678
|
headers: {
|
|
1658
1679
|
...options?.headers || {},
|
|
1659
|
-
...token ? { "Authorization": `Bearer ${token}` } : {}
|
|
1680
|
+
...token ? { "Authorization": `Bearer ${token}` } : {},
|
|
1681
|
+
...locale ? { "Accept-Language": locale } : {}
|
|
1660
1682
|
}
|
|
1661
1683
|
};
|
|
1662
1684
|
return originalRequest(method, path, mergedOptions);
|
|
@@ -1718,6 +1740,19 @@ var API = class {
|
|
|
1718
1740
|
getBaseUrl() {
|
|
1719
1741
|
return this.baseUrl;
|
|
1720
1742
|
}
|
|
1743
|
+
/**
|
|
1744
|
+
* Set locale for Accept-Language header
|
|
1745
|
+
* @param locale - Locale string (e.g. 'en', 'ko', 'ru') or null to clear
|
|
1746
|
+
*/
|
|
1747
|
+
setLocale(locale) {
|
|
1748
|
+
this._locale = locale;
|
|
1749
|
+
}
|
|
1750
|
+
/**
|
|
1751
|
+
* Get current locale
|
|
1752
|
+
*/
|
|
1753
|
+
getLocale() {
|
|
1754
|
+
return this._locale;
|
|
1755
|
+
}
|
|
1721
1756
|
/**
|
|
1722
1757
|
* Get OpenAPI schema path
|
|
1723
1758
|
* @returns Path to the OpenAPI schema JSON file
|
|
@@ -2899,14 +2934,30 @@ import { consola as consola8 } from "consola";
|
|
|
2899
2934
|
// src/generated/cfg_centrifugo/index.ts
|
|
2900
2935
|
var TOKEN_KEY2 = "auth_token";
|
|
2901
2936
|
var REFRESH_TOKEN_KEY2 = "refresh_token";
|
|
2937
|
+
function detectLocale2() {
|
|
2938
|
+
try {
|
|
2939
|
+
if (typeof document !== "undefined") {
|
|
2940
|
+
const match = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
|
|
2941
|
+
if (match) return match[1];
|
|
2942
|
+
}
|
|
2943
|
+
if (typeof navigator !== "undefined" && navigator.language) {
|
|
2944
|
+
return navigator.language;
|
|
2945
|
+
}
|
|
2946
|
+
} catch {
|
|
2947
|
+
}
|
|
2948
|
+
return null;
|
|
2949
|
+
}
|
|
2950
|
+
__name(detectLocale2, "detectLocale");
|
|
2902
2951
|
var API2 = class {
|
|
2903
2952
|
constructor(baseUrl, options) {
|
|
2904
2953
|
this._token = null;
|
|
2905
2954
|
this._refreshToken = null;
|
|
2955
|
+
this._locale = null;
|
|
2906
2956
|
this.baseUrl = baseUrl;
|
|
2907
2957
|
this.options = options;
|
|
2908
2958
|
const logger2 = options?.loggerConfig ? new APILogger2(options.loggerConfig) : void 0;
|
|
2909
2959
|
this.storage = options?.storage || new LocalStorageAdapter2(logger2);
|
|
2960
|
+
this._locale = options?.locale || null;
|
|
2910
2961
|
this._loadTokensFromStorage();
|
|
2911
2962
|
this._client = new APIClient2(this.baseUrl, {
|
|
2912
2963
|
retryConfig: this.options?.retryConfig,
|
|
@@ -2942,11 +2993,13 @@ var API2 = class {
|
|
|
2942
2993
|
const originalRequest = this._client.request.bind(this._client);
|
|
2943
2994
|
this._client.request = async (method, path, options) => {
|
|
2944
2995
|
const token = this.getToken();
|
|
2996
|
+
const locale = this._locale || detectLocale2();
|
|
2945
2997
|
const mergedOptions = {
|
|
2946
2998
|
...options,
|
|
2947
2999
|
headers: {
|
|
2948
3000
|
...options?.headers || {},
|
|
2949
|
-
...token ? { "Authorization": `Bearer ${token}` } : {}
|
|
3001
|
+
...token ? { "Authorization": `Bearer ${token}` } : {},
|
|
3002
|
+
...locale ? { "Accept-Language": locale } : {}
|
|
2950
3003
|
}
|
|
2951
3004
|
};
|
|
2952
3005
|
return originalRequest(method, path, mergedOptions);
|
|
@@ -3008,6 +3061,19 @@ var API2 = class {
|
|
|
3008
3061
|
getBaseUrl() {
|
|
3009
3062
|
return this.baseUrl;
|
|
3010
3063
|
}
|
|
3064
|
+
/**
|
|
3065
|
+
* Set locale for Accept-Language header
|
|
3066
|
+
* @param locale - Locale string (e.g. 'en', 'ko', 'ru') or null to clear
|
|
3067
|
+
*/
|
|
3068
|
+
setLocale(locale) {
|
|
3069
|
+
this._locale = locale;
|
|
3070
|
+
}
|
|
3071
|
+
/**
|
|
3072
|
+
* Get current locale
|
|
3073
|
+
*/
|
|
3074
|
+
getLocale() {
|
|
3075
|
+
return this._locale;
|
|
3076
|
+
}
|
|
3011
3077
|
/**
|
|
3012
3078
|
* Get OpenAPI schema path
|
|
3013
3079
|
* @returns Path to the OpenAPI schema JSON file
|
|
@@ -3886,6 +3952,7 @@ var TotpVerifyUserSchema = z68.object({
|
|
|
3886
3952
|
company: z68.string().max(100).optional(),
|
|
3887
3953
|
phone: z68.string().max(20).optional(),
|
|
3888
3954
|
position: z68.string().max(100).optional(),
|
|
3955
|
+
language: z68.string().max(10).optional(),
|
|
3889
3956
|
avatar: z68.union([z68.url(), z68.literal("")]).nullable(),
|
|
3890
3957
|
is_staff: z68.boolean(),
|
|
3891
3958
|
is_superuser: z68.boolean(),
|
|
@@ -3934,14 +4001,30 @@ import { consola as consola12 } from "consola";
|
|
|
3934
4001
|
// src/generated/cfg_totp/index.ts
|
|
3935
4002
|
var TOKEN_KEY3 = "auth_token";
|
|
3936
4003
|
var REFRESH_TOKEN_KEY3 = "refresh_token";
|
|
4004
|
+
function detectLocale3() {
|
|
4005
|
+
try {
|
|
4006
|
+
if (typeof document !== "undefined") {
|
|
4007
|
+
const match = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
|
|
4008
|
+
if (match) return match[1];
|
|
4009
|
+
}
|
|
4010
|
+
if (typeof navigator !== "undefined" && navigator.language) {
|
|
4011
|
+
return navigator.language;
|
|
4012
|
+
}
|
|
4013
|
+
} catch {
|
|
4014
|
+
}
|
|
4015
|
+
return null;
|
|
4016
|
+
}
|
|
4017
|
+
__name(detectLocale3, "detectLocale");
|
|
3937
4018
|
var API3 = class {
|
|
3938
4019
|
constructor(baseUrl, options) {
|
|
3939
4020
|
this._token = null;
|
|
3940
4021
|
this._refreshToken = null;
|
|
4022
|
+
this._locale = null;
|
|
3941
4023
|
this.baseUrl = baseUrl;
|
|
3942
4024
|
this.options = options;
|
|
3943
4025
|
const logger2 = options?.loggerConfig ? new APILogger3(options.loggerConfig) : void 0;
|
|
3944
4026
|
this.storage = options?.storage || new LocalStorageAdapter3(logger2);
|
|
4027
|
+
this._locale = options?.locale || null;
|
|
3945
4028
|
this._loadTokensFromStorage();
|
|
3946
4029
|
this._client = new APIClient3(this.baseUrl, {
|
|
3947
4030
|
retryConfig: this.options?.retryConfig,
|
|
@@ -3979,11 +4062,13 @@ var API3 = class {
|
|
|
3979
4062
|
const originalRequest = this._client.request.bind(this._client);
|
|
3980
4063
|
this._client.request = async (method, path, options) => {
|
|
3981
4064
|
const token = this.getToken();
|
|
4065
|
+
const locale = this._locale || detectLocale3();
|
|
3982
4066
|
const mergedOptions = {
|
|
3983
4067
|
...options,
|
|
3984
4068
|
headers: {
|
|
3985
4069
|
...options?.headers || {},
|
|
3986
|
-
...token ? { "Authorization": `Bearer ${token}` } : {}
|
|
4070
|
+
...token ? { "Authorization": `Bearer ${token}` } : {},
|
|
4071
|
+
...locale ? { "Accept-Language": locale } : {}
|
|
3987
4072
|
}
|
|
3988
4073
|
};
|
|
3989
4074
|
return originalRequest(method, path, mergedOptions);
|
|
@@ -4045,6 +4130,19 @@ var API3 = class {
|
|
|
4045
4130
|
getBaseUrl() {
|
|
4046
4131
|
return this.baseUrl;
|
|
4047
4132
|
}
|
|
4133
|
+
/**
|
|
4134
|
+
* Set locale for Accept-Language header
|
|
4135
|
+
* @param locale - Locale string (e.g. 'en', 'ko', 'ru') or null to clear
|
|
4136
|
+
*/
|
|
4137
|
+
setLocale(locale) {
|
|
4138
|
+
this._locale = locale;
|
|
4139
|
+
}
|
|
4140
|
+
/**
|
|
4141
|
+
* Get current locale
|
|
4142
|
+
*/
|
|
4143
|
+
getLocale() {
|
|
4144
|
+
return this._locale;
|
|
4145
|
+
}
|
|
4048
4146
|
/**
|
|
4049
4147
|
* Get OpenAPI schema path
|
|
4050
4148
|
* @returns Path to the OpenAPI schema JSON file
|
|
@@ -5784,6 +5882,18 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
5784
5882
|
}
|
|
5785
5883
|
return false;
|
|
5786
5884
|
}, [clearAuthState]);
|
|
5885
|
+
const isAutoLoggingOutRef = useRef5(false);
|
|
5886
|
+
const swrOnError = useCallback12((error) => {
|
|
5887
|
+
const isAuthError = error?.status === 401 || error?.statusCode === 401 || error?.code === "token_not_valid" || error?.code === "authentication_failed";
|
|
5888
|
+
if (isAuthError && !isAutoLoggingOutRef.current) {
|
|
5889
|
+
isAutoLoggingOutRef.current = true;
|
|
5890
|
+
authLogger.warn("SWR 401 error detected, auto-logout");
|
|
5891
|
+
clearAuthState("swrOnError:401");
|
|
5892
|
+
const authCallbackUrl = configRef.current?.routes?.defaultAuthCallback || defaultRoutes.defaultAuthCallback;
|
|
5893
|
+
router.hardReplace(authCallbackUrl);
|
|
5894
|
+
}
|
|
5895
|
+
}, [clearAuthState, router]);
|
|
5896
|
+
const swrConfig = useMemo2(() => ({ onError: swrOnError }), [swrOnError]);
|
|
5787
5897
|
const loadCurrentProfile = useCallback12(async (callerId) => {
|
|
5788
5898
|
const finalCallerId = callerId || "AuthContext.loadCurrentProfile";
|
|
5789
5899
|
if (isLoadingProfileRef.current) {
|
|
@@ -6128,7 +6238,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
6128
6238
|
uploadAvatar
|
|
6129
6239
|
]
|
|
6130
6240
|
);
|
|
6131
|
-
return /* @__PURE__ */ jsx2(AuthContext.Provider, { value, children });
|
|
6241
|
+
return /* @__PURE__ */ jsx2(AuthContext.Provider, { value, children: /* @__PURE__ */ jsx2(SWRConfig, { value: swrConfig, children }) });
|
|
6132
6242
|
}, "AuthProviderInternal");
|
|
6133
6243
|
var AuthProvider = /* @__PURE__ */ __name(({ children, config }) => {
|
|
6134
6244
|
return /* @__PURE__ */ jsx2(AccountsProvider, { children: /* @__PURE__ */ jsx2(AuthProviderInternal, { config, children }) });
|