@djangocfg/api 2.1.263 → 2.1.266
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.cjs +62 -74
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +0 -18
- package/dist/auth.d.ts +0 -18
- package/dist/auth.mjs +62 -74
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +57 -79
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +113 -179
- package/dist/clients.d.ts +113 -179
- package/dist/clients.mjs +57 -79
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.d.cts +72 -72
- package/dist/hooks.d.ts +72 -72
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +97 -97
- package/dist/index.d.ts +97 -97
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/_api/generated/cfg_accounts/accounts/models.ts +31 -31
- package/src/_api/generated/cfg_accounts/accounts__oauth/models.ts +40 -40
- package/src/_api/generated/cfg_accounts/accounts__user_profile/models.ts +31 -31
- 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/schema.json +2 -103
- package/src/_api/generated/cfg_totp/totp__backup_codes/models.ts +14 -14
- package/src/_api/generated/cfg_totp/totp__totp_management/client.ts +2 -13
- package/src/_api/generated/cfg_totp/totp__totp_management/models.ts +4 -29
- package/src/_api/generated/cfg_totp/totp__totp_setup/models.ts +13 -13
- package/src/auth/hooks/useTwoFactorStatus.ts +21 -14
- package/src/_api/generated/cfg_totp/_utils/schemas/PaginatedDeviceListResponseList.schema.ts +0 -24
package/dist/auth.cjs
CHANGED
|
@@ -2683,15 +2683,8 @@ var TotpManagement = class {
|
|
|
2683
2683
|
/**
|
|
2684
2684
|
* List all TOTP devices for user.
|
|
2685
2685
|
*/
|
|
2686
|
-
async
|
|
2687
|
-
const
|
|
2688
|
-
let params;
|
|
2689
|
-
if (isParamsObject) {
|
|
2690
|
-
params = args[0];
|
|
2691
|
-
} else {
|
|
2692
|
-
params = { ordering: args[0], page: args[1], page_size: args[2], search: args[3] };
|
|
2693
|
-
}
|
|
2694
|
-
const response = await this.client.request("GET", "/cfg/totp/devices/", { params });
|
|
2686
|
+
async totpDevicesRetrieve() {
|
|
2687
|
+
const response = await this.client.request("GET", "/cfg/totp/devices/");
|
|
2695
2688
|
return response;
|
|
2696
2689
|
}
|
|
2697
2690
|
/**
|
|
@@ -3478,81 +3471,67 @@ var DisableRequestSchema = import_zod30.z.object({
|
|
|
3478
3471
|
code: import_zod30.z.string().min(6).max(6)
|
|
3479
3472
|
});
|
|
3480
3473
|
|
|
3481
|
-
// src/_api/generated/cfg_totp/_utils/schemas/
|
|
3474
|
+
// src/_api/generated/cfg_totp/_utils/schemas/SetupRequest.schema.ts
|
|
3482
3475
|
var import_zod31 = require("zod");
|
|
3483
|
-
var
|
|
3484
|
-
|
|
3485
|
-
page: import_zod31.z.number().int(),
|
|
3486
|
-
pages: import_zod31.z.number().int(),
|
|
3487
|
-
page_size: import_zod31.z.number().int(),
|
|
3488
|
-
has_next: import_zod31.z.boolean(),
|
|
3489
|
-
has_previous: import_zod31.z.boolean(),
|
|
3490
|
-
next_page: import_zod31.z.number().int().nullable().optional(),
|
|
3491
|
-
previous_page: import_zod31.z.number().int().nullable().optional(),
|
|
3492
|
-
results: import_zod31.z.array(DeviceListResponseSchema)
|
|
3476
|
+
var SetupRequestSchema = import_zod31.z.object({
|
|
3477
|
+
device_name: import_zod31.z.string().min(1).max(100).optional()
|
|
3493
3478
|
});
|
|
3494
3479
|
|
|
3495
|
-
// src/_api/generated/cfg_totp/_utils/schemas/
|
|
3480
|
+
// src/_api/generated/cfg_totp/_utils/schemas/SetupResponse.schema.ts
|
|
3496
3481
|
var import_zod32 = require("zod");
|
|
3497
|
-
var
|
|
3498
|
-
|
|
3482
|
+
var SetupResponseSchema = import_zod32.z.object({
|
|
3483
|
+
device_id: import_zod32.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
3484
|
+
secret: import_zod32.z.string(),
|
|
3485
|
+
provisioning_uri: import_zod32.z.string(),
|
|
3486
|
+
qr_code_base64: import_zod32.z.string(),
|
|
3487
|
+
expires_in: import_zod32.z.number().int()
|
|
3499
3488
|
});
|
|
3500
3489
|
|
|
3501
|
-
// src/_api/generated/cfg_totp/_utils/schemas/
|
|
3490
|
+
// src/_api/generated/cfg_totp/_utils/schemas/TotpVerifyUser.schema.ts
|
|
3502
3491
|
var import_zod33 = require("zod");
|
|
3503
|
-
var
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3492
|
+
var TotpVerifyUserSchema = import_zod33.z.object({
|
|
3493
|
+
id: import_zod33.z.number().int(),
|
|
3494
|
+
email: import_zod33.z.email(),
|
|
3495
|
+
first_name: import_zod33.z.string().max(50).optional(),
|
|
3496
|
+
last_name: import_zod33.z.string().max(50).optional(),
|
|
3497
|
+
full_name: import_zod33.z.string(),
|
|
3498
|
+
initials: import_zod33.z.string(),
|
|
3499
|
+
display_username: import_zod33.z.string(),
|
|
3500
|
+
company: import_zod33.z.string().max(100).optional(),
|
|
3501
|
+
phone: import_zod33.z.string().max(20).optional(),
|
|
3502
|
+
position: import_zod33.z.string().max(100).optional(),
|
|
3503
|
+
language: import_zod33.z.string().max(10).optional(),
|
|
3504
|
+
avatar: import_zod33.z.string().nullable(),
|
|
3505
|
+
is_staff: import_zod33.z.boolean(),
|
|
3506
|
+
is_superuser: import_zod33.z.boolean(),
|
|
3507
|
+
date_joined: import_zod33.z.string().datetime({ offset: true }),
|
|
3508
|
+
last_login: import_zod33.z.string().datetime({ offset: true }).nullable(),
|
|
3509
|
+
unanswered_messages_count: import_zod33.z.number().int()
|
|
3509
3510
|
});
|
|
3510
3511
|
|
|
3511
|
-
// src/_api/generated/cfg_totp/_utils/schemas/
|
|
3512
|
+
// src/_api/generated/cfg_totp/_utils/schemas/VerifyBackupRequest.schema.ts
|
|
3512
3513
|
var import_zod34 = require("zod");
|
|
3513
|
-
var
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
first_name: import_zod34.z.string().max(50).optional(),
|
|
3517
|
-
last_name: import_zod34.z.string().max(50).optional(),
|
|
3518
|
-
full_name: import_zod34.z.string(),
|
|
3519
|
-
initials: import_zod34.z.string(),
|
|
3520
|
-
display_username: import_zod34.z.string(),
|
|
3521
|
-
company: import_zod34.z.string().max(100).optional(),
|
|
3522
|
-
phone: import_zod34.z.string().max(20).optional(),
|
|
3523
|
-
position: import_zod34.z.string().max(100).optional(),
|
|
3524
|
-
language: import_zod34.z.string().max(10).optional(),
|
|
3525
|
-
avatar: import_zod34.z.string().nullable(),
|
|
3526
|
-
is_staff: import_zod34.z.boolean(),
|
|
3527
|
-
is_superuser: import_zod34.z.boolean(),
|
|
3528
|
-
date_joined: import_zod34.z.string().datetime({ offset: true }),
|
|
3529
|
-
last_login: import_zod34.z.string().datetime({ offset: true }).nullable(),
|
|
3530
|
-
unanswered_messages_count: import_zod34.z.number().int()
|
|
3514
|
+
var VerifyBackupRequestSchema = import_zod34.z.object({
|
|
3515
|
+
session_id: import_zod34.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
3516
|
+
backup_code: import_zod34.z.string().min(8).max(8)
|
|
3531
3517
|
});
|
|
3532
3518
|
|
|
3533
|
-
// src/_api/generated/cfg_totp/_utils/schemas/
|
|
3519
|
+
// src/_api/generated/cfg_totp/_utils/schemas/VerifyRequest.schema.ts
|
|
3534
3520
|
var import_zod35 = require("zod");
|
|
3535
|
-
var
|
|
3521
|
+
var VerifyRequestSchema = import_zod35.z.object({
|
|
3536
3522
|
session_id: import_zod35.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
3537
|
-
|
|
3538
|
-
});
|
|
3539
|
-
|
|
3540
|
-
// src/_api/generated/cfg_totp/_utils/schemas/VerifyRequest.schema.ts
|
|
3541
|
-
var import_zod36 = require("zod");
|
|
3542
|
-
var VerifyRequestSchema = import_zod36.z.object({
|
|
3543
|
-
session_id: import_zod36.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
3544
|
-
code: import_zod36.z.string().min(6).max(6)
|
|
3523
|
+
code: import_zod35.z.string().min(6).max(6)
|
|
3545
3524
|
});
|
|
3546
3525
|
|
|
3547
3526
|
// src/_api/generated/cfg_totp/_utils/schemas/VerifyResponse.schema.ts
|
|
3548
|
-
var
|
|
3549
|
-
var VerifyResponseSchema =
|
|
3550
|
-
message:
|
|
3551
|
-
access_token:
|
|
3552
|
-
refresh_token:
|
|
3527
|
+
var import_zod36 = require("zod");
|
|
3528
|
+
var VerifyResponseSchema = import_zod36.z.object({
|
|
3529
|
+
message: import_zod36.z.string(),
|
|
3530
|
+
access_token: import_zod36.z.string(),
|
|
3531
|
+
refresh_token: import_zod36.z.string(),
|
|
3553
3532
|
user: TotpVerifyUserSchema,
|
|
3554
|
-
remaining_backup_codes:
|
|
3555
|
-
warning:
|
|
3533
|
+
remaining_backup_codes: import_zod36.z.number().int().optional(),
|
|
3534
|
+
warning: import_zod36.z.string().optional()
|
|
3556
3535
|
});
|
|
3557
3536
|
|
|
3558
3537
|
// src/_api/generated/cfg_totp/_utils/fetchers/totp__backup_codes.ts
|
|
@@ -4493,6 +4472,17 @@ var useTwoFactorSetup = /* @__PURE__ */ __name((options = {}) => {
|
|
|
4493
4472
|
|
|
4494
4473
|
// src/auth/hooks/useTwoFactorStatus.ts
|
|
4495
4474
|
var import_react10 = require("react");
|
|
4475
|
+
function extractErrorMessage(err, fallback) {
|
|
4476
|
+
if (err instanceof APIError3) {
|
|
4477
|
+
const body = err.response;
|
|
4478
|
+
if (typeof body?.error === "string") return body.error;
|
|
4479
|
+
if (typeof body?.detail === "string") return body.detail;
|
|
4480
|
+
return err.message;
|
|
4481
|
+
}
|
|
4482
|
+
if (err instanceof Error) return err.message;
|
|
4483
|
+
return fallback;
|
|
4484
|
+
}
|
|
4485
|
+
__name(extractErrorMessage, "extractErrorMessage");
|
|
4496
4486
|
var useTwoFactorStatus = /* @__PURE__ */ __name(() => {
|
|
4497
4487
|
const [isLoading, setIsLoading] = (0, import_react10.useState)(false);
|
|
4498
4488
|
const [error, setError] = (0, import_react10.useState)(null);
|
|
@@ -4506,9 +4496,8 @@ var useTwoFactorStatus = /* @__PURE__ */ __name(() => {
|
|
|
4506
4496
|
setError(null);
|
|
4507
4497
|
try {
|
|
4508
4498
|
authLogger.info("Fetching 2FA status...");
|
|
4509
|
-
const response = await apiTotp.totp_management.
|
|
4510
|
-
const
|
|
4511
|
-
const mappedDevices = devices2.map((device) => ({
|
|
4499
|
+
const response = await apiTotp.totp_management.totpDevicesRetrieve();
|
|
4500
|
+
const mappedDevices = response.devices.map((device) => ({
|
|
4512
4501
|
id: device.id,
|
|
4513
4502
|
name: device.name,
|
|
4514
4503
|
createdAt: device.created_at,
|
|
@@ -4516,11 +4505,10 @@ var useTwoFactorStatus = /* @__PURE__ */ __name(() => {
|
|
|
4516
4505
|
isPrimary: device.is_primary
|
|
4517
4506
|
}));
|
|
4518
4507
|
setDevices(mappedDevices);
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
authLogger.info("2FA status:", enabled ? "enabled" : "disabled");
|
|
4508
|
+
setHas2FAEnabled(response.has_2fa_enabled);
|
|
4509
|
+
authLogger.info("2FA status:", response.has_2fa_enabled ? "enabled" : "disabled");
|
|
4522
4510
|
} catch (err) {
|
|
4523
|
-
const errorMessage = err
|
|
4511
|
+
const errorMessage = extractErrorMessage(err, "Failed to fetch 2FA status");
|
|
4524
4512
|
authLogger.error("Failed to fetch 2FA status:", err);
|
|
4525
4513
|
setError(errorMessage);
|
|
4526
4514
|
} finally {
|
|
@@ -4542,7 +4530,7 @@ var useTwoFactorStatus = /* @__PURE__ */ __name(() => {
|
|
|
4542
4530
|
authLogger.info("2FA disabled successfully");
|
|
4543
4531
|
return true;
|
|
4544
4532
|
} catch (err) {
|
|
4545
|
-
const errorMessage = err
|
|
4533
|
+
const errorMessage = extractErrorMessage(err, "Invalid verification code");
|
|
4546
4534
|
authLogger.error("Failed to disable 2FA:", err);
|
|
4547
4535
|
setError(errorMessage);
|
|
4548
4536
|
return false;
|