@djangocfg/api 2.1.262 → 2.1.264
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 +9 -0
- package/dist/auth-server.cjs.map +1 -1
- package/dist/auth-server.mjs +9 -0
- package/dist/auth-server.mjs.map +1 -1
- package/dist/auth.cjs +76 -72
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.mjs +76 -72
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +122 -80
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +129 -172
- package/dist/clients.d.ts +129 -172
- package/dist/clients.mjs +122 -80
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +47 -1
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +80 -57
- package/dist/hooks.d.ts +80 -57
- package/dist/hooks.mjs +47 -1
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +56 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +99 -99
- package/dist/index.d.ts +99 -99
- package/dist/index.mjs +56 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/_api/generated/cfg_accounts/_utils/fetchers/accounts__oauth.ts +46 -2
- package/src/_api/generated/cfg_accounts/_utils/hooks/accounts__oauth.ts +3 -2
- package/src/_api/generated/cfg_accounts/accounts/models.ts +34 -34
- package/src/_api/generated/cfg_accounts/accounts__oauth/client.ts +1 -1
- package/src/_api/generated/cfg_accounts/accounts__oauth/models.ts +54 -54
- package/src/_api/generated/cfg_accounts/accounts__user_profile/models.ts +14 -14
- package/src/_api/generated/cfg_accounts/client.ts +8 -0
- package/src/_api/generated/cfg_accounts/errors.ts +5 -0
- package/src/_api/generated/cfg_centrifugo/client.ts +8 -0
- package/src/_api/generated/cfg_centrifugo/errors.ts +5 -0
- package/src/_api/generated/cfg_totp/CLAUDE.md +3 -3
- package/src/_api/generated/cfg_totp/_utils/fetchers/totp__totp_management.ts +7 -7
- package/src/_api/generated/cfg_totp/_utils/hooks/totp__totp_management.ts +5 -5
- package/src/_api/generated/cfg_totp/_utils/schemas/index.ts +0 -1
- package/src/_api/generated/cfg_totp/client.ts +8 -0
- package/src/_api/generated/cfg_totp/errors.ts +5 -0
- package/src/_api/generated/cfg_totp/schema.json +2 -103
- package/src/_api/generated/cfg_totp/totp__backup_codes/models.ts +10 -10
- package/src/_api/generated/cfg_totp/totp__totp_management/client.ts +2 -13
- package/src/_api/generated/cfg_totp/totp__totp_management/models.ts +9 -34
- package/src/_api/generated/cfg_totp/totp__totp_setup/models.ts +12 -12
- package/src/_api/generated/cfg_totp/totp__totp_verification/models.ts +8 -8
- package/src/auth/hooks/useTwoFactorStatus.ts +5 -11
- package/src/_api/generated/cfg_totp/_utils/schemas/PaginatedDeviceListResponseList.schema.ts +0 -24
package/dist/auth.mjs
CHANGED
|
@@ -539,6 +539,9 @@ var APIError = class extends Error {
|
|
|
539
539
|
if (details.detail) {
|
|
540
540
|
return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
|
|
541
541
|
}
|
|
542
|
+
if (details.error) {
|
|
543
|
+
return String(details.error);
|
|
544
|
+
}
|
|
542
545
|
if (details.message) {
|
|
543
546
|
return String(details.message);
|
|
544
547
|
}
|
|
@@ -877,6 +880,12 @@ var APIClient = class {
|
|
|
877
880
|
if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
|
|
878
881
|
headers["Content-Type"] = "application/json";
|
|
879
882
|
}
|
|
883
|
+
if (!headers["Authorization"]) {
|
|
884
|
+
const token = this.getToken();
|
|
885
|
+
if (token) {
|
|
886
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
880
889
|
if (this.logger) {
|
|
881
890
|
this.logger.logRequest({
|
|
882
891
|
method,
|
|
@@ -1883,6 +1892,9 @@ var APIError2 = class extends Error {
|
|
|
1883
1892
|
if (details.detail) {
|
|
1884
1893
|
return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
|
|
1885
1894
|
}
|
|
1895
|
+
if (details.error) {
|
|
1896
|
+
return String(details.error);
|
|
1897
|
+
}
|
|
1886
1898
|
if (details.message) {
|
|
1887
1899
|
return String(details.message);
|
|
1888
1900
|
}
|
|
@@ -2218,6 +2230,12 @@ var APIClient2 = class {
|
|
|
2218
2230
|
if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
|
|
2219
2231
|
headers["Content-Type"] = "application/json";
|
|
2220
2232
|
}
|
|
2233
|
+
if (!headers["Authorization"]) {
|
|
2234
|
+
const token = this.getToken();
|
|
2235
|
+
if (token) {
|
|
2236
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2221
2239
|
if (this.logger) {
|
|
2222
2240
|
this.logger.logRequest({
|
|
2223
2241
|
method,
|
|
@@ -2604,15 +2622,8 @@ var TotpManagement = class {
|
|
|
2604
2622
|
/**
|
|
2605
2623
|
* List all TOTP devices for user.
|
|
2606
2624
|
*/
|
|
2607
|
-
async
|
|
2608
|
-
const
|
|
2609
|
-
let params;
|
|
2610
|
-
if (isParamsObject) {
|
|
2611
|
-
params = args[0];
|
|
2612
|
-
} else {
|
|
2613
|
-
params = { ordering: args[0], page: args[1], page_size: args[2], search: args[3] };
|
|
2614
|
-
}
|
|
2615
|
-
const response = await this.client.request("GET", "/cfg/totp/devices/", { params });
|
|
2625
|
+
async totpDevicesRetrieve() {
|
|
2626
|
+
const response = await this.client.request("GET", "/cfg/totp/devices/");
|
|
2616
2627
|
return response;
|
|
2617
2628
|
}
|
|
2618
2629
|
/**
|
|
@@ -2800,6 +2811,9 @@ var APIError3 = class extends Error {
|
|
|
2800
2811
|
if (details.detail) {
|
|
2801
2812
|
return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
|
|
2802
2813
|
}
|
|
2814
|
+
if (details.error) {
|
|
2815
|
+
return String(details.error);
|
|
2816
|
+
}
|
|
2803
2817
|
if (details.message) {
|
|
2804
2818
|
return String(details.message);
|
|
2805
2819
|
}
|
|
@@ -3139,6 +3153,12 @@ var APIClient3 = class {
|
|
|
3139
3153
|
if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
|
|
3140
3154
|
headers["Content-Type"] = "application/json";
|
|
3141
3155
|
}
|
|
3156
|
+
if (!headers["Authorization"]) {
|
|
3157
|
+
const token = this.getToken();
|
|
3158
|
+
if (token) {
|
|
3159
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
3160
|
+
}
|
|
3161
|
+
}
|
|
3142
3162
|
if (this.logger) {
|
|
3143
3163
|
this.logger.logRequest({
|
|
3144
3164
|
method,
|
|
@@ -3390,81 +3410,67 @@ var DisableRequestSchema = z30.object({
|
|
|
3390
3410
|
code: z30.string().min(6).max(6)
|
|
3391
3411
|
});
|
|
3392
3412
|
|
|
3393
|
-
// src/_api/generated/cfg_totp/_utils/schemas/
|
|
3413
|
+
// src/_api/generated/cfg_totp/_utils/schemas/SetupRequest.schema.ts
|
|
3394
3414
|
import { z as z31 } from "zod";
|
|
3395
|
-
var
|
|
3396
|
-
|
|
3397
|
-
page: z31.number().int(),
|
|
3398
|
-
pages: z31.number().int(),
|
|
3399
|
-
page_size: z31.number().int(),
|
|
3400
|
-
has_next: z31.boolean(),
|
|
3401
|
-
has_previous: z31.boolean(),
|
|
3402
|
-
next_page: z31.number().int().nullable().optional(),
|
|
3403
|
-
previous_page: z31.number().int().nullable().optional(),
|
|
3404
|
-
results: z31.array(DeviceListResponseSchema)
|
|
3415
|
+
var SetupRequestSchema = z31.object({
|
|
3416
|
+
device_name: z31.string().min(1).max(100).optional()
|
|
3405
3417
|
});
|
|
3406
3418
|
|
|
3407
|
-
// src/_api/generated/cfg_totp/_utils/schemas/
|
|
3419
|
+
// src/_api/generated/cfg_totp/_utils/schemas/SetupResponse.schema.ts
|
|
3408
3420
|
import { z as z32 } from "zod";
|
|
3409
|
-
var
|
|
3410
|
-
|
|
3421
|
+
var SetupResponseSchema = z32.object({
|
|
3422
|
+
device_id: z32.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
3423
|
+
secret: z32.string(),
|
|
3424
|
+
provisioning_uri: z32.string(),
|
|
3425
|
+
qr_code_base64: z32.string(),
|
|
3426
|
+
expires_in: z32.number().int()
|
|
3411
3427
|
});
|
|
3412
3428
|
|
|
3413
|
-
// src/_api/generated/cfg_totp/_utils/schemas/
|
|
3429
|
+
// src/_api/generated/cfg_totp/_utils/schemas/TotpVerifyUser.schema.ts
|
|
3414
3430
|
import { z as z33 } from "zod";
|
|
3415
|
-
var
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3431
|
+
var TotpVerifyUserSchema = z33.object({
|
|
3432
|
+
id: z33.number().int(),
|
|
3433
|
+
email: z33.email(),
|
|
3434
|
+
first_name: z33.string().max(50).optional(),
|
|
3435
|
+
last_name: z33.string().max(50).optional(),
|
|
3436
|
+
full_name: z33.string(),
|
|
3437
|
+
initials: z33.string(),
|
|
3438
|
+
display_username: z33.string(),
|
|
3439
|
+
company: z33.string().max(100).optional(),
|
|
3440
|
+
phone: z33.string().max(20).optional(),
|
|
3441
|
+
position: z33.string().max(100).optional(),
|
|
3442
|
+
language: z33.string().max(10).optional(),
|
|
3443
|
+
avatar: z33.string().nullable(),
|
|
3444
|
+
is_staff: z33.boolean(),
|
|
3445
|
+
is_superuser: z33.boolean(),
|
|
3446
|
+
date_joined: z33.string().datetime({ offset: true }),
|
|
3447
|
+
last_login: z33.string().datetime({ offset: true }).nullable(),
|
|
3448
|
+
unanswered_messages_count: z33.number().int()
|
|
3421
3449
|
});
|
|
3422
3450
|
|
|
3423
|
-
// src/_api/generated/cfg_totp/_utils/schemas/
|
|
3451
|
+
// src/_api/generated/cfg_totp/_utils/schemas/VerifyBackupRequest.schema.ts
|
|
3424
3452
|
import { z as z34 } from "zod";
|
|
3425
|
-
var
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
first_name: z34.string().max(50).optional(),
|
|
3429
|
-
last_name: z34.string().max(50).optional(),
|
|
3430
|
-
full_name: z34.string(),
|
|
3431
|
-
initials: z34.string(),
|
|
3432
|
-
display_username: z34.string(),
|
|
3433
|
-
company: z34.string().max(100).optional(),
|
|
3434
|
-
phone: z34.string().max(20).optional(),
|
|
3435
|
-
position: z34.string().max(100).optional(),
|
|
3436
|
-
language: z34.string().max(10).optional(),
|
|
3437
|
-
avatar: z34.string().nullable(),
|
|
3438
|
-
is_staff: z34.boolean(),
|
|
3439
|
-
is_superuser: z34.boolean(),
|
|
3440
|
-
date_joined: z34.string().datetime({ offset: true }),
|
|
3441
|
-
last_login: z34.string().datetime({ offset: true }).nullable(),
|
|
3442
|
-
unanswered_messages_count: z34.number().int()
|
|
3453
|
+
var VerifyBackupRequestSchema = z34.object({
|
|
3454
|
+
session_id: z34.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
3455
|
+
backup_code: z34.string().min(8).max(8)
|
|
3443
3456
|
});
|
|
3444
3457
|
|
|
3445
|
-
// src/_api/generated/cfg_totp/_utils/schemas/
|
|
3458
|
+
// src/_api/generated/cfg_totp/_utils/schemas/VerifyRequest.schema.ts
|
|
3446
3459
|
import { z as z35 } from "zod";
|
|
3447
|
-
var
|
|
3460
|
+
var VerifyRequestSchema = z35.object({
|
|
3448
3461
|
session_id: z35.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
3449
|
-
|
|
3450
|
-
});
|
|
3451
|
-
|
|
3452
|
-
// src/_api/generated/cfg_totp/_utils/schemas/VerifyRequest.schema.ts
|
|
3453
|
-
import { z as z36 } from "zod";
|
|
3454
|
-
var VerifyRequestSchema = z36.object({
|
|
3455
|
-
session_id: z36.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
3456
|
-
code: z36.string().min(6).max(6)
|
|
3462
|
+
code: z35.string().min(6).max(6)
|
|
3457
3463
|
});
|
|
3458
3464
|
|
|
3459
3465
|
// src/_api/generated/cfg_totp/_utils/schemas/VerifyResponse.schema.ts
|
|
3460
|
-
import { z as
|
|
3461
|
-
var VerifyResponseSchema =
|
|
3462
|
-
message:
|
|
3463
|
-
access_token:
|
|
3464
|
-
refresh_token:
|
|
3466
|
+
import { z as z36 } from "zod";
|
|
3467
|
+
var VerifyResponseSchema = z36.object({
|
|
3468
|
+
message: z36.string(),
|
|
3469
|
+
access_token: z36.string(),
|
|
3470
|
+
refresh_token: z36.string(),
|
|
3465
3471
|
user: TotpVerifyUserSchema,
|
|
3466
|
-
remaining_backup_codes:
|
|
3467
|
-
warning:
|
|
3472
|
+
remaining_backup_codes: z36.number().int().optional(),
|
|
3473
|
+
warning: z36.string().optional()
|
|
3468
3474
|
});
|
|
3469
3475
|
|
|
3470
3476
|
// src/_api/generated/cfg_totp/_utils/fetchers/totp__backup_codes.ts
|
|
@@ -4418,9 +4424,8 @@ var useTwoFactorStatus = /* @__PURE__ */ __name(() => {
|
|
|
4418
4424
|
setError(null);
|
|
4419
4425
|
try {
|
|
4420
4426
|
authLogger.info("Fetching 2FA status...");
|
|
4421
|
-
const response = await apiTotp.totp_management.
|
|
4422
|
-
const
|
|
4423
|
-
const mappedDevices = devices2.map((device) => ({
|
|
4427
|
+
const response = await apiTotp.totp_management.totpDevicesRetrieve();
|
|
4428
|
+
const mappedDevices = response.devices.map((device) => ({
|
|
4424
4429
|
id: device.id,
|
|
4425
4430
|
name: device.name,
|
|
4426
4431
|
createdAt: device.created_at,
|
|
@@ -4428,9 +4433,8 @@ var useTwoFactorStatus = /* @__PURE__ */ __name(() => {
|
|
|
4428
4433
|
isPrimary: device.is_primary
|
|
4429
4434
|
}));
|
|
4430
4435
|
setDevices(mappedDevices);
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
authLogger.info("2FA status:", enabled ? "enabled" : "disabled");
|
|
4436
|
+
setHas2FAEnabled(response.has_2fa_enabled);
|
|
4437
|
+
authLogger.info("2FA status:", response.has_2fa_enabled ? "enabled" : "disabled");
|
|
4434
4438
|
} catch (err) {
|
|
4435
4439
|
const errorMessage = err instanceof Error ? err.message : "Failed to fetch 2FA status";
|
|
4436
4440
|
authLogger.error("Failed to fetch 2FA status:", err);
|