@djangocfg/api 2.1.541 → 2.1.543
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/README.md +1 -2
- package/dist/auth-server.cjs +1 -0
- package/dist/auth-server.cjs.map +1 -1
- package/dist/auth.cjs +156 -170
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +134 -29
- package/dist/auth.d.ts +134 -29
- package/dist/auth.mjs +168 -183
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +4 -99
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +4 -136
- package/dist/clients.d.ts +4 -136
- package/dist/clients.mjs +3 -99
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +1 -0
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +2 -4
- package/dist/hooks.d.ts +2 -4
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +4 -100
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -340
- package/dist/index.d.ts +10 -340
- package/dist/index.mjs +3 -100
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRetrieve.ts +8 -2
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthConnectionsList.ts +8 -2
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthProvidersRetrieve.ts +8 -2
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpConsentPolicyRetrieve.ts +8 -2
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileRetrieve.ts +8 -2
- package/src/_api/generated/_cfg_accounts/openapi.json +0 -45
- package/src/_api/generated/_cfg_accounts/schemas/User.ts +0 -2
- package/src/_api/generated/_cfg_accounts/schemas/index.ts +0 -1
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRetrieve.ts +8 -2
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesRetrieve.ts +8 -2
- package/src/_api/generated/index.ts +1 -5
- package/src/_api/generated/openapi.json +0 -135
- package/src/_api/generated/sdk.gen.ts +1 -20
- package/src/_api/generated/types.gen.ts +0 -79
- package/src/_api/index.ts +1 -1
- package/src/auth/__tests__/useTwoFactorStatus.test.ts +2 -2
- package/src/auth/context/AccountsContext.tsx +15 -11
- package/src/auth/hooks/useAuthForm.ts +0 -1
- package/src/auth/hooks/useCfgRouter.ts +1 -4
- package/src/auth/hooks/useGithubAuth.ts +25 -3
- package/src/auth/hooks/useLocalStorage.ts +7 -30
- package/src/auth/hooks/useSessionStorage.ts +6 -29
- package/src/auth/hooks/useTwoFactorVerify.ts +5 -9
- package/src/auth/utils/analytics.ts +22 -2
- package/src/auth/utils/errors.ts +22 -11
- package/src/auth/utils/storage.ts +64 -0
- package/src/clients.ts +2 -4
- package/src/index.ts +0 -2
- package/src/log-control.ts +1 -1
- package/src/server.ts +0 -4
- package/src/_api/generated/_cfg_accounts/schemas/CentrifugoToken.ts +0 -14
- package/src/_api/generated/_cfg_centrifugo/api.ts +0 -87
- package/src/_api/generated/_cfg_centrifugo/hooks/index.ts +0 -4
- package/src/_api/generated/_cfg_centrifugo/hooks/useCfgCentrifugoAuthTokenRetrieve.ts +0 -74
- package/src/_api/generated/_cfg_centrifugo/index.ts +0 -29
- package/src/_api/generated/_cfg_centrifugo/openapi.json +0 -136
- package/src/_api/generated/_cfg_centrifugo/schemas/ConnectionTokenResponse.ts +0 -14
- package/src/_api/generated/_cfg_centrifugo/schemas/index.ts +0 -4
- package/src/_api/generated/_cfg_centrifugo/sdk.gen.ts +0 -5
- package/src/_api/generated/_cfg_centrifugo/types.gen.ts +0 -5
package/README.md
CHANGED
|
@@ -32,7 +32,6 @@ import {
|
|
|
32
32
|
CfgTotpSetup, // TOTP setup / confirm
|
|
33
33
|
CfgTotpVerify, // TOTP verify / backup
|
|
34
34
|
CfgTotpBackupCodes, // Backup codes
|
|
35
|
-
CfgCentrifugo, // Centrifugo token
|
|
36
35
|
} from '@djangocfg/api';
|
|
37
36
|
|
|
38
37
|
// OTP login
|
|
@@ -137,7 +136,7 @@ import { isDev, isProd, isBrowser, isStaticBuild, dpopEnabled } from '@djangocfg
|
|
|
137
136
|
## Type Namespaces
|
|
138
137
|
|
|
139
138
|
```typescript
|
|
140
|
-
import type { AccountsTypes, TotpTypes
|
|
139
|
+
import type { AccountsTypes, TotpTypes } from '@djangocfg/api';
|
|
141
140
|
|
|
142
141
|
type User = AccountsTypes.User;
|
|
143
142
|
type Device = TotpTypes.TotpDevice;
|
package/dist/auth-server.cjs
CHANGED
package/dist/auth-server.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/auth/server.ts","../src/auth/middlewares/proxy.ts"],"sourcesContent":["/**\n * @djangocfg/api/auth/server\n *\n * Server-side authentication utilities.\n * Use this entry point in server components, API routes, and middleware.\n *\n * @example\n * ```typescript\n * // middleware.ts\n * import { proxyMiddleware } from '@djangocfg/api/auth/server';\n *\n * export function middleware(request: NextRequest) {\n * return proxyMiddleware(request);\n * }\n * ```\n */\n\n// Middlewares\nexport * from './middlewares';\n","import { NextRequest, NextResponse } from 'next/server';\n\n/**\n * Proxy middleware for media and API endpoints\n * Use this in your middleware.ts file\n */\nexport function proxyMiddleware(request: NextRequest) {\n const { pathname, search } = request.nextUrl;\n const apiUrl = process.env.NEXT_PUBLIC_API_URL;\n\n // Proxy /media/* - Images and static files\n if (pathname.startsWith('/media/')) {\n const targetUrl = `${apiUrl}${pathname}${search}`;\n return NextResponse.rewrite(targetUrl, { request: { headers: request.headers } });\n }\n\n // Proxy /api/* - API endpoints\n if (pathname.startsWith('/api/')) {\n const targetUrl = `${apiUrl}${pathname}${search}`;\n return NextResponse.rewrite(targetUrl, { request: { headers: request.headers } });\n }\n\n return NextResponse.next();\n}\n\n/**\n * Recommended matcher config for proxy middleware\n * Add this to your middleware.ts config\n */\nexport const proxyMiddlewareConfig = {\n matcher: ['/media/:path*', '/api/:path*'],\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/auth/server.ts","../src/auth/middlewares/proxy.ts"],"sourcesContent":["/**\n * @djangocfg/api/auth/server\n *\n * Server-side authentication utilities.\n * Use this entry point in server components, API routes, and middleware.\n *\n * @example\n * ```typescript\n * // middleware.ts\n * import { proxyMiddleware } from '@djangocfg/api/auth/server';\n *\n * export function middleware(request: NextRequest) {\n * return proxyMiddleware(request);\n * }\n * ```\n */\n\n// Middlewares\nexport * from './middlewares';\n","import { NextRequest, NextResponse } from 'next/server';\n\n/**\n * Proxy middleware for media and API endpoints\n * Use this in your middleware.ts file\n */\nexport function proxyMiddleware(request: NextRequest) {\n const { pathname, search } = request.nextUrl;\n const apiUrl = process.env.NEXT_PUBLIC_API_URL;\n\n // Proxy /media/* - Images and static files\n if (pathname.startsWith('/media/')) {\n const targetUrl = `${apiUrl}${pathname}${search}`;\n return NextResponse.rewrite(targetUrl, { request: { headers: request.headers } });\n }\n\n // Proxy /api/* - API endpoints\n if (pathname.startsWith('/api/')) {\n const targetUrl = `${apiUrl}${pathname}${search}`;\n return NextResponse.rewrite(targetUrl, { request: { headers: request.headers } });\n }\n\n return NextResponse.next();\n}\n\n/**\n * Recommended matcher config for proxy middleware\n * Add this to your middleware.ts config\n */\nexport const proxyMiddlewareConfig = {\n matcher: ['/media/:path*', '/api/:path*'],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAA0C;AAMnC,SAAS,gBAAgB,SAAsB;AACpD,QAAM,EAAE,UAAU,OAAO,IAAI,QAAQ;AACrC,QAAM,SAAS,QAAQ,IAAI;AAG3B,MAAI,SAAS,WAAW,SAAS,GAAG;AAClC,UAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM;AAC/C,WAAO,2BAAa,QAAQ,WAAW,EAAE,SAAS,EAAE,SAAS,QAAQ,QAAQ,EAAE,CAAC;AAAA,EAClF;AAGA,MAAI,SAAS,WAAW,OAAO,GAAG;AAChC,UAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM;AAC/C,WAAO,2BAAa,QAAQ,WAAW,EAAE,SAAS,EAAE,SAAS,QAAQ,QAAQ,EAAE,CAAC;AAAA,EAClF;AAEA,SAAO,2BAAa,KAAK;AAC3B;AAjBgB;AAuBT,IAAM,wBAAwB;AAAA,EACnC,SAAS,CAAC,iBAAiB,aAAa;AAC1C;","names":[]}
|
package/dist/auth.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
"use strict";
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -943,9 +944,6 @@ __name(withBasePath, "withBasePath");
|
|
|
943
944
|
function useCfgRouter() {
|
|
944
945
|
const router = (0, import_navigation.useRouter)();
|
|
945
946
|
const basePath = (0, import_react2.useMemo)(() => getBasePath(), []);
|
|
946
|
-
const isStaticBuild2 = (0, import_react2.useMemo)(() => {
|
|
947
|
-
return typeof process !== "undefined" && process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
|
|
948
|
-
}, []);
|
|
949
947
|
const push = (0, import_react2.useCallback)((href, options) => {
|
|
950
948
|
if (basePath) {
|
|
951
949
|
window.location.href = withBasePath(href, basePath);
|
|
@@ -2542,6 +2540,33 @@ var Analytics = {
|
|
|
2542
2540
|
|
|
2543
2541
|
// src/auth/hooks/useSessionStorage.ts
|
|
2544
2542
|
var import_react7 = require("react");
|
|
2543
|
+
|
|
2544
|
+
// src/auth/utils/storage.ts
|
|
2545
|
+
var MAX_ITEM_KB = 1024;
|
|
2546
|
+
function isQuotaExceededError(error) {
|
|
2547
|
+
if (typeof error !== "object" || error === null) return false;
|
|
2548
|
+
const { name, code, message } = error;
|
|
2549
|
+
return name === "QuotaExceededError" || code === 22 || typeof message === "string" && message.includes("quota");
|
|
2550
|
+
}
|
|
2551
|
+
__name(isQuotaExceededError, "isQuotaExceededError");
|
|
2552
|
+
function isWithinSizeLimit(data, key) {
|
|
2553
|
+
try {
|
|
2554
|
+
const sizeInKB = new Blob([JSON.stringify(data)]).size / 1024;
|
|
2555
|
+
if (sizeInKB > MAX_ITEM_KB) {
|
|
2556
|
+
authLogger.warn(
|
|
2557
|
+
`Data size (${sizeInKB.toFixed(2)}KB) exceeds 1MB limit for key "${key}"`
|
|
2558
|
+
);
|
|
2559
|
+
return false;
|
|
2560
|
+
}
|
|
2561
|
+
return true;
|
|
2562
|
+
} catch (error) {
|
|
2563
|
+
authLogger.error(`Error checking data size for key "${key}":`, error);
|
|
2564
|
+
return false;
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
__name(isWithinSizeLimit, "isWithinSizeLimit");
|
|
2568
|
+
|
|
2569
|
+
// src/auth/hooks/useSessionStorage.ts
|
|
2545
2570
|
function useSessionStorage(key, initialValue) {
|
|
2546
2571
|
const [storedValue, setStoredValue] = (0, import_react7.useState)(() => {
|
|
2547
2572
|
if (typeof window === "undefined") {
|
|
@@ -2555,21 +2580,6 @@ function useSessionStorage(key, initialValue) {
|
|
|
2555
2580
|
return initialValue;
|
|
2556
2581
|
}
|
|
2557
2582
|
});
|
|
2558
|
-
const checkDataSize = /* @__PURE__ */ __name((data) => {
|
|
2559
|
-
try {
|
|
2560
|
-
const jsonString = JSON.stringify(data);
|
|
2561
|
-
const sizeInBytes = new Blob([jsonString]).size;
|
|
2562
|
-
const sizeInKB = sizeInBytes / 1024;
|
|
2563
|
-
if (sizeInKB > 1024) {
|
|
2564
|
-
authLogger.warn(`Data size (${sizeInKB.toFixed(2)}KB) exceeds 1MB limit for key "${key}"`);
|
|
2565
|
-
return false;
|
|
2566
|
-
}
|
|
2567
|
-
return true;
|
|
2568
|
-
} catch (error) {
|
|
2569
|
-
authLogger.error(`Error checking data size for key "${key}":`, error);
|
|
2570
|
-
return false;
|
|
2571
|
-
}
|
|
2572
|
-
}, "checkDataSize");
|
|
2573
2583
|
const clearOldData = /* @__PURE__ */ __name(() => {
|
|
2574
2584
|
try {
|
|
2575
2585
|
const keys = Object.keys(sessionStorage).filter((key2) => key2 && typeof key2 === "string");
|
|
@@ -2606,7 +2616,7 @@ function useSessionStorage(key, initialValue) {
|
|
|
2606
2616
|
const setValue = /* @__PURE__ */ __name((value) => {
|
|
2607
2617
|
try {
|
|
2608
2618
|
const valueToStore = value instanceof Function ? value(storedValue) : value;
|
|
2609
|
-
if (!
|
|
2619
|
+
if (!isWithinSizeLimit(valueToStore, key)) {
|
|
2610
2620
|
authLogger.warn(`Data size too large for key "${key}", removing key`);
|
|
2611
2621
|
try {
|
|
2612
2622
|
window.sessionStorage.removeItem(key);
|
|
@@ -2622,7 +2632,7 @@ function useSessionStorage(key, initialValue) {
|
|
|
2622
2632
|
window.sessionStorage.setItem(key, JSON.stringify(valueToStore));
|
|
2623
2633
|
window.sessionStorage.setItem(`${key}_timestamp`, Date.now().toString());
|
|
2624
2634
|
} catch (storageError) {
|
|
2625
|
-
if (storageError
|
|
2635
|
+
if (isQuotaExceededError(storageError)) {
|
|
2626
2636
|
authLogger.warn("sessionStorage quota exceeded, clearing old data...");
|
|
2627
2637
|
clearOldData();
|
|
2628
2638
|
try {
|
|
@@ -2658,7 +2668,7 @@ function useSessionStorage(key, initialValue) {
|
|
|
2658
2668
|
window.sessionStorage.removeItem(key);
|
|
2659
2669
|
window.sessionStorage.removeItem(`${key}_timestamp`);
|
|
2660
2670
|
} catch (removeError) {
|
|
2661
|
-
if (removeError
|
|
2671
|
+
if (isQuotaExceededError(removeError)) {
|
|
2662
2672
|
authLogger.warn("sessionStorage quota exceeded during removal, clearing old data...");
|
|
2663
2673
|
clearOldData();
|
|
2664
2674
|
try {
|
|
@@ -2933,7 +2943,6 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
2933
2943
|
const {
|
|
2934
2944
|
identifier,
|
|
2935
2945
|
otp,
|
|
2936
|
-
isLoading,
|
|
2937
2946
|
acceptedTerms,
|
|
2938
2947
|
marketingConsent,
|
|
2939
2948
|
rememberMe,
|
|
@@ -3285,7 +3294,9 @@ var useGithubAuth = /* @__PURE__ */ __name((options = {}) => {
|
|
|
3285
3294
|
if (response.user?.id) {
|
|
3286
3295
|
Analytics.setUser(String(response.user.id));
|
|
3287
3296
|
}
|
|
3288
|
-
|
|
3297
|
+
if (response.user) {
|
|
3298
|
+
onSuccess?.(response.user, response.is_new_user || false);
|
|
3299
|
+
}
|
|
3289
3300
|
if (!skipRedirect) {
|
|
3290
3301
|
const finalRedirectUrl = redirectUrl || "/private";
|
|
3291
3302
|
router.hardPush(finalRedirectUrl);
|
|
@@ -3518,21 +3529,6 @@ function useLocalStorage(key, initialValue) {
|
|
|
3518
3529
|
return initialValue;
|
|
3519
3530
|
}
|
|
3520
3531
|
});
|
|
3521
|
-
const checkDataSize = /* @__PURE__ */ __name((data) => {
|
|
3522
|
-
try {
|
|
3523
|
-
const jsonString = JSON.stringify(data);
|
|
3524
|
-
const sizeInBytes = new Blob([jsonString]).size;
|
|
3525
|
-
const sizeInKB = sizeInBytes / 1024;
|
|
3526
|
-
if (sizeInKB > 1024) {
|
|
3527
|
-
authLogger.warn(`Data size (${sizeInKB.toFixed(2)}KB) exceeds 1MB limit for key "${key}"`);
|
|
3528
|
-
return false;
|
|
3529
|
-
}
|
|
3530
|
-
return true;
|
|
3531
|
-
} catch (error) {
|
|
3532
|
-
authLogger.error(`Error checking data size for key "${key}":`, error);
|
|
3533
|
-
return false;
|
|
3534
|
-
}
|
|
3535
|
-
}, "checkDataSize");
|
|
3536
3532
|
const clearOldData = /* @__PURE__ */ __name(() => {
|
|
3537
3533
|
try {
|
|
3538
3534
|
const keys = Object.keys(localStorage).filter((key2) => key2 && typeof key2 === "string");
|
|
@@ -3569,7 +3565,7 @@ function useLocalStorage(key, initialValue) {
|
|
|
3569
3565
|
const setValue = /* @__PURE__ */ __name((value) => {
|
|
3570
3566
|
try {
|
|
3571
3567
|
const valueToStore = value instanceof Function ? value(storedValue) : value;
|
|
3572
|
-
if (!
|
|
3568
|
+
if (!isWithinSizeLimit(valueToStore, key)) {
|
|
3573
3569
|
authLogger.warn(`Data size too large for key "${key}", removing key`);
|
|
3574
3570
|
try {
|
|
3575
3571
|
window.localStorage.removeItem(key);
|
|
@@ -3589,7 +3585,7 @@ function useLocalStorage(key, initialValue) {
|
|
|
3589
3585
|
}
|
|
3590
3586
|
window.localStorage.setItem(`${key}_timestamp`, Date.now().toString());
|
|
3591
3587
|
} catch (storageError) {
|
|
3592
|
-
if (storageError
|
|
3588
|
+
if (isQuotaExceededError(storageError)) {
|
|
3593
3589
|
authLogger.warn("localStorage quota exceeded, clearing old data...");
|
|
3594
3590
|
clearOldData();
|
|
3595
3591
|
try {
|
|
@@ -3633,7 +3629,7 @@ function useLocalStorage(key, initialValue) {
|
|
|
3633
3629
|
window.localStorage.removeItem(key);
|
|
3634
3630
|
window.localStorage.removeItem(`${key}_timestamp`);
|
|
3635
3631
|
} catch (removeError) {
|
|
3636
|
-
if (removeError
|
|
3632
|
+
if (isQuotaExceededError(removeError)) {
|
|
3637
3633
|
authLogger.warn("localStorage quota exceeded during removal, clearing old data...");
|
|
3638
3634
|
clearOldData();
|
|
3639
3635
|
try {
|
|
@@ -4044,53 +4040,41 @@ __name(useCfgAccountsOtpRequestCreate, "useCfgAccountsOtpRequestCreate");
|
|
|
4044
4040
|
var import_mutation8 = __toESM(require("swr/mutation"), 1);
|
|
4045
4041
|
|
|
4046
4042
|
// src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts
|
|
4047
|
-
var import_zod19 = require("zod");
|
|
4048
|
-
|
|
4049
|
-
// src/_api/generated/_cfg_accounts/schemas/User.ts
|
|
4050
4043
|
var import_zod18 = require("zod");
|
|
4051
4044
|
|
|
4052
|
-
// src/_api/generated/_cfg_accounts/schemas/CentrifugoToken.ts
|
|
4053
|
-
var import_zod17 = require("zod");
|
|
4054
|
-
var CentrifugoTokenSchema = import_zod17.z.object({
|
|
4055
|
-
token: import_zod17.z.string(),
|
|
4056
|
-
centrifugo_url: import_zod17.z.string(),
|
|
4057
|
-
expires_at: import_zod17.z.string().datetime({ offset: true }),
|
|
4058
|
-
channels: import_zod17.z.array(import_zod17.z.string())
|
|
4059
|
-
});
|
|
4060
|
-
|
|
4061
4045
|
// src/_api/generated/_cfg_accounts/schemas/User.ts
|
|
4062
|
-
var
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
api_key:
|
|
4046
|
+
var import_zod17 = require("zod");
|
|
4047
|
+
var UserSchema = import_zod17.z.object({
|
|
4048
|
+
id: import_zod17.z.number().int(),
|
|
4049
|
+
email: import_zod17.z.email(),
|
|
4050
|
+
first_name: import_zod17.z.string().max(50).nullable().optional(),
|
|
4051
|
+
last_name: import_zod17.z.string().max(50).nullable().optional(),
|
|
4052
|
+
full_name: import_zod17.z.string(),
|
|
4053
|
+
initials: import_zod17.z.string(),
|
|
4054
|
+
display_username: import_zod17.z.string(),
|
|
4055
|
+
company: import_zod17.z.string().max(100).nullable().optional(),
|
|
4056
|
+
phone: import_zod17.z.string().max(20).nullable().optional(),
|
|
4057
|
+
position: import_zod17.z.string().max(100).nullable().optional(),
|
|
4058
|
+
language: import_zod17.z.string().max(10).nullable().optional(),
|
|
4059
|
+
timezone: import_zod17.z.string().max(64).nullable().optional(),
|
|
4060
|
+
avatar: import_zod17.z.string().nullable(),
|
|
4061
|
+
is_staff: import_zod17.z.boolean(),
|
|
4062
|
+
is_superuser: import_zod17.z.boolean(),
|
|
4063
|
+
date_joined: import_zod17.z.string().datetime({ offset: true }),
|
|
4064
|
+
last_login: import_zod17.z.string().datetime({ offset: true }).nullable(),
|
|
4065
|
+
unanswered_messages_count: import_zod17.z.number().int().default(0),
|
|
4066
|
+
api_key: import_zod17.z.string().nullable()
|
|
4083
4067
|
});
|
|
4084
4068
|
|
|
4085
4069
|
// src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts
|
|
4086
|
-
var OTPVerifyResponseSchema =
|
|
4087
|
-
requires_2fa:
|
|
4088
|
-
session_id:
|
|
4089
|
-
refresh:
|
|
4090
|
-
access:
|
|
4070
|
+
var OTPVerifyResponseSchema = import_zod18.z.object({
|
|
4071
|
+
requires_2fa: import_zod18.z.boolean().default(false).optional(),
|
|
4072
|
+
session_id: import_zod18.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i).nullable().optional(),
|
|
4073
|
+
refresh: import_zod18.z.string().nullable().optional(),
|
|
4074
|
+
access: import_zod18.z.string().nullable().optional(),
|
|
4091
4075
|
user: UserSchema.nullable().optional(),
|
|
4092
|
-
should_prompt_2fa:
|
|
4093
|
-
persistent_session:
|
|
4076
|
+
should_prompt_2fa: import_zod18.z.boolean().optional(),
|
|
4077
|
+
persistent_session: import_zod18.z.boolean().optional()
|
|
4094
4078
|
});
|
|
4095
4079
|
|
|
4096
4080
|
// src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpVerifyCreate.ts
|
|
@@ -4192,10 +4176,10 @@ __name(useCfgAccountsProfileAvatarCreate, "useCfgAccountsProfileAvatarCreate");
|
|
|
4192
4176
|
var import_mutation10 = __toESM(require("swr/mutation"), 1);
|
|
4193
4177
|
|
|
4194
4178
|
// src/_api/generated/_cfg_accounts/schemas/AccountDeleteResponse.ts
|
|
4195
|
-
var
|
|
4196
|
-
var AccountDeleteResponseSchema =
|
|
4197
|
-
success:
|
|
4198
|
-
message:
|
|
4179
|
+
var import_zod19 = require("zod");
|
|
4180
|
+
var AccountDeleteResponseSchema = import_zod19.z.object({
|
|
4181
|
+
success: import_zod19.z.boolean(),
|
|
4182
|
+
message: import_zod19.z.string()
|
|
4199
4183
|
});
|
|
4200
4184
|
|
|
4201
4185
|
// src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialPartialUpdate.ts
|
|
@@ -4310,117 +4294,117 @@ var import_mutation15 = __toESM(require("swr/mutation"), 1);
|
|
|
4310
4294
|
var import_mutation16 = __toESM(require("swr/mutation"), 1);
|
|
4311
4295
|
|
|
4312
4296
|
// src/_api/generated/_cfg_accounts/schemas/TokenRefresh.ts
|
|
4313
|
-
var
|
|
4314
|
-
var TokenRefreshSchema =
|
|
4315
|
-
access:
|
|
4316
|
-
refresh:
|
|
4297
|
+
var import_zod20 = require("zod");
|
|
4298
|
+
var TokenRefreshSchema = import_zod20.z.object({
|
|
4299
|
+
access: import_zod20.z.string(),
|
|
4300
|
+
refresh: import_zod20.z.string()
|
|
4317
4301
|
});
|
|
4318
4302
|
|
|
4319
4303
|
// src/_api/generated/_cfg_accounts/schemas/APIKeyRequest.ts
|
|
4320
|
-
var
|
|
4321
|
-
var APIKeyRequestSchema =
|
|
4322
|
-
key:
|
|
4323
|
-
reissued_at:
|
|
4324
|
-
created_at:
|
|
4304
|
+
var import_zod21 = require("zod");
|
|
4305
|
+
var APIKeyRequestSchema = import_zod21.z.object({
|
|
4306
|
+
key: import_zod21.z.string().min(1),
|
|
4307
|
+
reissued_at: import_zod21.z.string().datetime({ offset: true }).nullable(),
|
|
4308
|
+
created_at: import_zod21.z.string().datetime({ offset: true })
|
|
4325
4309
|
});
|
|
4326
4310
|
|
|
4327
4311
|
// src/_api/generated/_cfg_accounts/schemas/APIKeyTestRequest.ts
|
|
4328
|
-
var
|
|
4329
|
-
var APIKeyTestRequestSchema =
|
|
4330
|
-
key:
|
|
4312
|
+
var import_zod22 = require("zod");
|
|
4313
|
+
var APIKeyTestRequestSchema = import_zod22.z.object({
|
|
4314
|
+
key: import_zod22.z.string().min(1)
|
|
4331
4315
|
});
|
|
4332
4316
|
|
|
4333
4317
|
// src/_api/generated/_cfg_accounts/schemas/CfgUserUpdateRequest.ts
|
|
4334
|
-
var
|
|
4335
|
-
var CfgUserUpdateRequestSchema =
|
|
4336
|
-
first_name:
|
|
4337
|
-
last_name:
|
|
4338
|
-
company:
|
|
4339
|
-
phone:
|
|
4340
|
-
position:
|
|
4341
|
-
language:
|
|
4342
|
-
timezone:
|
|
4318
|
+
var import_zod23 = require("zod");
|
|
4319
|
+
var CfgUserUpdateRequestSchema = import_zod23.z.object({
|
|
4320
|
+
first_name: import_zod23.z.string().max(50).optional(),
|
|
4321
|
+
last_name: import_zod23.z.string().max(50).optional(),
|
|
4322
|
+
company: import_zod23.z.string().max(100).optional(),
|
|
4323
|
+
phone: import_zod23.z.string().max(20).optional(),
|
|
4324
|
+
position: import_zod23.z.string().max(100).optional(),
|
|
4325
|
+
language: import_zod23.z.string().max(10).optional(),
|
|
4326
|
+
timezone: import_zod23.z.string().max(64).optional()
|
|
4343
4327
|
});
|
|
4344
4328
|
|
|
4345
4329
|
// src/_api/generated/_cfg_accounts/schemas/OAuthAuthorizeRequestRequest.ts
|
|
4346
|
-
var
|
|
4347
|
-
var OAuthAuthorizeRequestRequestSchema =
|
|
4348
|
-
redirect_uri:
|
|
4349
|
-
source_url:
|
|
4330
|
+
var import_zod24 = require("zod");
|
|
4331
|
+
var OAuthAuthorizeRequestRequestSchema = import_zod24.z.object({
|
|
4332
|
+
redirect_uri: import_zod24.z.string().optional(),
|
|
4333
|
+
source_url: import_zod24.z.string().optional()
|
|
4350
4334
|
});
|
|
4351
4335
|
|
|
4352
4336
|
// src/_api/generated/_cfg_accounts/schemas/OAuthCallbackRequestRequest.ts
|
|
4353
|
-
var
|
|
4354
|
-
var OAuthCallbackRequestRequestSchema =
|
|
4355
|
-
code:
|
|
4356
|
-
state:
|
|
4357
|
-
redirect_uri:
|
|
4358
|
-
remember_me:
|
|
4337
|
+
var import_zod25 = require("zod");
|
|
4338
|
+
var OAuthCallbackRequestRequestSchema = import_zod25.z.object({
|
|
4339
|
+
code: import_zod25.z.string().min(10).max(500),
|
|
4340
|
+
state: import_zod25.z.string().min(20).max(100),
|
|
4341
|
+
redirect_uri: import_zod25.z.string().optional(),
|
|
4342
|
+
remember_me: import_zod25.z.boolean().default(false).optional()
|
|
4359
4343
|
});
|
|
4360
4344
|
|
|
4361
4345
|
// src/_api/generated/_cfg_accounts/schemas/OAuthDisconnectRequestRequest.ts
|
|
4362
|
-
var
|
|
4363
|
-
var OAuthDisconnectRequestRequestSchema =
|
|
4346
|
+
var import_zod26 = require("zod");
|
|
4347
|
+
var OAuthDisconnectRequestRequestSchema = import_zod26.z.object({
|
|
4364
4348
|
provider: OAuthProviderEnumSchema
|
|
4365
4349
|
});
|
|
4366
4350
|
|
|
4367
4351
|
// src/_api/generated/_cfg_accounts/schemas/OAuthError.ts
|
|
4352
|
+
var import_zod27 = require("zod");
|
|
4353
|
+
var OAuthErrorSchema = import_zod27.z.object({
|
|
4354
|
+
error: import_zod27.z.string(),
|
|
4355
|
+
error_description: import_zod27.z.string().optional()
|
|
4356
|
+
});
|
|
4357
|
+
|
|
4358
|
+
// src/_api/generated/_cfg_accounts/schemas/OTPErrorResponse.ts
|
|
4368
4359
|
var import_zod28 = require("zod");
|
|
4369
|
-
var
|
|
4360
|
+
var OTPErrorResponseSchema = import_zod28.z.object({
|
|
4370
4361
|
error: import_zod28.z.string(),
|
|
4371
|
-
|
|
4362
|
+
error_code: import_zod28.z.string().nullable().optional(),
|
|
4363
|
+
retry_after: import_zod28.z.number().int().nullable().optional()
|
|
4372
4364
|
});
|
|
4373
4365
|
|
|
4374
|
-
// src/_api/generated/_cfg_accounts/schemas/
|
|
4366
|
+
// src/_api/generated/_cfg_accounts/schemas/OTPRequestRequest.ts
|
|
4375
4367
|
var import_zod29 = require("zod");
|
|
4376
|
-
var
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4368
|
+
var OTPRequestRequestSchema = import_zod29.z.object({
|
|
4369
|
+
identifier: import_zod29.z.string().min(1),
|
|
4370
|
+
source_url: import_zod29.z.string().optional(),
|
|
4371
|
+
marketing_consent: import_zod29.z.boolean().nullable().optional(),
|
|
4372
|
+
consent_disclosure_version: import_zod29.z.string().max(64).optional()
|
|
4380
4373
|
});
|
|
4381
4374
|
|
|
4382
|
-
// src/_api/generated/_cfg_accounts/schemas/
|
|
4375
|
+
// src/_api/generated/_cfg_accounts/schemas/OTPVerifyRequest.ts
|
|
4383
4376
|
var import_zod30 = require("zod");
|
|
4384
|
-
var
|
|
4377
|
+
var OTPVerifyRequestSchema = import_zod30.z.object({
|
|
4385
4378
|
identifier: import_zod30.z.string().min(1),
|
|
4379
|
+
otp: import_zod30.z.string().min(4).max(4),
|
|
4386
4380
|
source_url: import_zod30.z.string().optional(),
|
|
4387
|
-
|
|
4388
|
-
consent_disclosure_version: import_zod30.z.string().max(64).optional()
|
|
4381
|
+
remember_me: import_zod30.z.boolean().default(false).optional()
|
|
4389
4382
|
});
|
|
4390
4383
|
|
|
4391
|
-
// src/_api/generated/_cfg_accounts/schemas/
|
|
4384
|
+
// src/_api/generated/_cfg_accounts/schemas/PatchedCfgUserUpdateRequest.ts
|
|
4392
4385
|
var import_zod31 = require("zod");
|
|
4393
|
-
var
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4386
|
+
var PatchedCfgUserUpdateRequestSchema = import_zod31.z.object({
|
|
4387
|
+
first_name: import_zod31.z.string().max(50).optional(),
|
|
4388
|
+
last_name: import_zod31.z.string().max(50).optional(),
|
|
4389
|
+
company: import_zod31.z.string().max(100).optional(),
|
|
4390
|
+
phone: import_zod31.z.string().max(20).optional(),
|
|
4391
|
+
position: import_zod31.z.string().max(100).optional(),
|
|
4392
|
+
language: import_zod31.z.string().max(10).optional(),
|
|
4393
|
+
timezone: import_zod31.z.string().max(64).optional()
|
|
4398
4394
|
});
|
|
4399
4395
|
|
|
4400
|
-
// src/_api/generated/_cfg_accounts/schemas/
|
|
4396
|
+
// src/_api/generated/_cfg_accounts/schemas/TokenBlacklistRequest.ts
|
|
4401
4397
|
var import_zod32 = require("zod");
|
|
4402
|
-
var
|
|
4403
|
-
|
|
4404
|
-
last_name: import_zod32.z.string().max(50).optional(),
|
|
4405
|
-
company: import_zod32.z.string().max(100).optional(),
|
|
4406
|
-
phone: import_zod32.z.string().max(20).optional(),
|
|
4407
|
-
position: import_zod32.z.string().max(100).optional(),
|
|
4408
|
-
language: import_zod32.z.string().max(10).optional(),
|
|
4409
|
-
timezone: import_zod32.z.string().max(64).optional()
|
|
4398
|
+
var TokenBlacklistRequestSchema = import_zod32.z.object({
|
|
4399
|
+
refresh: import_zod32.z.string().min(1)
|
|
4410
4400
|
});
|
|
4411
4401
|
|
|
4412
|
-
// src/_api/generated/_cfg_accounts/schemas/
|
|
4402
|
+
// src/_api/generated/_cfg_accounts/schemas/TokenRefreshRequest.ts
|
|
4413
4403
|
var import_zod33 = require("zod");
|
|
4414
|
-
var
|
|
4404
|
+
var TokenRefreshRequestSchema = import_zod33.z.object({
|
|
4415
4405
|
refresh: import_zod33.z.string().min(1)
|
|
4416
4406
|
});
|
|
4417
4407
|
|
|
4418
|
-
// src/_api/generated/_cfg_accounts/schemas/TokenRefreshRequest.ts
|
|
4419
|
-
var import_zod34 = require("zod");
|
|
4420
|
-
var TokenRefreshRequestSchema = import_zod34.z.object({
|
|
4421
|
-
refresh: import_zod34.z.string().min(1)
|
|
4422
|
-
});
|
|
4423
|
-
|
|
4424
4408
|
// src/auth/context/AccountsContext.tsx
|
|
4425
4409
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
4426
4410
|
function hasApiOrigin() {
|
|
@@ -4485,26 +4469,26 @@ function AccountsProvider({ children }) {
|
|
|
4485
4469
|
isLoadingRef.current = false;
|
|
4486
4470
|
}
|
|
4487
4471
|
}, []);
|
|
4488
|
-
const updateProfile =
|
|
4472
|
+
const updateProfile = (0, import_react15.useCallback)(async (data) => {
|
|
4489
4473
|
await triggerProfileUpdate({ body: data });
|
|
4490
4474
|
const user = await refreshProfile({ callerId: "updateProfile", force: true });
|
|
4491
4475
|
return user;
|
|
4492
|
-
},
|
|
4493
|
-
const partialUpdateProfile =
|
|
4476
|
+
}, [triggerProfileUpdate, refreshProfile]);
|
|
4477
|
+
const partialUpdateProfile = (0, import_react15.useCallback)(async (data) => {
|
|
4494
4478
|
await triggerProfilePartialUpdate({ body: data });
|
|
4495
4479
|
const user = await refreshProfile({ callerId: "partialUpdateProfile", force: true });
|
|
4496
4480
|
return user;
|
|
4497
|
-
},
|
|
4498
|
-
const uploadAvatar =
|
|
4481
|
+
}, [triggerProfilePartialUpdate, refreshProfile]);
|
|
4482
|
+
const uploadAvatar = (0, import_react15.useCallback)(async (avatar) => {
|
|
4499
4483
|
await triggerAvatar({ body: { avatar } });
|
|
4500
4484
|
const user = await refreshProfile({ callerId: "uploadAvatar", force: true });
|
|
4501
4485
|
return user;
|
|
4502
|
-
},
|
|
4503
|
-
const requestOTP =
|
|
4486
|
+
}, [triggerAvatar, refreshProfile]);
|
|
4487
|
+
const requestOTP = (0, import_react15.useCallback)(async (data) => {
|
|
4504
4488
|
const result = await triggerOtpRequest({ body: data });
|
|
4505
4489
|
return result;
|
|
4506
|
-
},
|
|
4507
|
-
const verifyOTP =
|
|
4490
|
+
}, [triggerOtpRequest]);
|
|
4491
|
+
const verifyOTP = (0, import_react15.useCallback)(async (data) => {
|
|
4508
4492
|
const result = await triggerOtpVerify({ body: data });
|
|
4509
4493
|
if (result.requires_2fa && result.session_id) {
|
|
4510
4494
|
authLogger.info("2FA required, session:", result.session_id);
|
|
@@ -4519,7 +4503,7 @@ function AccountsProvider({ children }) {
|
|
|
4519
4503
|
}
|
|
4520
4504
|
}
|
|
4521
4505
|
return result;
|
|
4522
|
-
},
|
|
4506
|
+
}, [triggerOtpVerify, refreshProfile]);
|
|
4523
4507
|
const logout = (0, import_react15.useCallback)(() => {
|
|
4524
4508
|
const refresh = auth.getRefreshToken();
|
|
4525
4509
|
if (refresh) {
|
|
@@ -4949,18 +4933,20 @@ var validateEmail = /* @__PURE__ */ __name((email) => {
|
|
|
4949
4933
|
}, "validateEmail");
|
|
4950
4934
|
|
|
4951
4935
|
// src/auth/utils/errors.ts
|
|
4936
|
+
var prop = /* @__PURE__ */ __name((value, key) => typeof value === "object" && value !== null ? value[key] : void 0, "prop");
|
|
4952
4937
|
var formatAuthError = /* @__PURE__ */ __name((error) => {
|
|
4953
4938
|
if (typeof error === "string") {
|
|
4954
4939
|
return error;
|
|
4955
4940
|
}
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4941
|
+
const candidates = [
|
|
4942
|
+
prop(error, "message"),
|
|
4943
|
+
prop(error, "detail"),
|
|
4944
|
+
prop(prop(prop(error, "response"), "data"), "detail")
|
|
4945
|
+
];
|
|
4946
|
+
for (const candidate of candidates) {
|
|
4947
|
+
if (typeof candidate === "string" && candidate) {
|
|
4948
|
+
return candidate;
|
|
4949
|
+
}
|
|
4964
4950
|
}
|
|
4965
4951
|
return "An unexpected error occurred";
|
|
4966
4952
|
}, "formatAuthError");
|