@djangocfg/api 2.1.57 → 2.1.59
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 +125 -9
- package/dist/auth.cjs +1865 -402
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +352 -76
- package/dist/auth.d.ts +352 -76
- package/dist/auth.mjs +1867 -404
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +1637 -137
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +1394 -282
- package/dist/clients.d.ts +1394 -282
- package/dist/clients.mjs +1637 -137
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +24 -11
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +88 -21
- package/dist/hooks.d.ts +88 -21
- package/dist/hooks.mjs +24 -11
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +38 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +94 -21
- package/dist/index.d.ts +94 -21
- package/dist/index.mjs +38 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/auth/context/AccountsContext.tsx +8 -1
- package/src/auth/context/AuthContext.tsx +31 -8
- package/src/auth/context/types.ts +8 -1
- package/src/auth/hooks/index.ts +29 -5
- package/src/auth/hooks/useAuthForm.ts +292 -226
- package/src/auth/hooks/useAuthFormState.ts +60 -0
- package/src/auth/hooks/useAuthValidation.ts +77 -0
- package/src/auth/hooks/useGithubAuth.ts +26 -5
- package/src/auth/hooks/useTwoFactor.ts +239 -0
- package/src/auth/hooks/useTwoFactorSetup.ts +213 -0
- package/src/auth/index.ts +3 -0
- package/src/auth/types/form.ts +194 -0
- package/src/auth/types/index.ts +28 -0
- package/src/clients.ts +10 -0
- package/src/generated/cfg_accounts/_utils/schemas/OAuthTokenResponse.schema.ts +26 -3
- package/src/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts +26 -3
- package/src/generated/cfg_accounts/accounts/client.ts +4 -1
- package/src/generated/cfg_accounts/accounts/models.ts +15 -6
- package/src/generated/cfg_accounts/accounts__oauth/models.ts +16 -7
- package/src/generated/cfg_accounts/client.ts +5 -2
- package/src/generated/cfg_accounts/http.ts +8 -2
- package/src/generated/cfg_accounts/schema.json +47 -19
- package/src/generated/cfg_centrifugo/client.ts +5 -2
- package/src/generated/cfg_centrifugo/http.ts +8 -2
- package/src/generated/cfg_totp/CLAUDE.md +12 -12
- package/src/generated/cfg_totp/_utils/fetchers/index.ts +3 -3
- package/src/generated/cfg_totp/_utils/fetchers/{totp__2fa_management.ts → totp__totp_management.ts} +3 -3
- package/src/generated/cfg_totp/_utils/fetchers/{totp__2fa_setup.ts → totp__totp_setup.ts} +3 -3
- package/src/generated/cfg_totp/_utils/fetchers/{totp__2fa_verification.ts → totp__totp_verification.ts} +3 -3
- package/src/generated/cfg_totp/_utils/hooks/index.ts +3 -3
- package/src/generated/cfg_totp/_utils/hooks/{totp__2fa_management.ts → totp__totp_management.ts} +2 -2
- package/src/generated/cfg_totp/_utils/hooks/{totp__2fa_setup.ts → totp__totp_setup.ts} +2 -2
- package/src/generated/cfg_totp/_utils/hooks/{totp__2fa_verification.ts → totp__totp_verification.ts} +2 -2
- package/src/generated/cfg_totp/_utils/schemas/DeviceList.schema.ts +1 -1
- package/src/generated/cfg_totp/client.ts +14 -11
- package/src/generated/cfg_totp/http.ts +8 -2
- package/src/generated/cfg_totp/index.ts +16 -16
- package/src/generated/cfg_totp/schema.json +8 -7
- package/src/generated/cfg_totp/{totp__2fa_management → totp__totp_management}/client.ts +2 -2
- package/src/generated/cfg_totp/{totp__2fa_management → totp__totp_management}/models.ts +1 -1
- package/src/generated/cfg_totp/{totp__2fa_setup → totp__totp_setup}/client.ts +4 -4
- package/src/generated/cfg_totp/{totp__2fa_verification → totp__totp_verification}/client.ts +2 -2
- package/src/generated/cfg_webpush/client.ts +5 -2
- package/src/generated/cfg_webpush/http.ts +8 -2
- /package/src/generated/cfg_totp/{totp__2fa_management → totp__totp_management}/index.ts +0 -0
- /package/src/generated/cfg_totp/{totp__2fa_setup → totp__totp_setup}/index.ts +0 -0
- /package/src/generated/cfg_totp/{totp__2fa_setup → totp__totp_setup}/models.ts +0 -0
- /package/src/generated/cfg_totp/{totp__2fa_verification → totp__totp_verification}/index.ts +0 -0
- /package/src/generated/cfg_totp/{totp__2fa_verification → totp__totp_verification}/models.ts +0 -0
package/dist/clients.mjs
CHANGED
|
@@ -162,7 +162,10 @@ var Accounts = class {
|
|
|
162
162
|
return response;
|
|
163
163
|
}
|
|
164
164
|
/**
|
|
165
|
-
* Verify OTP code and return JWT tokens.
|
|
165
|
+
* Verify OTP code and return JWT tokens or 2FA session. If user has 2FA
|
|
166
|
+
* enabled: - Returns requires_2fa=True with session_id - Client must
|
|
167
|
+
* complete 2FA verification at /cfg/totp/verify/ If user has no 2FA: -
|
|
168
|
+
* Returns JWT tokens and user data directly
|
|
166
169
|
*/
|
|
167
170
|
async otpVerifyCreate(data) {
|
|
168
171
|
const response = await this.client.request("POST", "/cfg/accounts/otp/verify/", { body: data });
|
|
@@ -176,7 +179,7 @@ var FetchAdapter = class {
|
|
|
176
179
|
__name(this, "FetchAdapter");
|
|
177
180
|
}
|
|
178
181
|
async request(request) {
|
|
179
|
-
const { method, url, headers, body, params, formData } = request;
|
|
182
|
+
const { method, url, headers, body, params, formData, binaryBody } = request;
|
|
180
183
|
let finalUrl = url;
|
|
181
184
|
if (params) {
|
|
182
185
|
const searchParams = new URLSearchParams();
|
|
@@ -194,6 +197,9 @@ var FetchAdapter = class {
|
|
|
194
197
|
let requestBody;
|
|
195
198
|
if (formData) {
|
|
196
199
|
requestBody = formData;
|
|
200
|
+
} else if (binaryBody) {
|
|
201
|
+
finalHeaders["Content-Type"] = "application/octet-stream";
|
|
202
|
+
requestBody = binaryBody;
|
|
197
203
|
} else if (body) {
|
|
198
204
|
finalHeaders["Content-Type"] = "application/json";
|
|
199
205
|
requestBody = JSON.stringify(body);
|
|
@@ -593,7 +599,7 @@ var APIClient = class {
|
|
|
593
599
|
const headers = {
|
|
594
600
|
...options?.headers || {}
|
|
595
601
|
};
|
|
596
|
-
if (!options?.formData && !headers["Content-Type"]) {
|
|
602
|
+
if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
|
|
597
603
|
headers["Content-Type"] = "application/json";
|
|
598
604
|
}
|
|
599
605
|
if (this.logger) {
|
|
@@ -612,7 +618,8 @@ var APIClient = class {
|
|
|
612
618
|
headers,
|
|
613
619
|
params: options?.params,
|
|
614
620
|
body: options?.body,
|
|
615
|
-
formData: options?.formData
|
|
621
|
+
formData: options?.formData,
|
|
622
|
+
binaryBody: options?.binaryBody
|
|
616
623
|
});
|
|
617
624
|
const duration = Date.now() - startTime;
|
|
618
625
|
if (response.status >= 400) {
|
|
@@ -866,11 +873,14 @@ var OAuthProvidersResponseSchema = z8.object({
|
|
|
866
873
|
// src/generated/cfg_accounts/_utils/schemas/OAuthTokenResponse.schema.ts
|
|
867
874
|
import { z as z9 } from "zod";
|
|
868
875
|
var OAuthTokenResponseSchema = z9.object({
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
876
|
+
requires_2fa: z9.boolean().optional(),
|
|
877
|
+
session_id: z9.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(),
|
|
878
|
+
access: z9.string().nullable().optional(),
|
|
879
|
+
refresh: z9.string().nullable().optional(),
|
|
880
|
+
user: z9.record(z9.string(), z9.any()).nullable().optional(),
|
|
872
881
|
is_new_user: z9.boolean(),
|
|
873
|
-
is_new_connection: z9.boolean()
|
|
882
|
+
is_new_connection: z9.boolean(),
|
|
883
|
+
should_prompt_2fa: z9.boolean().optional()
|
|
874
884
|
});
|
|
875
885
|
|
|
876
886
|
// src/generated/cfg_accounts/_utils/schemas/OTPErrorResponse.schema.ts
|
|
@@ -929,9 +939,12 @@ var UserSchema = z14.object({
|
|
|
929
939
|
|
|
930
940
|
// src/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts
|
|
931
941
|
var OTPVerifyResponseSchema = z15.object({
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
942
|
+
requires_2fa: z15.boolean().optional(),
|
|
943
|
+
session_id: z15.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(),
|
|
944
|
+
refresh: z15.string().nullable().optional(),
|
|
945
|
+
access: z15.string().nullable().optional(),
|
|
946
|
+
user: UserSchema.nullable().optional(),
|
|
947
|
+
should_prompt_2fa: z15.boolean().optional()
|
|
935
948
|
});
|
|
936
949
|
|
|
937
950
|
// src/generated/cfg_accounts/_utils/schemas/PatchedUserProfileUpdateRequest.schema.ts
|
|
@@ -1877,7 +1890,7 @@ var FetchAdapter2 = class {
|
|
|
1877
1890
|
__name(this, "FetchAdapter");
|
|
1878
1891
|
}
|
|
1879
1892
|
async request(request) {
|
|
1880
|
-
const { method, url, headers, body, params, formData } = request;
|
|
1893
|
+
const { method, url, headers, body, params, formData, binaryBody } = request;
|
|
1881
1894
|
let finalUrl = url;
|
|
1882
1895
|
if (params) {
|
|
1883
1896
|
const searchParams = new URLSearchParams();
|
|
@@ -1895,6 +1908,9 @@ var FetchAdapter2 = class {
|
|
|
1895
1908
|
let requestBody;
|
|
1896
1909
|
if (formData) {
|
|
1897
1910
|
requestBody = formData;
|
|
1911
|
+
} else if (binaryBody) {
|
|
1912
|
+
finalHeaders["Content-Type"] = "application/octet-stream";
|
|
1913
|
+
requestBody = binaryBody;
|
|
1898
1914
|
} else if (body) {
|
|
1899
1915
|
finalHeaders["Content-Type"] = "application/json";
|
|
1900
1916
|
requestBody = JSON.stringify(body);
|
|
@@ -2294,7 +2310,7 @@ var APIClient2 = class {
|
|
|
2294
2310
|
const headers = {
|
|
2295
2311
|
...options?.headers || {}
|
|
2296
2312
|
};
|
|
2297
|
-
if (!options?.formData && !headers["Content-Type"]) {
|
|
2313
|
+
if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
|
|
2298
2314
|
headers["Content-Type"] = "application/json";
|
|
2299
2315
|
}
|
|
2300
2316
|
if (this.logger) {
|
|
@@ -2313,7 +2329,8 @@ var APIClient2 = class {
|
|
|
2313
2329
|
headers,
|
|
2314
2330
|
params: options?.params,
|
|
2315
2331
|
body: options?.body,
|
|
2316
|
-
formData: options?.formData
|
|
2332
|
+
formData: options?.formData,
|
|
2333
|
+
binaryBody: options?.binaryBody
|
|
2317
2334
|
});
|
|
2318
2335
|
const duration = Date.now() - startTime;
|
|
2319
2336
|
if (response.status >= 400) {
|
|
@@ -3625,6 +3642,1370 @@ var API2 = class {
|
|
|
3625
3642
|
}
|
|
3626
3643
|
};
|
|
3627
3644
|
|
|
3645
|
+
// src/generated/cfg_totp/totp__backup_codes/client.ts
|
|
3646
|
+
var BackupCodes = class {
|
|
3647
|
+
static {
|
|
3648
|
+
__name(this, "BackupCodes");
|
|
3649
|
+
}
|
|
3650
|
+
constructor(client) {
|
|
3651
|
+
this.client = client;
|
|
3652
|
+
}
|
|
3653
|
+
/**
|
|
3654
|
+
* Get backup codes status for user.
|
|
3655
|
+
*/
|
|
3656
|
+
async totpBackupCodesRetrieve() {
|
|
3657
|
+
const response = await this.client.request("GET", "/cfg/totp/backup-codes/");
|
|
3658
|
+
return response;
|
|
3659
|
+
}
|
|
3660
|
+
/**
|
|
3661
|
+
* Regenerate backup codes. Requires TOTP code for verification.
|
|
3662
|
+
* Invalidates all existing codes.
|
|
3663
|
+
*/
|
|
3664
|
+
async totpBackupCodesRegenerateCreate(data) {
|
|
3665
|
+
const response = await this.client.request("POST", "/cfg/totp/backup-codes/regenerate/", { body: data });
|
|
3666
|
+
return response;
|
|
3667
|
+
}
|
|
3668
|
+
};
|
|
3669
|
+
|
|
3670
|
+
// src/generated/cfg_totp/totp__totp_management/client.ts
|
|
3671
|
+
var TotpManagement = class {
|
|
3672
|
+
static {
|
|
3673
|
+
__name(this, "TotpManagement");
|
|
3674
|
+
}
|
|
3675
|
+
constructor(client) {
|
|
3676
|
+
this.client = client;
|
|
3677
|
+
}
|
|
3678
|
+
/**
|
|
3679
|
+
* List all TOTP devices for user.
|
|
3680
|
+
*/
|
|
3681
|
+
async totpDevicesList(...args) {
|
|
3682
|
+
const isParamsObject = args.length === 1 && typeof args[0] === "object" && args[0] !== null && !Array.isArray(args[0]);
|
|
3683
|
+
let params;
|
|
3684
|
+
if (isParamsObject) {
|
|
3685
|
+
params = args[0];
|
|
3686
|
+
} else {
|
|
3687
|
+
params = { page: args[0], page_size: args[1] };
|
|
3688
|
+
}
|
|
3689
|
+
const response = await this.client.request("GET", "/cfg/totp/devices/", { params });
|
|
3690
|
+
return response;
|
|
3691
|
+
}
|
|
3692
|
+
/**
|
|
3693
|
+
* Completely disable 2FA for account. Requires verification code.
|
|
3694
|
+
*/
|
|
3695
|
+
async totpDisableCreate(data) {
|
|
3696
|
+
const response = await this.client.request("POST", "/cfg/totp/disable/", { body: data });
|
|
3697
|
+
return response;
|
|
3698
|
+
}
|
|
3699
|
+
};
|
|
3700
|
+
|
|
3701
|
+
// src/generated/cfg_totp/totp__totp_setup/client.ts
|
|
3702
|
+
var TotpSetup = class {
|
|
3703
|
+
static {
|
|
3704
|
+
__name(this, "TotpSetup");
|
|
3705
|
+
}
|
|
3706
|
+
constructor(client) {
|
|
3707
|
+
this.client = client;
|
|
3708
|
+
}
|
|
3709
|
+
/**
|
|
3710
|
+
* Start 2FA setup process. Creates a new TOTP device and returns QR code
|
|
3711
|
+
* for scanning.
|
|
3712
|
+
*/
|
|
3713
|
+
async create(data) {
|
|
3714
|
+
const response = await this.client.request("POST", "/cfg/totp/setup/", { body: data });
|
|
3715
|
+
return response;
|
|
3716
|
+
}
|
|
3717
|
+
/**
|
|
3718
|
+
* Confirm 2FA setup with first valid code. Activates the device and
|
|
3719
|
+
* generates backup codes.
|
|
3720
|
+
*/
|
|
3721
|
+
async confirmCreate(data) {
|
|
3722
|
+
const response = await this.client.request("POST", "/cfg/totp/setup/confirm/", { body: data });
|
|
3723
|
+
return response;
|
|
3724
|
+
}
|
|
3725
|
+
};
|
|
3726
|
+
|
|
3727
|
+
// src/generated/cfg_totp/totp__totp_verification/client.ts
|
|
3728
|
+
var TotpVerification = class {
|
|
3729
|
+
static {
|
|
3730
|
+
__name(this, "TotpVerification");
|
|
3731
|
+
}
|
|
3732
|
+
constructor(client) {
|
|
3733
|
+
this.client = client;
|
|
3734
|
+
}
|
|
3735
|
+
/**
|
|
3736
|
+
* Verify TOTP code for 2FA session. Completes authentication and returns
|
|
3737
|
+
* JWT tokens on success.
|
|
3738
|
+
*/
|
|
3739
|
+
async totpVerifyCreate(data) {
|
|
3740
|
+
const response = await this.client.request("POST", "/cfg/totp/verify/", { body: data });
|
|
3741
|
+
return response;
|
|
3742
|
+
}
|
|
3743
|
+
/**
|
|
3744
|
+
* Verify backup recovery code for 2FA session. Alternative verification
|
|
3745
|
+
* method when TOTP device unavailable.
|
|
3746
|
+
*/
|
|
3747
|
+
async totpVerifyBackupCreate(data) {
|
|
3748
|
+
const response = await this.client.request("POST", "/cfg/totp/verify/backup/", { body: data });
|
|
3749
|
+
return response;
|
|
3750
|
+
}
|
|
3751
|
+
};
|
|
3752
|
+
|
|
3753
|
+
// src/generated/cfg_totp/totp/client.ts
|
|
3754
|
+
var Totp = class {
|
|
3755
|
+
static {
|
|
3756
|
+
__name(this, "Totp");
|
|
3757
|
+
}
|
|
3758
|
+
constructor(client) {
|
|
3759
|
+
this.client = client;
|
|
3760
|
+
}
|
|
3761
|
+
/**
|
|
3762
|
+
* Delete a TOTP device. Requires verification code if removing the
|
|
3763
|
+
* last/primary device.
|
|
3764
|
+
*/
|
|
3765
|
+
async devicesDestroy(id) {
|
|
3766
|
+
const response = await this.client.request("DELETE", `/cfg/totp/devices/${id}/`);
|
|
3767
|
+
return;
|
|
3768
|
+
}
|
|
3769
|
+
};
|
|
3770
|
+
|
|
3771
|
+
// src/generated/cfg_totp/http.ts
|
|
3772
|
+
var FetchAdapter3 = class {
|
|
3773
|
+
static {
|
|
3774
|
+
__name(this, "FetchAdapter");
|
|
3775
|
+
}
|
|
3776
|
+
async request(request) {
|
|
3777
|
+
const { method, url, headers, body, params, formData, binaryBody } = request;
|
|
3778
|
+
let finalUrl = url;
|
|
3779
|
+
if (params) {
|
|
3780
|
+
const searchParams = new URLSearchParams();
|
|
3781
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
3782
|
+
if (value !== null && value !== void 0) {
|
|
3783
|
+
searchParams.append(key, String(value));
|
|
3784
|
+
}
|
|
3785
|
+
});
|
|
3786
|
+
const queryString = searchParams.toString();
|
|
3787
|
+
if (queryString) {
|
|
3788
|
+
finalUrl = url.includes("?") ? `${url}&${queryString}` : `${url}?${queryString}`;
|
|
3789
|
+
}
|
|
3790
|
+
}
|
|
3791
|
+
const finalHeaders = { ...headers };
|
|
3792
|
+
let requestBody;
|
|
3793
|
+
if (formData) {
|
|
3794
|
+
requestBody = formData;
|
|
3795
|
+
} else if (binaryBody) {
|
|
3796
|
+
finalHeaders["Content-Type"] = "application/octet-stream";
|
|
3797
|
+
requestBody = binaryBody;
|
|
3798
|
+
} else if (body) {
|
|
3799
|
+
finalHeaders["Content-Type"] = "application/json";
|
|
3800
|
+
requestBody = JSON.stringify(body);
|
|
3801
|
+
}
|
|
3802
|
+
const response = await fetch(finalUrl, {
|
|
3803
|
+
method,
|
|
3804
|
+
headers: finalHeaders,
|
|
3805
|
+
body: requestBody,
|
|
3806
|
+
credentials: "include"
|
|
3807
|
+
// Include Django session cookies
|
|
3808
|
+
});
|
|
3809
|
+
let data = null;
|
|
3810
|
+
const contentType = response.headers.get("content-type");
|
|
3811
|
+
if (response.status !== 204 && contentType?.includes("application/json")) {
|
|
3812
|
+
data = await response.json();
|
|
3813
|
+
} else if (response.status !== 204) {
|
|
3814
|
+
data = await response.text();
|
|
3815
|
+
}
|
|
3816
|
+
const responseHeaders = {};
|
|
3817
|
+
response.headers.forEach((value, key) => {
|
|
3818
|
+
responseHeaders[key] = value;
|
|
3819
|
+
});
|
|
3820
|
+
return {
|
|
3821
|
+
data,
|
|
3822
|
+
status: response.status,
|
|
3823
|
+
statusText: response.statusText,
|
|
3824
|
+
headers: responseHeaders
|
|
3825
|
+
};
|
|
3826
|
+
}
|
|
3827
|
+
};
|
|
3828
|
+
|
|
3829
|
+
// src/generated/cfg_totp/errors.ts
|
|
3830
|
+
var APIError3 = class extends Error {
|
|
3831
|
+
constructor(statusCode, statusText, response, url, message) {
|
|
3832
|
+
super(message || `HTTP ${statusCode}: ${statusText}`);
|
|
3833
|
+
this.statusCode = statusCode;
|
|
3834
|
+
this.statusText = statusText;
|
|
3835
|
+
this.response = response;
|
|
3836
|
+
this.url = url;
|
|
3837
|
+
this.name = "APIError";
|
|
3838
|
+
}
|
|
3839
|
+
static {
|
|
3840
|
+
__name(this, "APIError");
|
|
3841
|
+
}
|
|
3842
|
+
/**
|
|
3843
|
+
* Get error details from response.
|
|
3844
|
+
* DRF typically returns: { "detail": "Error message" } or { "field": ["error1", "error2"] }
|
|
3845
|
+
*/
|
|
3846
|
+
get details() {
|
|
3847
|
+
if (typeof this.response === "object" && this.response !== null) {
|
|
3848
|
+
return this.response;
|
|
3849
|
+
}
|
|
3850
|
+
return null;
|
|
3851
|
+
}
|
|
3852
|
+
/**
|
|
3853
|
+
* Get field-specific validation errors from DRF.
|
|
3854
|
+
* Returns: { "field_name": ["error1", "error2"], ... }
|
|
3855
|
+
*/
|
|
3856
|
+
get fieldErrors() {
|
|
3857
|
+
const details = this.details;
|
|
3858
|
+
if (!details) return null;
|
|
3859
|
+
const fieldErrors = {};
|
|
3860
|
+
for (const [key, value] of Object.entries(details)) {
|
|
3861
|
+
if (Array.isArray(value)) {
|
|
3862
|
+
fieldErrors[key] = value;
|
|
3863
|
+
}
|
|
3864
|
+
}
|
|
3865
|
+
return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
|
|
3866
|
+
}
|
|
3867
|
+
/**
|
|
3868
|
+
* Get single error message from DRF.
|
|
3869
|
+
* Checks for "detail", "message", or first field error.
|
|
3870
|
+
*/
|
|
3871
|
+
get errorMessage() {
|
|
3872
|
+
const details = this.details;
|
|
3873
|
+
if (!details) return this.message;
|
|
3874
|
+
if (details.detail) {
|
|
3875
|
+
return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
|
|
3876
|
+
}
|
|
3877
|
+
if (details.message) {
|
|
3878
|
+
return String(details.message);
|
|
3879
|
+
}
|
|
3880
|
+
const fieldErrors = this.fieldErrors;
|
|
3881
|
+
if (fieldErrors) {
|
|
3882
|
+
const firstField = Object.keys(fieldErrors)[0];
|
|
3883
|
+
if (firstField) {
|
|
3884
|
+
return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
|
|
3885
|
+
}
|
|
3886
|
+
}
|
|
3887
|
+
return this.message;
|
|
3888
|
+
}
|
|
3889
|
+
// Helper methods for common HTTP status codes
|
|
3890
|
+
get isValidationError() {
|
|
3891
|
+
return this.statusCode === 400;
|
|
3892
|
+
}
|
|
3893
|
+
get isAuthError() {
|
|
3894
|
+
return this.statusCode === 401;
|
|
3895
|
+
}
|
|
3896
|
+
get isPermissionError() {
|
|
3897
|
+
return this.statusCode === 403;
|
|
3898
|
+
}
|
|
3899
|
+
get isNotFoundError() {
|
|
3900
|
+
return this.statusCode === 404;
|
|
3901
|
+
}
|
|
3902
|
+
get isServerError() {
|
|
3903
|
+
return this.statusCode >= 500 && this.statusCode < 600;
|
|
3904
|
+
}
|
|
3905
|
+
};
|
|
3906
|
+
var NetworkError3 = class extends Error {
|
|
3907
|
+
constructor(message, url, originalError) {
|
|
3908
|
+
super(message);
|
|
3909
|
+
this.url = url;
|
|
3910
|
+
this.originalError = originalError;
|
|
3911
|
+
this.name = "NetworkError";
|
|
3912
|
+
}
|
|
3913
|
+
static {
|
|
3914
|
+
__name(this, "NetworkError");
|
|
3915
|
+
}
|
|
3916
|
+
};
|
|
3917
|
+
|
|
3918
|
+
// src/generated/cfg_totp/logger.ts
|
|
3919
|
+
import { createConsola as createConsola3 } from "consola";
|
|
3920
|
+
var DEFAULT_CONFIG3 = {
|
|
3921
|
+
enabled: process.env.NODE_ENV !== "production",
|
|
3922
|
+
logRequests: true,
|
|
3923
|
+
logResponses: true,
|
|
3924
|
+
logErrors: true,
|
|
3925
|
+
logBodies: true,
|
|
3926
|
+
logHeaders: false
|
|
3927
|
+
};
|
|
3928
|
+
var SENSITIVE_HEADERS3 = [
|
|
3929
|
+
"authorization",
|
|
3930
|
+
"cookie",
|
|
3931
|
+
"set-cookie",
|
|
3932
|
+
"x-api-key",
|
|
3933
|
+
"x-csrf-token"
|
|
3934
|
+
];
|
|
3935
|
+
var APILogger3 = class {
|
|
3936
|
+
static {
|
|
3937
|
+
__name(this, "APILogger");
|
|
3938
|
+
}
|
|
3939
|
+
constructor(config = {}) {
|
|
3940
|
+
this.config = { ...DEFAULT_CONFIG3, ...config };
|
|
3941
|
+
this.consola = config.consola || createConsola3({
|
|
3942
|
+
level: this.config.enabled ? 4 : 0
|
|
3943
|
+
});
|
|
3944
|
+
}
|
|
3945
|
+
/**
|
|
3946
|
+
* Enable logging
|
|
3947
|
+
*/
|
|
3948
|
+
enable() {
|
|
3949
|
+
this.config.enabled = true;
|
|
3950
|
+
}
|
|
3951
|
+
/**
|
|
3952
|
+
* Disable logging
|
|
3953
|
+
*/
|
|
3954
|
+
disable() {
|
|
3955
|
+
this.config.enabled = false;
|
|
3956
|
+
}
|
|
3957
|
+
/**
|
|
3958
|
+
* Update configuration
|
|
3959
|
+
*/
|
|
3960
|
+
setConfig(config) {
|
|
3961
|
+
this.config = { ...this.config, ...config };
|
|
3962
|
+
}
|
|
3963
|
+
/**
|
|
3964
|
+
* Filter sensitive headers
|
|
3965
|
+
*/
|
|
3966
|
+
filterHeaders(headers) {
|
|
3967
|
+
if (!headers) return {};
|
|
3968
|
+
const filtered = {};
|
|
3969
|
+
Object.keys(headers).forEach((key) => {
|
|
3970
|
+
const lowerKey = key.toLowerCase();
|
|
3971
|
+
if (SENSITIVE_HEADERS3.includes(lowerKey)) {
|
|
3972
|
+
filtered[key] = "***";
|
|
3973
|
+
} else {
|
|
3974
|
+
filtered[key] = headers[key] || "";
|
|
3975
|
+
}
|
|
3976
|
+
});
|
|
3977
|
+
return filtered;
|
|
3978
|
+
}
|
|
3979
|
+
/**
|
|
3980
|
+
* Log request
|
|
3981
|
+
*/
|
|
3982
|
+
logRequest(request) {
|
|
3983
|
+
if (!this.config.enabled || !this.config.logRequests) return;
|
|
3984
|
+
const { method, url, headers, body } = request;
|
|
3985
|
+
this.consola.start(`${method} ${url}`);
|
|
3986
|
+
if (this.config.logHeaders && headers) {
|
|
3987
|
+
this.consola.debug("Headers:", this.filterHeaders(headers));
|
|
3988
|
+
}
|
|
3989
|
+
if (this.config.logBodies && body) {
|
|
3990
|
+
this.consola.debug("Body:", body);
|
|
3991
|
+
}
|
|
3992
|
+
}
|
|
3993
|
+
/**
|
|
3994
|
+
* Log response
|
|
3995
|
+
*/
|
|
3996
|
+
logResponse(request, response) {
|
|
3997
|
+
if (!this.config.enabled || !this.config.logResponses) return;
|
|
3998
|
+
const { method, url } = request;
|
|
3999
|
+
const { status, statusText, data, duration } = response;
|
|
4000
|
+
const statusColor = status >= 500 ? "red" : status >= 400 ? "yellow" : status >= 300 ? "cyan" : "green";
|
|
4001
|
+
this.consola.success(
|
|
4002
|
+
`${method} ${url} ${status} ${statusText} (${duration}ms)`
|
|
4003
|
+
);
|
|
4004
|
+
if (this.config.logBodies && data) {
|
|
4005
|
+
this.consola.debug("Response:", data);
|
|
4006
|
+
}
|
|
4007
|
+
}
|
|
4008
|
+
/**
|
|
4009
|
+
* Log error
|
|
4010
|
+
*/
|
|
4011
|
+
logError(request, error) {
|
|
4012
|
+
if (!this.config.enabled || !this.config.logErrors) return;
|
|
4013
|
+
const { method, url } = request;
|
|
4014
|
+
const { message, statusCode, fieldErrors, duration } = error;
|
|
4015
|
+
this.consola.error(
|
|
4016
|
+
`${method} ${url} ${statusCode || "Network"} Error (${duration}ms)`
|
|
4017
|
+
);
|
|
4018
|
+
this.consola.error("Message:", message);
|
|
4019
|
+
if (fieldErrors && Object.keys(fieldErrors).length > 0) {
|
|
4020
|
+
this.consola.error("Field Errors:");
|
|
4021
|
+
Object.entries(fieldErrors).forEach(([field, errors]) => {
|
|
4022
|
+
errors.forEach((err) => {
|
|
4023
|
+
this.consola.error(` \u2022 ${field}: ${err}`);
|
|
4024
|
+
});
|
|
4025
|
+
});
|
|
4026
|
+
}
|
|
4027
|
+
}
|
|
4028
|
+
/**
|
|
4029
|
+
* Log general info
|
|
4030
|
+
*/
|
|
4031
|
+
info(message, ...args) {
|
|
4032
|
+
if (!this.config.enabled) return;
|
|
4033
|
+
this.consola.info(message, ...args);
|
|
4034
|
+
}
|
|
4035
|
+
/**
|
|
4036
|
+
* Log warning
|
|
4037
|
+
*/
|
|
4038
|
+
warn(message, ...args) {
|
|
4039
|
+
if (!this.config.enabled) return;
|
|
4040
|
+
this.consola.warn(message, ...args);
|
|
4041
|
+
}
|
|
4042
|
+
/**
|
|
4043
|
+
* Log error
|
|
4044
|
+
*/
|
|
4045
|
+
error(message, ...args) {
|
|
4046
|
+
if (!this.config.enabled) return;
|
|
4047
|
+
this.consola.error(message, ...args);
|
|
4048
|
+
}
|
|
4049
|
+
/**
|
|
4050
|
+
* Log debug
|
|
4051
|
+
*/
|
|
4052
|
+
debug(message, ...args) {
|
|
4053
|
+
if (!this.config.enabled) return;
|
|
4054
|
+
this.consola.debug(message, ...args);
|
|
4055
|
+
}
|
|
4056
|
+
/**
|
|
4057
|
+
* Log success
|
|
4058
|
+
*/
|
|
4059
|
+
success(message, ...args) {
|
|
4060
|
+
if (!this.config.enabled) return;
|
|
4061
|
+
this.consola.success(message, ...args);
|
|
4062
|
+
}
|
|
4063
|
+
/**
|
|
4064
|
+
* Create a sub-logger with prefix
|
|
4065
|
+
*/
|
|
4066
|
+
withTag(tag) {
|
|
4067
|
+
return this.consola.withTag(tag);
|
|
4068
|
+
}
|
|
4069
|
+
};
|
|
4070
|
+
var defaultLogger3 = new APILogger3();
|
|
4071
|
+
|
|
4072
|
+
// src/generated/cfg_totp/retry.ts
|
|
4073
|
+
import pRetry3, { AbortError as AbortError3 } from "p-retry";
|
|
4074
|
+
var DEFAULT_RETRY_CONFIG3 = {
|
|
4075
|
+
retries: 3,
|
|
4076
|
+
factor: 2,
|
|
4077
|
+
minTimeout: 1e3,
|
|
4078
|
+
maxTimeout: 6e4,
|
|
4079
|
+
randomize: true,
|
|
4080
|
+
onFailedAttempt: /* @__PURE__ */ __name(() => {
|
|
4081
|
+
}, "onFailedAttempt")
|
|
4082
|
+
};
|
|
4083
|
+
function shouldRetry3(error) {
|
|
4084
|
+
if (error instanceof NetworkError3) {
|
|
4085
|
+
return true;
|
|
4086
|
+
}
|
|
4087
|
+
if (error instanceof APIError3) {
|
|
4088
|
+
const status = error.statusCode;
|
|
4089
|
+
if (status >= 500 && status < 600) {
|
|
4090
|
+
return true;
|
|
4091
|
+
}
|
|
4092
|
+
if (status === 429) {
|
|
4093
|
+
return true;
|
|
4094
|
+
}
|
|
4095
|
+
return false;
|
|
4096
|
+
}
|
|
4097
|
+
return true;
|
|
4098
|
+
}
|
|
4099
|
+
__name(shouldRetry3, "shouldRetry");
|
|
4100
|
+
async function withRetry3(fn, config) {
|
|
4101
|
+
const finalConfig = { ...DEFAULT_RETRY_CONFIG3, ...config };
|
|
4102
|
+
return pRetry3(
|
|
4103
|
+
async () => {
|
|
4104
|
+
try {
|
|
4105
|
+
return await fn();
|
|
4106
|
+
} catch (error) {
|
|
4107
|
+
if (!shouldRetry3(error)) {
|
|
4108
|
+
throw new AbortError3(error);
|
|
4109
|
+
}
|
|
4110
|
+
throw error;
|
|
4111
|
+
}
|
|
4112
|
+
},
|
|
4113
|
+
{
|
|
4114
|
+
retries: finalConfig.retries,
|
|
4115
|
+
factor: finalConfig.factor,
|
|
4116
|
+
minTimeout: finalConfig.minTimeout,
|
|
4117
|
+
maxTimeout: finalConfig.maxTimeout,
|
|
4118
|
+
randomize: finalConfig.randomize,
|
|
4119
|
+
onFailedAttempt: finalConfig.onFailedAttempt ? (error) => {
|
|
4120
|
+
const pRetryError = error;
|
|
4121
|
+
finalConfig.onFailedAttempt({
|
|
4122
|
+
error: pRetryError,
|
|
4123
|
+
attemptNumber: pRetryError.attemptNumber,
|
|
4124
|
+
retriesLeft: pRetryError.retriesLeft
|
|
4125
|
+
});
|
|
4126
|
+
} : void 0
|
|
4127
|
+
}
|
|
4128
|
+
);
|
|
4129
|
+
}
|
|
4130
|
+
__name(withRetry3, "withRetry");
|
|
4131
|
+
|
|
4132
|
+
// src/generated/cfg_totp/client.ts
|
|
4133
|
+
var APIClient3 = class {
|
|
4134
|
+
constructor(baseUrl, options) {
|
|
4135
|
+
this.logger = null;
|
|
4136
|
+
this.retryConfig = null;
|
|
4137
|
+
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
4138
|
+
this.httpClient = options?.httpClient || new FetchAdapter3();
|
|
4139
|
+
if (options?.loggerConfig !== void 0) {
|
|
4140
|
+
this.logger = new APILogger3(options.loggerConfig);
|
|
4141
|
+
}
|
|
4142
|
+
if (options?.retryConfig !== void 0) {
|
|
4143
|
+
this.retryConfig = options.retryConfig;
|
|
4144
|
+
}
|
|
4145
|
+
this.backup_codes = new BackupCodes(this);
|
|
4146
|
+
this.totp_management = new TotpManagement(this);
|
|
4147
|
+
this.totp_setup = new TotpSetup(this);
|
|
4148
|
+
this.totp_verification = new TotpVerification(this);
|
|
4149
|
+
this.totp = new Totp(this);
|
|
4150
|
+
}
|
|
4151
|
+
static {
|
|
4152
|
+
__name(this, "APIClient");
|
|
4153
|
+
}
|
|
4154
|
+
/**
|
|
4155
|
+
* Get CSRF token from cookies (for SessionAuthentication).
|
|
4156
|
+
*
|
|
4157
|
+
* Returns null if cookie doesn't exist (JWT-only auth).
|
|
4158
|
+
*/
|
|
4159
|
+
getCsrfToken() {
|
|
4160
|
+
const name = "csrftoken";
|
|
4161
|
+
const value = `; ${document.cookie}`;
|
|
4162
|
+
const parts = value.split(`; ${name}=`);
|
|
4163
|
+
if (parts.length === 2) {
|
|
4164
|
+
return parts.pop()?.split(";").shift() || null;
|
|
4165
|
+
}
|
|
4166
|
+
return null;
|
|
4167
|
+
}
|
|
4168
|
+
/**
|
|
4169
|
+
* Make HTTP request with Django CSRF and session handling.
|
|
4170
|
+
* Automatically retries on network errors and 5xx server errors.
|
|
4171
|
+
*/
|
|
4172
|
+
async request(method, path, options) {
|
|
4173
|
+
if (this.retryConfig) {
|
|
4174
|
+
return withRetry3(() => this._makeRequest(method, path, options), {
|
|
4175
|
+
...this.retryConfig,
|
|
4176
|
+
onFailedAttempt: /* @__PURE__ */ __name((info) => {
|
|
4177
|
+
if (this.logger) {
|
|
4178
|
+
this.logger.warn(
|
|
4179
|
+
`Retry attempt ${info.attemptNumber}/${info.retriesLeft + info.attemptNumber} for ${method} ${path}: ${info.error.message}`
|
|
4180
|
+
);
|
|
4181
|
+
}
|
|
4182
|
+
this.retryConfig?.onFailedAttempt?.(info);
|
|
4183
|
+
}, "onFailedAttempt")
|
|
4184
|
+
});
|
|
4185
|
+
}
|
|
4186
|
+
return this._makeRequest(method, path, options);
|
|
4187
|
+
}
|
|
4188
|
+
/**
|
|
4189
|
+
* Internal request method (without retry wrapper).
|
|
4190
|
+
* Used by request() method with optional retry logic.
|
|
4191
|
+
*/
|
|
4192
|
+
async _makeRequest(method, path, options) {
|
|
4193
|
+
const url = this.baseUrl ? `${this.baseUrl}${path}` : path;
|
|
4194
|
+
const startTime = Date.now();
|
|
4195
|
+
const headers = {
|
|
4196
|
+
...options?.headers || {}
|
|
4197
|
+
};
|
|
4198
|
+
if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
|
|
4199
|
+
headers["Content-Type"] = "application/json";
|
|
4200
|
+
}
|
|
4201
|
+
if (this.logger) {
|
|
4202
|
+
this.logger.logRequest({
|
|
4203
|
+
method,
|
|
4204
|
+
url,
|
|
4205
|
+
headers,
|
|
4206
|
+
body: options?.formData || options?.body,
|
|
4207
|
+
timestamp: startTime
|
|
4208
|
+
});
|
|
4209
|
+
}
|
|
4210
|
+
try {
|
|
4211
|
+
const response = await this.httpClient.request({
|
|
4212
|
+
method,
|
|
4213
|
+
url,
|
|
4214
|
+
headers,
|
|
4215
|
+
params: options?.params,
|
|
4216
|
+
body: options?.body,
|
|
4217
|
+
formData: options?.formData,
|
|
4218
|
+
binaryBody: options?.binaryBody
|
|
4219
|
+
});
|
|
4220
|
+
const duration = Date.now() - startTime;
|
|
4221
|
+
if (response.status >= 400) {
|
|
4222
|
+
const error = new APIError3(
|
|
4223
|
+
response.status,
|
|
4224
|
+
response.statusText,
|
|
4225
|
+
response.data,
|
|
4226
|
+
url
|
|
4227
|
+
);
|
|
4228
|
+
if (this.logger) {
|
|
4229
|
+
this.logger.logError(
|
|
4230
|
+
{
|
|
4231
|
+
method,
|
|
4232
|
+
url,
|
|
4233
|
+
headers,
|
|
4234
|
+
body: options?.formData || options?.body,
|
|
4235
|
+
timestamp: startTime
|
|
4236
|
+
},
|
|
4237
|
+
{
|
|
4238
|
+
message: error.message,
|
|
4239
|
+
statusCode: response.status,
|
|
4240
|
+
duration,
|
|
4241
|
+
timestamp: Date.now()
|
|
4242
|
+
}
|
|
4243
|
+
);
|
|
4244
|
+
}
|
|
4245
|
+
throw error;
|
|
4246
|
+
}
|
|
4247
|
+
if (this.logger) {
|
|
4248
|
+
this.logger.logResponse(
|
|
4249
|
+
{
|
|
4250
|
+
method,
|
|
4251
|
+
url,
|
|
4252
|
+
headers,
|
|
4253
|
+
body: options?.formData || options?.body,
|
|
4254
|
+
timestamp: startTime
|
|
4255
|
+
},
|
|
4256
|
+
{
|
|
4257
|
+
status: response.status,
|
|
4258
|
+
statusText: response.statusText,
|
|
4259
|
+
data: response.data,
|
|
4260
|
+
duration,
|
|
4261
|
+
timestamp: Date.now()
|
|
4262
|
+
}
|
|
4263
|
+
);
|
|
4264
|
+
}
|
|
4265
|
+
return response.data;
|
|
4266
|
+
} catch (error) {
|
|
4267
|
+
const duration = Date.now() - startTime;
|
|
4268
|
+
if (error instanceof APIError3) {
|
|
4269
|
+
throw error;
|
|
4270
|
+
}
|
|
4271
|
+
const isCORSError = error instanceof TypeError && (error.message.toLowerCase().includes("cors") || error.message.toLowerCase().includes("failed to fetch") || error.message.toLowerCase().includes("network request failed"));
|
|
4272
|
+
if (this.logger) {
|
|
4273
|
+
if (isCORSError) {
|
|
4274
|
+
this.logger.error(`\u{1F6AB} CORS Error: ${method} ${url}`);
|
|
4275
|
+
this.logger.error(` \u2192 ${error instanceof Error ? error.message : String(error)}`);
|
|
4276
|
+
this.logger.error(` \u2192 Configure security_domains parameter on the server`);
|
|
4277
|
+
} else {
|
|
4278
|
+
this.logger.error(`\u26A0\uFE0F Network Error: ${method} ${url}`);
|
|
4279
|
+
this.logger.error(` \u2192 ${error instanceof Error ? error.message : String(error)}`);
|
|
4280
|
+
}
|
|
4281
|
+
}
|
|
4282
|
+
if (typeof window !== "undefined") {
|
|
4283
|
+
try {
|
|
4284
|
+
if (isCORSError) {
|
|
4285
|
+
window.dispatchEvent(new CustomEvent("cors-error", {
|
|
4286
|
+
detail: {
|
|
4287
|
+
url,
|
|
4288
|
+
method,
|
|
4289
|
+
error: error instanceof Error ? error.message : String(error),
|
|
4290
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
4291
|
+
},
|
|
4292
|
+
bubbles: true,
|
|
4293
|
+
cancelable: false
|
|
4294
|
+
}));
|
|
4295
|
+
} else {
|
|
4296
|
+
window.dispatchEvent(new CustomEvent("network-error", {
|
|
4297
|
+
detail: {
|
|
4298
|
+
url,
|
|
4299
|
+
method,
|
|
4300
|
+
error: error instanceof Error ? error.message : String(error),
|
|
4301
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
4302
|
+
},
|
|
4303
|
+
bubbles: true,
|
|
4304
|
+
cancelable: false
|
|
4305
|
+
}));
|
|
4306
|
+
}
|
|
4307
|
+
} catch (eventError) {
|
|
4308
|
+
}
|
|
4309
|
+
}
|
|
4310
|
+
const networkError = error instanceof Error ? new NetworkError3(error.message, url, error) : new NetworkError3("Unknown error", url);
|
|
4311
|
+
if (this.logger) {
|
|
4312
|
+
this.logger.logError(
|
|
4313
|
+
{
|
|
4314
|
+
method,
|
|
4315
|
+
url,
|
|
4316
|
+
headers,
|
|
4317
|
+
body: options?.formData || options?.body,
|
|
4318
|
+
timestamp: startTime
|
|
4319
|
+
},
|
|
4320
|
+
{
|
|
4321
|
+
message: networkError.message,
|
|
4322
|
+
duration,
|
|
4323
|
+
timestamp: Date.now()
|
|
4324
|
+
}
|
|
4325
|
+
);
|
|
4326
|
+
}
|
|
4327
|
+
throw networkError;
|
|
4328
|
+
}
|
|
4329
|
+
}
|
|
4330
|
+
};
|
|
4331
|
+
|
|
4332
|
+
// src/generated/cfg_totp/storage.ts
|
|
4333
|
+
var LocalStorageAdapter3 = class {
|
|
4334
|
+
static {
|
|
4335
|
+
__name(this, "LocalStorageAdapter");
|
|
4336
|
+
}
|
|
4337
|
+
constructor(logger) {
|
|
4338
|
+
this.logger = logger;
|
|
4339
|
+
}
|
|
4340
|
+
getItem(key) {
|
|
4341
|
+
try {
|
|
4342
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
4343
|
+
const value = localStorage.getItem(key);
|
|
4344
|
+
this.logger?.debug(`LocalStorage.getItem("${key}"): ${value ? "found" : "not found"}`);
|
|
4345
|
+
return value;
|
|
4346
|
+
}
|
|
4347
|
+
this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
|
|
4348
|
+
} catch (error) {
|
|
4349
|
+
this.logger?.error("LocalStorage.getItem failed:", error);
|
|
4350
|
+
}
|
|
4351
|
+
return null;
|
|
4352
|
+
}
|
|
4353
|
+
setItem(key, value) {
|
|
4354
|
+
try {
|
|
4355
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
4356
|
+
localStorage.setItem(key, value);
|
|
4357
|
+
this.logger?.debug(`LocalStorage.setItem("${key}"): success`);
|
|
4358
|
+
} else {
|
|
4359
|
+
this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
|
|
4360
|
+
}
|
|
4361
|
+
} catch (error) {
|
|
4362
|
+
this.logger?.error("LocalStorage.setItem failed:", error);
|
|
4363
|
+
}
|
|
4364
|
+
}
|
|
4365
|
+
removeItem(key) {
|
|
4366
|
+
try {
|
|
4367
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
4368
|
+
localStorage.removeItem(key);
|
|
4369
|
+
this.logger?.debug(`LocalStorage.removeItem("${key}"): success`);
|
|
4370
|
+
} else {
|
|
4371
|
+
this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
|
|
4372
|
+
}
|
|
4373
|
+
} catch (error) {
|
|
4374
|
+
this.logger?.error("LocalStorage.removeItem failed:", error);
|
|
4375
|
+
}
|
|
4376
|
+
}
|
|
4377
|
+
};
|
|
4378
|
+
|
|
4379
|
+
// src/generated/cfg_totp/enums.ts
|
|
4380
|
+
var DeviceListStatus = /* @__PURE__ */ ((DeviceListStatus2) => {
|
|
4381
|
+
DeviceListStatus2["PENDING"] = "pending";
|
|
4382
|
+
DeviceListStatus2["ACTIVE"] = "active";
|
|
4383
|
+
DeviceListStatus2["DISABLED"] = "disabled";
|
|
4384
|
+
return DeviceListStatus2;
|
|
4385
|
+
})(DeviceListStatus || {});
|
|
4386
|
+
|
|
4387
|
+
// src/generated/cfg_totp/_utils/schemas/index.ts
|
|
4388
|
+
var schemas_exports3 = {};
|
|
4389
|
+
__export(schemas_exports3, {
|
|
4390
|
+
BackupCodesRegenerateRequestSchema: () => BackupCodesRegenerateRequestSchema,
|
|
4391
|
+
BackupCodesRegenerateResponseSchema: () => BackupCodesRegenerateResponseSchema,
|
|
4392
|
+
BackupCodesStatusSchema: () => BackupCodesStatusSchema,
|
|
4393
|
+
ConfirmSetupRequestSchema: () => ConfirmSetupRequestSchema,
|
|
4394
|
+
ConfirmSetupResponseSchema: () => ConfirmSetupResponseSchema,
|
|
4395
|
+
DeviceListSchema: () => DeviceListSchema,
|
|
4396
|
+
DisableRequestSchema: () => DisableRequestSchema,
|
|
4397
|
+
PaginatedDeviceListListSchema: () => PaginatedDeviceListListSchema,
|
|
4398
|
+
SetupRequestSchema: () => SetupRequestSchema,
|
|
4399
|
+
SetupResponseSchema: () => SetupResponseSchema,
|
|
4400
|
+
VerifyBackupRequestSchema: () => VerifyBackupRequestSchema,
|
|
4401
|
+
VerifyRequestSchema: () => VerifyRequestSchema,
|
|
4402
|
+
VerifyResponseSchema: () => VerifyResponseSchema
|
|
4403
|
+
});
|
|
4404
|
+
|
|
4405
|
+
// src/generated/cfg_totp/_utils/schemas/BackupCodesRegenerateRequest.schema.ts
|
|
4406
|
+
import { z as z55 } from "zod";
|
|
4407
|
+
var BackupCodesRegenerateRequestSchema = z55.object({
|
|
4408
|
+
code: z55.string().min(6).max(6)
|
|
4409
|
+
});
|
|
4410
|
+
|
|
4411
|
+
// src/generated/cfg_totp/_utils/schemas/BackupCodesRegenerateResponse.schema.ts
|
|
4412
|
+
import { z as z56 } from "zod";
|
|
4413
|
+
var BackupCodesRegenerateResponseSchema = z56.object({
|
|
4414
|
+
backup_codes: z56.array(z56.string()),
|
|
4415
|
+
warning: z56.string()
|
|
4416
|
+
});
|
|
4417
|
+
|
|
4418
|
+
// src/generated/cfg_totp/_utils/schemas/BackupCodesStatus.schema.ts
|
|
4419
|
+
import { z as z57 } from "zod";
|
|
4420
|
+
var BackupCodesStatusSchema = z57.object({
|
|
4421
|
+
remaining_count: z57.int(),
|
|
4422
|
+
total_generated: z57.int(),
|
|
4423
|
+
warning: z57.string().nullable().optional()
|
|
4424
|
+
});
|
|
4425
|
+
|
|
4426
|
+
// src/generated/cfg_totp/_utils/schemas/ConfirmSetupRequest.schema.ts
|
|
4427
|
+
import { z as z58 } from "zod";
|
|
4428
|
+
var ConfirmSetupRequestSchema = z58.object({
|
|
4429
|
+
device_id: z58.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
4430
|
+
code: z58.string().min(6).max(6)
|
|
4431
|
+
});
|
|
4432
|
+
|
|
4433
|
+
// src/generated/cfg_totp/_utils/schemas/ConfirmSetupResponse.schema.ts
|
|
4434
|
+
import { z as z59 } from "zod";
|
|
4435
|
+
var ConfirmSetupResponseSchema = z59.object({
|
|
4436
|
+
message: z59.string(),
|
|
4437
|
+
backup_codes: z59.array(z59.string()),
|
|
4438
|
+
backup_codes_warning: z59.string()
|
|
4439
|
+
});
|
|
4440
|
+
|
|
4441
|
+
// src/generated/cfg_totp/_utils/schemas/DeviceList.schema.ts
|
|
4442
|
+
import { z as z60 } from "zod";
|
|
4443
|
+
var DeviceListSchema = z60.object({
|
|
4444
|
+
id: z60.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
4445
|
+
name: z60.string(),
|
|
4446
|
+
is_primary: z60.boolean(),
|
|
4447
|
+
status: z60.nativeEnum(DeviceListStatus),
|
|
4448
|
+
created_at: z60.iso.datetime(),
|
|
4449
|
+
confirmed_at: z60.iso.datetime().nullable(),
|
|
4450
|
+
last_used_at: z60.iso.datetime().nullable()
|
|
4451
|
+
});
|
|
4452
|
+
|
|
4453
|
+
// src/generated/cfg_totp/_utils/schemas/DisableRequest.schema.ts
|
|
4454
|
+
import { z as z61 } from "zod";
|
|
4455
|
+
var DisableRequestSchema = z61.object({
|
|
4456
|
+
code: z61.string().min(6).max(6)
|
|
4457
|
+
});
|
|
4458
|
+
|
|
4459
|
+
// src/generated/cfg_totp/_utils/schemas/PaginatedDeviceListList.schema.ts
|
|
4460
|
+
import { z as z62 } from "zod";
|
|
4461
|
+
var PaginatedDeviceListListSchema = z62.object({
|
|
4462
|
+
count: z62.int(),
|
|
4463
|
+
page: z62.int(),
|
|
4464
|
+
pages: z62.int(),
|
|
4465
|
+
page_size: z62.int(),
|
|
4466
|
+
has_next: z62.boolean(),
|
|
4467
|
+
has_previous: z62.boolean(),
|
|
4468
|
+
next_page: z62.int().nullable().optional(),
|
|
4469
|
+
previous_page: z62.int().nullable().optional(),
|
|
4470
|
+
results: z62.array(DeviceListSchema)
|
|
4471
|
+
});
|
|
4472
|
+
|
|
4473
|
+
// src/generated/cfg_totp/_utils/schemas/SetupRequest.schema.ts
|
|
4474
|
+
import { z as z63 } from "zod";
|
|
4475
|
+
var SetupRequestSchema = z63.object({
|
|
4476
|
+
device_name: z63.string().min(1).max(100).optional()
|
|
4477
|
+
});
|
|
4478
|
+
|
|
4479
|
+
// src/generated/cfg_totp/_utils/schemas/SetupResponse.schema.ts
|
|
4480
|
+
import { z as z64 } from "zod";
|
|
4481
|
+
var SetupResponseSchema = z64.object({
|
|
4482
|
+
device_id: z64.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
4483
|
+
secret: z64.string(),
|
|
4484
|
+
provisioning_uri: z64.string(),
|
|
4485
|
+
qr_code_base64: z64.string(),
|
|
4486
|
+
expires_in: z64.int()
|
|
4487
|
+
});
|
|
4488
|
+
|
|
4489
|
+
// src/generated/cfg_totp/_utils/schemas/VerifyBackupRequest.schema.ts
|
|
4490
|
+
import { z as z65 } from "zod";
|
|
4491
|
+
var VerifyBackupRequestSchema = z65.object({
|
|
4492
|
+
session_id: z65.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
4493
|
+
backup_code: z65.string().min(8).max(8)
|
|
4494
|
+
});
|
|
4495
|
+
|
|
4496
|
+
// src/generated/cfg_totp/_utils/schemas/VerifyRequest.schema.ts
|
|
4497
|
+
import { z as z66 } from "zod";
|
|
4498
|
+
var VerifyRequestSchema = z66.object({
|
|
4499
|
+
session_id: z66.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
4500
|
+
code: z66.string().min(6).max(6)
|
|
4501
|
+
});
|
|
4502
|
+
|
|
4503
|
+
// src/generated/cfg_totp/_utils/schemas/VerifyResponse.schema.ts
|
|
4504
|
+
import { z as z67 } from "zod";
|
|
4505
|
+
var VerifyResponseSchema = z67.object({
|
|
4506
|
+
message: z67.string(),
|
|
4507
|
+
access_token: z67.string(),
|
|
4508
|
+
refresh_token: z67.string(),
|
|
4509
|
+
user: z67.record(z67.string(), z67.any()),
|
|
4510
|
+
remaining_backup_codes: z67.int().optional(),
|
|
4511
|
+
warning: z67.string().optional()
|
|
4512
|
+
});
|
|
4513
|
+
|
|
4514
|
+
// src/generated/cfg_totp/_utils/fetchers/index.ts
|
|
4515
|
+
var fetchers_exports3 = {};
|
|
4516
|
+
__export(fetchers_exports3, {
|
|
4517
|
+
createTotpBackupCodesRegenerateCreate: () => createTotpBackupCodesRegenerateCreate,
|
|
4518
|
+
createTotpDisableCreate: () => createTotpDisableCreate,
|
|
4519
|
+
createTotpSetupConfirmCreate: () => createTotpSetupConfirmCreate,
|
|
4520
|
+
createTotpSetupCreate: () => createTotpSetupCreate,
|
|
4521
|
+
createTotpVerifyBackupCreate: () => createTotpVerifyBackupCreate,
|
|
4522
|
+
createTotpVerifyCreate: () => createTotpVerifyCreate,
|
|
4523
|
+
deleteTotpDevicesDestroy: () => deleteTotpDevicesDestroy,
|
|
4524
|
+
getTotpBackupCodesRetrieve: () => getTotpBackupCodesRetrieve,
|
|
4525
|
+
getTotpDevicesList: () => getTotpDevicesList
|
|
4526
|
+
});
|
|
4527
|
+
|
|
4528
|
+
// src/generated/cfg_totp/api-instance.ts
|
|
4529
|
+
var globalAPI3 = null;
|
|
4530
|
+
var autoConfigAttempted3 = false;
|
|
4531
|
+
function tryAutoConfigureFromEnv3() {
|
|
4532
|
+
if (autoConfigAttempted3) return;
|
|
4533
|
+
autoConfigAttempted3 = true;
|
|
4534
|
+
if (globalAPI3) return;
|
|
4535
|
+
if (typeof process === "undefined" || !process.env) return;
|
|
4536
|
+
const baseUrl = process.env.NEXT_PUBLIC_API_URL || process.env.VITE_API_URL || process.env.REACT_APP_API_URL || process.env.API_URL;
|
|
4537
|
+
if (baseUrl) {
|
|
4538
|
+
globalAPI3 = new API3(baseUrl);
|
|
4539
|
+
}
|
|
4540
|
+
}
|
|
4541
|
+
__name(tryAutoConfigureFromEnv3, "tryAutoConfigureFromEnv");
|
|
4542
|
+
function getAPIInstance3() {
|
|
4543
|
+
tryAutoConfigureFromEnv3();
|
|
4544
|
+
if (!globalAPI3) {
|
|
4545
|
+
throw new Error(
|
|
4546
|
+
'API not configured. Call configureAPI() with your base URL before using fetchers or hooks.\n\nExample:\n import { configureAPI } from "./api-instance"\n configureAPI({ baseUrl: "https://api.example.com" })\n\nOr set environment variable: NEXT_PUBLIC_API_URL, VITE_API_URL, or REACT_APP_API_URL'
|
|
4547
|
+
);
|
|
4548
|
+
}
|
|
4549
|
+
return globalAPI3;
|
|
4550
|
+
}
|
|
4551
|
+
__name(getAPIInstance3, "getAPIInstance");
|
|
4552
|
+
|
|
4553
|
+
// src/generated/cfg_totp/_utils/fetchers/totp.ts
|
|
4554
|
+
async function deleteTotpDevicesDestroy(id, client) {
|
|
4555
|
+
const api = client || getAPIInstance3();
|
|
4556
|
+
const response = await api.totp.devicesDestroy(id);
|
|
4557
|
+
return response;
|
|
4558
|
+
}
|
|
4559
|
+
__name(deleteTotpDevicesDestroy, "deleteTotpDevicesDestroy");
|
|
4560
|
+
|
|
4561
|
+
// src/generated/cfg_totp/_utils/fetchers/totp__backup_codes.ts
|
|
4562
|
+
import { consola as consola9 } from "consola";
|
|
4563
|
+
async function getTotpBackupCodesRetrieve(client) {
|
|
4564
|
+
const api = client || getAPIInstance3();
|
|
4565
|
+
const response = await api.backup_codes.totpBackupCodesRetrieve();
|
|
4566
|
+
try {
|
|
4567
|
+
return BackupCodesStatusSchema.parse(response);
|
|
4568
|
+
} catch (error) {
|
|
4569
|
+
consola9.error("\u274C Zod Validation Failed");
|
|
4570
|
+
consola9.box(`getTotpBackupCodesRetrieve
|
|
4571
|
+
Path: /cfg/totp/backup-codes/
|
|
4572
|
+
Method: GET`);
|
|
4573
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
4574
|
+
consola9.error("Validation Issues:");
|
|
4575
|
+
error.issues.forEach((issue, index) => {
|
|
4576
|
+
consola9.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
4577
|
+
consola9.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
4578
|
+
if (issue.expected) consola9.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
4579
|
+
if (issue.received) consola9.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
4580
|
+
});
|
|
4581
|
+
}
|
|
4582
|
+
consola9.error("Response data:", response);
|
|
4583
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
4584
|
+
try {
|
|
4585
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
4586
|
+
detail: {
|
|
4587
|
+
operation: "getTotpBackupCodesRetrieve",
|
|
4588
|
+
path: "/cfg/totp/backup-codes/",
|
|
4589
|
+
method: "GET",
|
|
4590
|
+
error,
|
|
4591
|
+
response,
|
|
4592
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
4593
|
+
},
|
|
4594
|
+
bubbles: true,
|
|
4595
|
+
cancelable: false
|
|
4596
|
+
});
|
|
4597
|
+
window.dispatchEvent(event);
|
|
4598
|
+
} catch (eventError) {
|
|
4599
|
+
consola9.warn("Failed to dispatch validation error event:", eventError);
|
|
4600
|
+
}
|
|
4601
|
+
}
|
|
4602
|
+
throw error;
|
|
4603
|
+
}
|
|
4604
|
+
}
|
|
4605
|
+
__name(getTotpBackupCodesRetrieve, "getTotpBackupCodesRetrieve");
|
|
4606
|
+
async function createTotpBackupCodesRegenerateCreate(data, client) {
|
|
4607
|
+
const api = client || getAPIInstance3();
|
|
4608
|
+
const response = await api.backup_codes.totpBackupCodesRegenerateCreate(data);
|
|
4609
|
+
try {
|
|
4610
|
+
return BackupCodesRegenerateResponseSchema.parse(response);
|
|
4611
|
+
} catch (error) {
|
|
4612
|
+
consola9.error("\u274C Zod Validation Failed");
|
|
4613
|
+
consola9.box(`createTotpBackupCodesRegenerateCreate
|
|
4614
|
+
Path: /cfg/totp/backup-codes/regenerate/
|
|
4615
|
+
Method: POST`);
|
|
4616
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
4617
|
+
consola9.error("Validation Issues:");
|
|
4618
|
+
error.issues.forEach((issue, index) => {
|
|
4619
|
+
consola9.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
4620
|
+
consola9.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
4621
|
+
if (issue.expected) consola9.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
4622
|
+
if (issue.received) consola9.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
4623
|
+
});
|
|
4624
|
+
}
|
|
4625
|
+
consola9.error("Response data:", response);
|
|
4626
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
4627
|
+
try {
|
|
4628
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
4629
|
+
detail: {
|
|
4630
|
+
operation: "createTotpBackupCodesRegenerateCreate",
|
|
4631
|
+
path: "/cfg/totp/backup-codes/regenerate/",
|
|
4632
|
+
method: "POST",
|
|
4633
|
+
error,
|
|
4634
|
+
response,
|
|
4635
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
4636
|
+
},
|
|
4637
|
+
bubbles: true,
|
|
4638
|
+
cancelable: false
|
|
4639
|
+
});
|
|
4640
|
+
window.dispatchEvent(event);
|
|
4641
|
+
} catch (eventError) {
|
|
4642
|
+
consola9.warn("Failed to dispatch validation error event:", eventError);
|
|
4643
|
+
}
|
|
4644
|
+
}
|
|
4645
|
+
throw error;
|
|
4646
|
+
}
|
|
4647
|
+
}
|
|
4648
|
+
__name(createTotpBackupCodesRegenerateCreate, "createTotpBackupCodesRegenerateCreate");
|
|
4649
|
+
|
|
4650
|
+
// src/generated/cfg_totp/_utils/fetchers/totp__totp_management.ts
|
|
4651
|
+
import { consola as consola10 } from "consola";
|
|
4652
|
+
async function getTotpDevicesList(params, client) {
|
|
4653
|
+
const api = client || getAPIInstance3();
|
|
4654
|
+
const response = await api.totp_management.totpDevicesList(params?.page, params?.page_size);
|
|
4655
|
+
try {
|
|
4656
|
+
return PaginatedDeviceListListSchema.parse(response);
|
|
4657
|
+
} catch (error) {
|
|
4658
|
+
consola10.error("\u274C Zod Validation Failed");
|
|
4659
|
+
consola10.box(`getTotpDevicesList
|
|
4660
|
+
Path: /cfg/totp/devices/
|
|
4661
|
+
Method: GET`);
|
|
4662
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
4663
|
+
consola10.error("Validation Issues:");
|
|
4664
|
+
error.issues.forEach((issue, index) => {
|
|
4665
|
+
consola10.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
4666
|
+
consola10.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
4667
|
+
if (issue.expected) consola10.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
4668
|
+
if (issue.received) consola10.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
4669
|
+
});
|
|
4670
|
+
}
|
|
4671
|
+
consola10.error("Response data:", response);
|
|
4672
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
4673
|
+
try {
|
|
4674
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
4675
|
+
detail: {
|
|
4676
|
+
operation: "getTotpDevicesList",
|
|
4677
|
+
path: "/cfg/totp/devices/",
|
|
4678
|
+
method: "GET",
|
|
4679
|
+
error,
|
|
4680
|
+
response,
|
|
4681
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
4682
|
+
},
|
|
4683
|
+
bubbles: true,
|
|
4684
|
+
cancelable: false
|
|
4685
|
+
});
|
|
4686
|
+
window.dispatchEvent(event);
|
|
4687
|
+
} catch (eventError) {
|
|
4688
|
+
consola10.warn("Failed to dispatch validation error event:", eventError);
|
|
4689
|
+
}
|
|
4690
|
+
}
|
|
4691
|
+
throw error;
|
|
4692
|
+
}
|
|
4693
|
+
}
|
|
4694
|
+
__name(getTotpDevicesList, "getTotpDevicesList");
|
|
4695
|
+
async function createTotpDisableCreate(data, client) {
|
|
4696
|
+
const api = client || getAPIInstance3();
|
|
4697
|
+
const response = await api.totp_management.totpDisableCreate(data);
|
|
4698
|
+
return response;
|
|
4699
|
+
}
|
|
4700
|
+
__name(createTotpDisableCreate, "createTotpDisableCreate");
|
|
4701
|
+
|
|
4702
|
+
// src/generated/cfg_totp/_utils/fetchers/totp__totp_setup.ts
|
|
4703
|
+
import { consola as consola11 } from "consola";
|
|
4704
|
+
async function createTotpSetupCreate(data, client) {
|
|
4705
|
+
const api = client || getAPIInstance3();
|
|
4706
|
+
const response = await api.totp_setup.create(data);
|
|
4707
|
+
try {
|
|
4708
|
+
return SetupResponseSchema.parse(response);
|
|
4709
|
+
} catch (error) {
|
|
4710
|
+
consola11.error("\u274C Zod Validation Failed");
|
|
4711
|
+
consola11.box(`createTotpSetupCreate
|
|
4712
|
+
Path: /cfg/totp/setup/
|
|
4713
|
+
Method: POST`);
|
|
4714
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
4715
|
+
consola11.error("Validation Issues:");
|
|
4716
|
+
error.issues.forEach((issue, index) => {
|
|
4717
|
+
consola11.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
4718
|
+
consola11.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
4719
|
+
if (issue.expected) consola11.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
4720
|
+
if (issue.received) consola11.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
4721
|
+
});
|
|
4722
|
+
}
|
|
4723
|
+
consola11.error("Response data:", response);
|
|
4724
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
4725
|
+
try {
|
|
4726
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
4727
|
+
detail: {
|
|
4728
|
+
operation: "createTotpSetupCreate",
|
|
4729
|
+
path: "/cfg/totp/setup/",
|
|
4730
|
+
method: "POST",
|
|
4731
|
+
error,
|
|
4732
|
+
response,
|
|
4733
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
4734
|
+
},
|
|
4735
|
+
bubbles: true,
|
|
4736
|
+
cancelable: false
|
|
4737
|
+
});
|
|
4738
|
+
window.dispatchEvent(event);
|
|
4739
|
+
} catch (eventError) {
|
|
4740
|
+
consola11.warn("Failed to dispatch validation error event:", eventError);
|
|
4741
|
+
}
|
|
4742
|
+
}
|
|
4743
|
+
throw error;
|
|
4744
|
+
}
|
|
4745
|
+
}
|
|
4746
|
+
__name(createTotpSetupCreate, "createTotpSetupCreate");
|
|
4747
|
+
async function createTotpSetupConfirmCreate(data, client) {
|
|
4748
|
+
const api = client || getAPIInstance3();
|
|
4749
|
+
const response = await api.totp_setup.confirmCreate(data);
|
|
4750
|
+
try {
|
|
4751
|
+
return ConfirmSetupResponseSchema.parse(response);
|
|
4752
|
+
} catch (error) {
|
|
4753
|
+
consola11.error("\u274C Zod Validation Failed");
|
|
4754
|
+
consola11.box(`createTotpSetupConfirmCreate
|
|
4755
|
+
Path: /cfg/totp/setup/confirm/
|
|
4756
|
+
Method: POST`);
|
|
4757
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
4758
|
+
consola11.error("Validation Issues:");
|
|
4759
|
+
error.issues.forEach((issue, index) => {
|
|
4760
|
+
consola11.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
4761
|
+
consola11.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
4762
|
+
if (issue.expected) consola11.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
4763
|
+
if (issue.received) consola11.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
4764
|
+
});
|
|
4765
|
+
}
|
|
4766
|
+
consola11.error("Response data:", response);
|
|
4767
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
4768
|
+
try {
|
|
4769
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
4770
|
+
detail: {
|
|
4771
|
+
operation: "createTotpSetupConfirmCreate",
|
|
4772
|
+
path: "/cfg/totp/setup/confirm/",
|
|
4773
|
+
method: "POST",
|
|
4774
|
+
error,
|
|
4775
|
+
response,
|
|
4776
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
4777
|
+
},
|
|
4778
|
+
bubbles: true,
|
|
4779
|
+
cancelable: false
|
|
4780
|
+
});
|
|
4781
|
+
window.dispatchEvent(event);
|
|
4782
|
+
} catch (eventError) {
|
|
4783
|
+
consola11.warn("Failed to dispatch validation error event:", eventError);
|
|
4784
|
+
}
|
|
4785
|
+
}
|
|
4786
|
+
throw error;
|
|
4787
|
+
}
|
|
4788
|
+
}
|
|
4789
|
+
__name(createTotpSetupConfirmCreate, "createTotpSetupConfirmCreate");
|
|
4790
|
+
|
|
4791
|
+
// src/generated/cfg_totp/_utils/fetchers/totp__totp_verification.ts
|
|
4792
|
+
import { consola as consola12 } from "consola";
|
|
4793
|
+
async function createTotpVerifyCreate(data, client) {
|
|
4794
|
+
const api = client || getAPIInstance3();
|
|
4795
|
+
const response = await api.totp_verification.totpVerifyCreate(data);
|
|
4796
|
+
try {
|
|
4797
|
+
return VerifyResponseSchema.parse(response);
|
|
4798
|
+
} catch (error) {
|
|
4799
|
+
consola12.error("\u274C Zod Validation Failed");
|
|
4800
|
+
consola12.box(`createTotpVerifyCreate
|
|
4801
|
+
Path: /cfg/totp/verify/
|
|
4802
|
+
Method: POST`);
|
|
4803
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
4804
|
+
consola12.error("Validation Issues:");
|
|
4805
|
+
error.issues.forEach((issue, index) => {
|
|
4806
|
+
consola12.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
4807
|
+
consola12.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
4808
|
+
if (issue.expected) consola12.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
4809
|
+
if (issue.received) consola12.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
4810
|
+
});
|
|
4811
|
+
}
|
|
4812
|
+
consola12.error("Response data:", response);
|
|
4813
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
4814
|
+
try {
|
|
4815
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
4816
|
+
detail: {
|
|
4817
|
+
operation: "createTotpVerifyCreate",
|
|
4818
|
+
path: "/cfg/totp/verify/",
|
|
4819
|
+
method: "POST",
|
|
4820
|
+
error,
|
|
4821
|
+
response,
|
|
4822
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
4823
|
+
},
|
|
4824
|
+
bubbles: true,
|
|
4825
|
+
cancelable: false
|
|
4826
|
+
});
|
|
4827
|
+
window.dispatchEvent(event);
|
|
4828
|
+
} catch (eventError) {
|
|
4829
|
+
consola12.warn("Failed to dispatch validation error event:", eventError);
|
|
4830
|
+
}
|
|
4831
|
+
}
|
|
4832
|
+
throw error;
|
|
4833
|
+
}
|
|
4834
|
+
}
|
|
4835
|
+
__name(createTotpVerifyCreate, "createTotpVerifyCreate");
|
|
4836
|
+
async function createTotpVerifyBackupCreate(data, client) {
|
|
4837
|
+
const api = client || getAPIInstance3();
|
|
4838
|
+
const response = await api.totp_verification.totpVerifyBackupCreate(data);
|
|
4839
|
+
try {
|
|
4840
|
+
return VerifyResponseSchema.parse(response);
|
|
4841
|
+
} catch (error) {
|
|
4842
|
+
consola12.error("\u274C Zod Validation Failed");
|
|
4843
|
+
consola12.box(`createTotpVerifyBackupCreate
|
|
4844
|
+
Path: /cfg/totp/verify/backup/
|
|
4845
|
+
Method: POST`);
|
|
4846
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
4847
|
+
consola12.error("Validation Issues:");
|
|
4848
|
+
error.issues.forEach((issue, index) => {
|
|
4849
|
+
consola12.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
4850
|
+
consola12.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
4851
|
+
if (issue.expected) consola12.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
4852
|
+
if (issue.received) consola12.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
4853
|
+
});
|
|
4854
|
+
}
|
|
4855
|
+
consola12.error("Response data:", response);
|
|
4856
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
4857
|
+
try {
|
|
4858
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
4859
|
+
detail: {
|
|
4860
|
+
operation: "createTotpVerifyBackupCreate",
|
|
4861
|
+
path: "/cfg/totp/verify/backup/",
|
|
4862
|
+
method: "POST",
|
|
4863
|
+
error,
|
|
4864
|
+
response,
|
|
4865
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
4866
|
+
},
|
|
4867
|
+
bubbles: true,
|
|
4868
|
+
cancelable: false
|
|
4869
|
+
});
|
|
4870
|
+
window.dispatchEvent(event);
|
|
4871
|
+
} catch (eventError) {
|
|
4872
|
+
consola12.warn("Failed to dispatch validation error event:", eventError);
|
|
4873
|
+
}
|
|
4874
|
+
}
|
|
4875
|
+
throw error;
|
|
4876
|
+
}
|
|
4877
|
+
}
|
|
4878
|
+
__name(createTotpVerifyBackupCreate, "createTotpVerifyBackupCreate");
|
|
4879
|
+
|
|
4880
|
+
// src/generated/cfg_totp/index.ts
|
|
4881
|
+
var TOKEN_KEY3 = "auth_token";
|
|
4882
|
+
var REFRESH_TOKEN_KEY3 = "refresh_token";
|
|
4883
|
+
var API3 = class {
|
|
4884
|
+
constructor(baseUrl, options) {
|
|
4885
|
+
this._token = null;
|
|
4886
|
+
this._refreshToken = null;
|
|
4887
|
+
this.baseUrl = baseUrl;
|
|
4888
|
+
this.options = options;
|
|
4889
|
+
const logger = options?.loggerConfig ? new APILogger3(options.loggerConfig) : void 0;
|
|
4890
|
+
this.storage = options?.storage || new LocalStorageAdapter3(logger);
|
|
4891
|
+
this._loadTokensFromStorage();
|
|
4892
|
+
this._client = new APIClient3(this.baseUrl, {
|
|
4893
|
+
retryConfig: this.options?.retryConfig,
|
|
4894
|
+
loggerConfig: this.options?.loggerConfig
|
|
4895
|
+
});
|
|
4896
|
+
this._injectAuthHeader();
|
|
4897
|
+
this.backup_codes = this._client.backup_codes;
|
|
4898
|
+
this.totp_management = this._client.totp_management;
|
|
4899
|
+
this.totp_setup = this._client.totp_setup;
|
|
4900
|
+
this.totp_verification = this._client.totp_verification;
|
|
4901
|
+
this.totp = this._client.totp;
|
|
4902
|
+
}
|
|
4903
|
+
static {
|
|
4904
|
+
__name(this, "API");
|
|
4905
|
+
}
|
|
4906
|
+
_loadTokensFromStorage() {
|
|
4907
|
+
this._token = this.storage.getItem(TOKEN_KEY3);
|
|
4908
|
+
this._refreshToken = this.storage.getItem(REFRESH_TOKEN_KEY3);
|
|
4909
|
+
}
|
|
4910
|
+
_reinitClients() {
|
|
4911
|
+
this._client = new APIClient3(this.baseUrl, {
|
|
4912
|
+
retryConfig: this.options?.retryConfig,
|
|
4913
|
+
loggerConfig: this.options?.loggerConfig
|
|
4914
|
+
});
|
|
4915
|
+
this._injectAuthHeader();
|
|
4916
|
+
this.backup_codes = this._client.backup_codes;
|
|
4917
|
+
this.totp_management = this._client.totp_management;
|
|
4918
|
+
this.totp_setup = this._client.totp_setup;
|
|
4919
|
+
this.totp_verification = this._client.totp_verification;
|
|
4920
|
+
this.totp = this._client.totp;
|
|
4921
|
+
}
|
|
4922
|
+
_injectAuthHeader() {
|
|
4923
|
+
const originalRequest = this._client.request.bind(this._client);
|
|
4924
|
+
this._client.request = async (method, path, options) => {
|
|
4925
|
+
const token = this.getToken();
|
|
4926
|
+
const mergedOptions = {
|
|
4927
|
+
...options,
|
|
4928
|
+
headers: {
|
|
4929
|
+
...options?.headers || {},
|
|
4930
|
+
...token ? { "Authorization": `Bearer ${token}` } : {}
|
|
4931
|
+
}
|
|
4932
|
+
};
|
|
4933
|
+
return originalRequest(method, path, mergedOptions);
|
|
4934
|
+
};
|
|
4935
|
+
}
|
|
4936
|
+
/**
|
|
4937
|
+
* Get current JWT token
|
|
4938
|
+
*/
|
|
4939
|
+
getToken() {
|
|
4940
|
+
return this.storage.getItem(TOKEN_KEY3);
|
|
4941
|
+
}
|
|
4942
|
+
/**
|
|
4943
|
+
* Get current refresh token
|
|
4944
|
+
*/
|
|
4945
|
+
getRefreshToken() {
|
|
4946
|
+
return this.storage.getItem(REFRESH_TOKEN_KEY3);
|
|
4947
|
+
}
|
|
4948
|
+
/**
|
|
4949
|
+
* Set JWT token and refresh token
|
|
4950
|
+
* @param token - JWT access token
|
|
4951
|
+
* @param refreshToken - JWT refresh token (optional)
|
|
4952
|
+
*/
|
|
4953
|
+
setToken(token, refreshToken) {
|
|
4954
|
+
this._token = token;
|
|
4955
|
+
this.storage.setItem(TOKEN_KEY3, token);
|
|
4956
|
+
if (refreshToken) {
|
|
4957
|
+
this._refreshToken = refreshToken;
|
|
4958
|
+
this.storage.setItem(REFRESH_TOKEN_KEY3, refreshToken);
|
|
4959
|
+
}
|
|
4960
|
+
this._reinitClients();
|
|
4961
|
+
}
|
|
4962
|
+
/**
|
|
4963
|
+
* Clear all tokens
|
|
4964
|
+
*/
|
|
4965
|
+
clearTokens() {
|
|
4966
|
+
this._token = null;
|
|
4967
|
+
this._refreshToken = null;
|
|
4968
|
+
this.storage.removeItem(TOKEN_KEY3);
|
|
4969
|
+
this.storage.removeItem(REFRESH_TOKEN_KEY3);
|
|
4970
|
+
this._reinitClients();
|
|
4971
|
+
}
|
|
4972
|
+
/**
|
|
4973
|
+
* Check if user is authenticated
|
|
4974
|
+
*/
|
|
4975
|
+
isAuthenticated() {
|
|
4976
|
+
return !!this.getToken();
|
|
4977
|
+
}
|
|
4978
|
+
/**
|
|
4979
|
+
* Update base URL and reinitialize clients
|
|
4980
|
+
* @param url - New base URL
|
|
4981
|
+
*/
|
|
4982
|
+
setBaseUrl(url) {
|
|
4983
|
+
this.baseUrl = url;
|
|
4984
|
+
this._reinitClients();
|
|
4985
|
+
}
|
|
4986
|
+
/**
|
|
4987
|
+
* Get current base URL
|
|
4988
|
+
*/
|
|
4989
|
+
getBaseUrl() {
|
|
4990
|
+
return this.baseUrl;
|
|
4991
|
+
}
|
|
4992
|
+
/**
|
|
4993
|
+
* Get OpenAPI schema path
|
|
4994
|
+
* @returns Path to the OpenAPI schema JSON file
|
|
4995
|
+
*
|
|
4996
|
+
* Note: The OpenAPI schema is available in the schema.json file.
|
|
4997
|
+
* You can load it dynamically using:
|
|
4998
|
+
* ```typescript
|
|
4999
|
+
* const schema = await fetch('./schema.json').then(r => r.json());
|
|
5000
|
+
* // or using fs in Node.js:
|
|
5001
|
+
* // const schema = JSON.parse(fs.readFileSync('./schema.json', 'utf-8'));
|
|
5002
|
+
* ```
|
|
5003
|
+
*/
|
|
5004
|
+
getSchemaPath() {
|
|
5005
|
+
return "./schema.json";
|
|
5006
|
+
}
|
|
5007
|
+
};
|
|
5008
|
+
|
|
3628
5009
|
// src/generated/cfg_webpush/webpush__web_push/client.ts
|
|
3629
5010
|
var WebPush = class {
|
|
3630
5011
|
static {
|
|
@@ -3664,12 +5045,12 @@ var WebPush = class {
|
|
|
3664
5045
|
};
|
|
3665
5046
|
|
|
3666
5047
|
// src/generated/cfg_webpush/http.ts
|
|
3667
|
-
var
|
|
5048
|
+
var FetchAdapter4 = class {
|
|
3668
5049
|
static {
|
|
3669
5050
|
__name(this, "FetchAdapter");
|
|
3670
5051
|
}
|
|
3671
5052
|
async request(request) {
|
|
3672
|
-
const { method, url, headers, body, params, formData } = request;
|
|
5053
|
+
const { method, url, headers, body, params, formData, binaryBody } = request;
|
|
3673
5054
|
let finalUrl = url;
|
|
3674
5055
|
if (params) {
|
|
3675
5056
|
const searchParams = new URLSearchParams();
|
|
@@ -3687,6 +5068,9 @@ var FetchAdapter3 = class {
|
|
|
3687
5068
|
let requestBody;
|
|
3688
5069
|
if (formData) {
|
|
3689
5070
|
requestBody = formData;
|
|
5071
|
+
} else if (binaryBody) {
|
|
5072
|
+
finalHeaders["Content-Type"] = "application/octet-stream";
|
|
5073
|
+
requestBody = binaryBody;
|
|
3690
5074
|
} else if (body) {
|
|
3691
5075
|
finalHeaders["Content-Type"] = "application/json";
|
|
3692
5076
|
requestBody = JSON.stringify(body);
|
|
@@ -3719,7 +5103,7 @@ var FetchAdapter3 = class {
|
|
|
3719
5103
|
};
|
|
3720
5104
|
|
|
3721
5105
|
// src/generated/cfg_webpush/errors.ts
|
|
3722
|
-
var
|
|
5106
|
+
var APIError4 = class extends Error {
|
|
3723
5107
|
constructor(statusCode, statusText, response, url, message) {
|
|
3724
5108
|
super(message || `HTTP ${statusCode}: ${statusText}`);
|
|
3725
5109
|
this.statusCode = statusCode;
|
|
@@ -3795,7 +5179,7 @@ var APIError3 = class extends Error {
|
|
|
3795
5179
|
return this.statusCode >= 500 && this.statusCode < 600;
|
|
3796
5180
|
}
|
|
3797
5181
|
};
|
|
3798
|
-
var
|
|
5182
|
+
var NetworkError4 = class extends Error {
|
|
3799
5183
|
constructor(message, url, originalError) {
|
|
3800
5184
|
super(message);
|
|
3801
5185
|
this.url = url;
|
|
@@ -3808,8 +5192,8 @@ var NetworkError3 = class extends Error {
|
|
|
3808
5192
|
};
|
|
3809
5193
|
|
|
3810
5194
|
// src/generated/cfg_webpush/logger.ts
|
|
3811
|
-
import { createConsola as
|
|
3812
|
-
var
|
|
5195
|
+
import { createConsola as createConsola4 } from "consola";
|
|
5196
|
+
var DEFAULT_CONFIG4 = {
|
|
3813
5197
|
enabled: process.env.NODE_ENV !== "production",
|
|
3814
5198
|
logRequests: true,
|
|
3815
5199
|
logResponses: true,
|
|
@@ -3817,20 +5201,20 @@ var DEFAULT_CONFIG3 = {
|
|
|
3817
5201
|
logBodies: true,
|
|
3818
5202
|
logHeaders: false
|
|
3819
5203
|
};
|
|
3820
|
-
var
|
|
5204
|
+
var SENSITIVE_HEADERS4 = [
|
|
3821
5205
|
"authorization",
|
|
3822
5206
|
"cookie",
|
|
3823
5207
|
"set-cookie",
|
|
3824
5208
|
"x-api-key",
|
|
3825
5209
|
"x-csrf-token"
|
|
3826
5210
|
];
|
|
3827
|
-
var
|
|
5211
|
+
var APILogger4 = class {
|
|
3828
5212
|
static {
|
|
3829
5213
|
__name(this, "APILogger");
|
|
3830
5214
|
}
|
|
3831
5215
|
constructor(config = {}) {
|
|
3832
|
-
this.config = { ...
|
|
3833
|
-
this.consola = config.consola ||
|
|
5216
|
+
this.config = { ...DEFAULT_CONFIG4, ...config };
|
|
5217
|
+
this.consola = config.consola || createConsola4({
|
|
3834
5218
|
level: this.config.enabled ? 4 : 0
|
|
3835
5219
|
});
|
|
3836
5220
|
}
|
|
@@ -3860,7 +5244,7 @@ var APILogger3 = class {
|
|
|
3860
5244
|
const filtered = {};
|
|
3861
5245
|
Object.keys(headers).forEach((key) => {
|
|
3862
5246
|
const lowerKey = key.toLowerCase();
|
|
3863
|
-
if (
|
|
5247
|
+
if (SENSITIVE_HEADERS4.includes(lowerKey)) {
|
|
3864
5248
|
filtered[key] = "***";
|
|
3865
5249
|
} else {
|
|
3866
5250
|
filtered[key] = headers[key] || "";
|
|
@@ -3959,11 +5343,11 @@ var APILogger3 = class {
|
|
|
3959
5343
|
return this.consola.withTag(tag);
|
|
3960
5344
|
}
|
|
3961
5345
|
};
|
|
3962
|
-
var
|
|
5346
|
+
var defaultLogger4 = new APILogger4();
|
|
3963
5347
|
|
|
3964
5348
|
// src/generated/cfg_webpush/retry.ts
|
|
3965
|
-
import
|
|
3966
|
-
var
|
|
5349
|
+
import pRetry4, { AbortError as AbortError4 } from "p-retry";
|
|
5350
|
+
var DEFAULT_RETRY_CONFIG4 = {
|
|
3967
5351
|
retries: 3,
|
|
3968
5352
|
factor: 2,
|
|
3969
5353
|
minTimeout: 1e3,
|
|
@@ -3972,11 +5356,11 @@ var DEFAULT_RETRY_CONFIG3 = {
|
|
|
3972
5356
|
onFailedAttempt: /* @__PURE__ */ __name(() => {
|
|
3973
5357
|
}, "onFailedAttempt")
|
|
3974
5358
|
};
|
|
3975
|
-
function
|
|
3976
|
-
if (error instanceof
|
|
5359
|
+
function shouldRetry4(error) {
|
|
5360
|
+
if (error instanceof NetworkError4) {
|
|
3977
5361
|
return true;
|
|
3978
5362
|
}
|
|
3979
|
-
if (error instanceof
|
|
5363
|
+
if (error instanceof APIError4) {
|
|
3980
5364
|
const status = error.statusCode;
|
|
3981
5365
|
if (status >= 500 && status < 600) {
|
|
3982
5366
|
return true;
|
|
@@ -3988,16 +5372,16 @@ function shouldRetry3(error) {
|
|
|
3988
5372
|
}
|
|
3989
5373
|
return true;
|
|
3990
5374
|
}
|
|
3991
|
-
__name(
|
|
3992
|
-
async function
|
|
3993
|
-
const finalConfig = { ...
|
|
3994
|
-
return
|
|
5375
|
+
__name(shouldRetry4, "shouldRetry");
|
|
5376
|
+
async function withRetry4(fn, config) {
|
|
5377
|
+
const finalConfig = { ...DEFAULT_RETRY_CONFIG4, ...config };
|
|
5378
|
+
return pRetry4(
|
|
3995
5379
|
async () => {
|
|
3996
5380
|
try {
|
|
3997
5381
|
return await fn();
|
|
3998
5382
|
} catch (error) {
|
|
3999
|
-
if (!
|
|
4000
|
-
throw new
|
|
5383
|
+
if (!shouldRetry4(error)) {
|
|
5384
|
+
throw new AbortError4(error);
|
|
4001
5385
|
}
|
|
4002
5386
|
throw error;
|
|
4003
5387
|
}
|
|
@@ -4019,17 +5403,17 @@ async function withRetry3(fn, config) {
|
|
|
4019
5403
|
}
|
|
4020
5404
|
);
|
|
4021
5405
|
}
|
|
4022
|
-
__name(
|
|
5406
|
+
__name(withRetry4, "withRetry");
|
|
4023
5407
|
|
|
4024
5408
|
// src/generated/cfg_webpush/client.ts
|
|
4025
|
-
var
|
|
5409
|
+
var APIClient4 = class {
|
|
4026
5410
|
constructor(baseUrl, options) {
|
|
4027
5411
|
this.logger = null;
|
|
4028
5412
|
this.retryConfig = null;
|
|
4029
5413
|
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
4030
|
-
this.httpClient = options?.httpClient || new
|
|
5414
|
+
this.httpClient = options?.httpClient || new FetchAdapter4();
|
|
4031
5415
|
if (options?.loggerConfig !== void 0) {
|
|
4032
|
-
this.logger = new
|
|
5416
|
+
this.logger = new APILogger4(options.loggerConfig);
|
|
4033
5417
|
}
|
|
4034
5418
|
if (options?.retryConfig !== void 0) {
|
|
4035
5419
|
this.retryConfig = options.retryConfig;
|
|
@@ -4059,7 +5443,7 @@ var APIClient3 = class {
|
|
|
4059
5443
|
*/
|
|
4060
5444
|
async request(method, path, options) {
|
|
4061
5445
|
if (this.retryConfig) {
|
|
4062
|
-
return
|
|
5446
|
+
return withRetry4(() => this._makeRequest(method, path, options), {
|
|
4063
5447
|
...this.retryConfig,
|
|
4064
5448
|
onFailedAttempt: /* @__PURE__ */ __name((info) => {
|
|
4065
5449
|
if (this.logger) {
|
|
@@ -4083,7 +5467,7 @@ var APIClient3 = class {
|
|
|
4083
5467
|
const headers = {
|
|
4084
5468
|
...options?.headers || {}
|
|
4085
5469
|
};
|
|
4086
|
-
if (!options?.formData && !headers["Content-Type"]) {
|
|
5470
|
+
if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
|
|
4087
5471
|
headers["Content-Type"] = "application/json";
|
|
4088
5472
|
}
|
|
4089
5473
|
if (this.logger) {
|
|
@@ -4102,11 +5486,12 @@ var APIClient3 = class {
|
|
|
4102
5486
|
headers,
|
|
4103
5487
|
params: options?.params,
|
|
4104
5488
|
body: options?.body,
|
|
4105
|
-
formData: options?.formData
|
|
5489
|
+
formData: options?.formData,
|
|
5490
|
+
binaryBody: options?.binaryBody
|
|
4106
5491
|
});
|
|
4107
5492
|
const duration = Date.now() - startTime;
|
|
4108
5493
|
if (response.status >= 400) {
|
|
4109
|
-
const error = new
|
|
5494
|
+
const error = new APIError4(
|
|
4110
5495
|
response.status,
|
|
4111
5496
|
response.statusText,
|
|
4112
5497
|
response.data,
|
|
@@ -4152,7 +5537,7 @@ var APIClient3 = class {
|
|
|
4152
5537
|
return response.data;
|
|
4153
5538
|
} catch (error) {
|
|
4154
5539
|
const duration = Date.now() - startTime;
|
|
4155
|
-
if (error instanceof
|
|
5540
|
+
if (error instanceof APIError4) {
|
|
4156
5541
|
throw error;
|
|
4157
5542
|
}
|
|
4158
5543
|
const isCORSError = error instanceof TypeError && (error.message.toLowerCase().includes("cors") || error.message.toLowerCase().includes("failed to fetch") || error.message.toLowerCase().includes("network request failed"));
|
|
@@ -4194,7 +5579,7 @@ var APIClient3 = class {
|
|
|
4194
5579
|
} catch (eventError) {
|
|
4195
5580
|
}
|
|
4196
5581
|
}
|
|
4197
|
-
const networkError = error instanceof Error ? new
|
|
5582
|
+
const networkError = error instanceof Error ? new NetworkError4(error.message, url, error) : new NetworkError4("Unknown error", url);
|
|
4198
5583
|
if (this.logger) {
|
|
4199
5584
|
this.logger.logError(
|
|
4200
5585
|
{
|
|
@@ -4217,7 +5602,7 @@ var APIClient3 = class {
|
|
|
4217
5602
|
};
|
|
4218
5603
|
|
|
4219
5604
|
// src/generated/cfg_webpush/storage.ts
|
|
4220
|
-
var
|
|
5605
|
+
var LocalStorageAdapter4 = class {
|
|
4221
5606
|
static {
|
|
4222
5607
|
__name(this, "LocalStorageAdapter");
|
|
4223
5608
|
}
|
|
@@ -4264,8 +5649,8 @@ var LocalStorageAdapter3 = class {
|
|
|
4264
5649
|
};
|
|
4265
5650
|
|
|
4266
5651
|
// src/generated/cfg_webpush/_utils/schemas/index.ts
|
|
4267
|
-
var
|
|
4268
|
-
__export(
|
|
5652
|
+
var schemas_exports4 = {};
|
|
5653
|
+
__export(schemas_exports4, {
|
|
4269
5654
|
SendPushRequestRequestSchema: () => SendPushRequestRequestSchema,
|
|
4270
5655
|
SendPushResponseSchema: () => SendPushResponseSchema,
|
|
4271
5656
|
SubscribeRequestRequestSchema: () => SubscribeRequestRequestSchema,
|
|
@@ -4274,99 +5659,99 @@ __export(schemas_exports3, {
|
|
|
4274
5659
|
});
|
|
4275
5660
|
|
|
4276
5661
|
// src/generated/cfg_webpush/_utils/schemas/SendPushRequestRequest.schema.ts
|
|
4277
|
-
import { z as
|
|
4278
|
-
var SendPushRequestRequestSchema =
|
|
4279
|
-
title:
|
|
4280
|
-
body:
|
|
4281
|
-
icon:
|
|
4282
|
-
url:
|
|
5662
|
+
import { z as z68 } from "zod";
|
|
5663
|
+
var SendPushRequestRequestSchema = z68.object({
|
|
5664
|
+
title: z68.string().min(1).max(255),
|
|
5665
|
+
body: z68.string().min(1),
|
|
5666
|
+
icon: z68.union([z68.url(), z68.literal("")]).nullable().optional(),
|
|
5667
|
+
url: z68.union([z68.url(), z68.literal("")]).nullable().optional()
|
|
4283
5668
|
});
|
|
4284
5669
|
|
|
4285
5670
|
// src/generated/cfg_webpush/_utils/schemas/SendPushResponse.schema.ts
|
|
4286
|
-
import { z as
|
|
4287
|
-
var SendPushResponseSchema =
|
|
4288
|
-
success:
|
|
4289
|
-
sent_to:
|
|
5671
|
+
import { z as z69 } from "zod";
|
|
5672
|
+
var SendPushResponseSchema = z69.object({
|
|
5673
|
+
success: z69.boolean(),
|
|
5674
|
+
sent_to: z69.int()
|
|
4290
5675
|
});
|
|
4291
5676
|
|
|
4292
5677
|
// src/generated/cfg_webpush/_utils/schemas/SubscribeRequestRequest.schema.ts
|
|
4293
|
-
import { z as
|
|
4294
|
-
var SubscribeRequestRequestSchema =
|
|
4295
|
-
endpoint:
|
|
4296
|
-
keys:
|
|
5678
|
+
import { z as z70 } from "zod";
|
|
5679
|
+
var SubscribeRequestRequestSchema = z70.object({
|
|
5680
|
+
endpoint: z70.union([z70.url(), z70.literal("")]),
|
|
5681
|
+
keys: z70.record(z70.string(), z70.string().min(1))
|
|
4297
5682
|
});
|
|
4298
5683
|
|
|
4299
5684
|
// src/generated/cfg_webpush/_utils/schemas/SubscribeResponse.schema.ts
|
|
4300
|
-
import { z as
|
|
4301
|
-
var SubscribeResponseSchema =
|
|
4302
|
-
success:
|
|
4303
|
-
subscription_id:
|
|
4304
|
-
created:
|
|
5685
|
+
import { z as z71 } from "zod";
|
|
5686
|
+
var SubscribeResponseSchema = z71.object({
|
|
5687
|
+
success: z71.boolean(),
|
|
5688
|
+
subscription_id: z71.int(),
|
|
5689
|
+
created: z71.boolean()
|
|
4305
5690
|
});
|
|
4306
5691
|
|
|
4307
5692
|
// src/generated/cfg_webpush/_utils/schemas/VapidPublicKeyResponse.schema.ts
|
|
4308
|
-
import { z as
|
|
4309
|
-
var VapidPublicKeyResponseSchema =
|
|
4310
|
-
publicKey:
|
|
5693
|
+
import { z as z72 } from "zod";
|
|
5694
|
+
var VapidPublicKeyResponseSchema = z72.object({
|
|
5695
|
+
publicKey: z72.string()
|
|
4311
5696
|
});
|
|
4312
5697
|
|
|
4313
5698
|
// src/generated/cfg_webpush/_utils/fetchers/index.ts
|
|
4314
|
-
var
|
|
4315
|
-
__export(
|
|
5699
|
+
var fetchers_exports4 = {};
|
|
5700
|
+
__export(fetchers_exports4, {
|
|
4316
5701
|
createWebpushSendCreate: () => createWebpushSendCreate,
|
|
4317
5702
|
createWebpushSubscribeCreate: () => createWebpushSubscribeCreate,
|
|
4318
5703
|
getWebpushVapidRetrieve: () => getWebpushVapidRetrieve
|
|
4319
5704
|
});
|
|
4320
5705
|
|
|
4321
5706
|
// src/generated/cfg_webpush/_utils/fetchers/webpush__web_push.ts
|
|
4322
|
-
import { consola as
|
|
5707
|
+
import { consola as consola13 } from "consola";
|
|
4323
5708
|
|
|
4324
5709
|
// src/generated/cfg_webpush/api-instance.ts
|
|
4325
|
-
var
|
|
4326
|
-
var
|
|
4327
|
-
function
|
|
4328
|
-
if (
|
|
4329
|
-
|
|
4330
|
-
if (
|
|
5710
|
+
var globalAPI4 = null;
|
|
5711
|
+
var autoConfigAttempted4 = false;
|
|
5712
|
+
function tryAutoConfigureFromEnv4() {
|
|
5713
|
+
if (autoConfigAttempted4) return;
|
|
5714
|
+
autoConfigAttempted4 = true;
|
|
5715
|
+
if (globalAPI4) return;
|
|
4331
5716
|
if (typeof process === "undefined" || !process.env) return;
|
|
4332
5717
|
const baseUrl = process.env.NEXT_PUBLIC_API_URL || process.env.VITE_API_URL || process.env.REACT_APP_API_URL || process.env.API_URL;
|
|
4333
5718
|
if (baseUrl) {
|
|
4334
|
-
|
|
5719
|
+
globalAPI4 = new API4(baseUrl);
|
|
4335
5720
|
}
|
|
4336
5721
|
}
|
|
4337
|
-
__name(
|
|
4338
|
-
function
|
|
4339
|
-
|
|
4340
|
-
if (!
|
|
5722
|
+
__name(tryAutoConfigureFromEnv4, "tryAutoConfigureFromEnv");
|
|
5723
|
+
function getAPIInstance4() {
|
|
5724
|
+
tryAutoConfigureFromEnv4();
|
|
5725
|
+
if (!globalAPI4) {
|
|
4341
5726
|
throw new Error(
|
|
4342
5727
|
'API not configured. Call configureAPI() with your base URL before using fetchers or hooks.\n\nExample:\n import { configureAPI } from "./api-instance"\n configureAPI({ baseUrl: "https://api.example.com" })\n\nOr set environment variable: NEXT_PUBLIC_API_URL, VITE_API_URL, or REACT_APP_API_URL'
|
|
4343
5728
|
);
|
|
4344
5729
|
}
|
|
4345
|
-
return
|
|
5730
|
+
return globalAPI4;
|
|
4346
5731
|
}
|
|
4347
|
-
__name(
|
|
5732
|
+
__name(getAPIInstance4, "getAPIInstance");
|
|
4348
5733
|
|
|
4349
5734
|
// src/generated/cfg_webpush/_utils/fetchers/webpush__web_push.ts
|
|
4350
5735
|
async function createWebpushSendCreate(data, client) {
|
|
4351
|
-
const api = client ||
|
|
5736
|
+
const api = client || getAPIInstance4();
|
|
4352
5737
|
const response = await api.web_push.webpushSendCreate(data);
|
|
4353
5738
|
try {
|
|
4354
5739
|
return SendPushResponseSchema.parse(response);
|
|
4355
5740
|
} catch (error) {
|
|
4356
|
-
|
|
4357
|
-
|
|
5741
|
+
consola13.error("\u274C Zod Validation Failed");
|
|
5742
|
+
consola13.box(`createWebpushSendCreate
|
|
4358
5743
|
Path: /cfg/webpush/send/
|
|
4359
5744
|
Method: POST`);
|
|
4360
5745
|
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
4361
|
-
|
|
5746
|
+
consola13.error("Validation Issues:");
|
|
4362
5747
|
error.issues.forEach((issue, index) => {
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
if (issue.expected)
|
|
4366
|
-
if (issue.received)
|
|
5748
|
+
consola13.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
5749
|
+
consola13.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
5750
|
+
if (issue.expected) consola13.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
5751
|
+
if (issue.received) consola13.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
4367
5752
|
});
|
|
4368
5753
|
}
|
|
4369
|
-
|
|
5754
|
+
consola13.error("Response data:", response);
|
|
4370
5755
|
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
4371
5756
|
try {
|
|
4372
5757
|
const event = new CustomEvent("zod-validation-error", {
|
|
@@ -4383,7 +5768,7 @@ Method: POST`);
|
|
|
4383
5768
|
});
|
|
4384
5769
|
window.dispatchEvent(event);
|
|
4385
5770
|
} catch (eventError) {
|
|
4386
|
-
|
|
5771
|
+
consola13.warn("Failed to dispatch validation error event:", eventError);
|
|
4387
5772
|
}
|
|
4388
5773
|
}
|
|
4389
5774
|
throw error;
|
|
@@ -4391,25 +5776,25 @@ Method: POST`);
|
|
|
4391
5776
|
}
|
|
4392
5777
|
__name(createWebpushSendCreate, "createWebpushSendCreate");
|
|
4393
5778
|
async function createWebpushSubscribeCreate(data, client) {
|
|
4394
|
-
const api = client ||
|
|
5779
|
+
const api = client || getAPIInstance4();
|
|
4395
5780
|
const response = await api.web_push.webpushSubscribeCreate(data);
|
|
4396
5781
|
try {
|
|
4397
5782
|
return SubscribeResponseSchema.parse(response);
|
|
4398
5783
|
} catch (error) {
|
|
4399
|
-
|
|
4400
|
-
|
|
5784
|
+
consola13.error("\u274C Zod Validation Failed");
|
|
5785
|
+
consola13.box(`createWebpushSubscribeCreate
|
|
4401
5786
|
Path: /cfg/webpush/subscribe/
|
|
4402
5787
|
Method: POST`);
|
|
4403
5788
|
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
4404
|
-
|
|
5789
|
+
consola13.error("Validation Issues:");
|
|
4405
5790
|
error.issues.forEach((issue, index) => {
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
if (issue.expected)
|
|
4409
|
-
if (issue.received)
|
|
5791
|
+
consola13.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
5792
|
+
consola13.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
5793
|
+
if (issue.expected) consola13.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
5794
|
+
if (issue.received) consola13.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
4410
5795
|
});
|
|
4411
5796
|
}
|
|
4412
|
-
|
|
5797
|
+
consola13.error("Response data:", response);
|
|
4413
5798
|
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
4414
5799
|
try {
|
|
4415
5800
|
const event = new CustomEvent("zod-validation-error", {
|
|
@@ -4426,7 +5811,7 @@ Method: POST`);
|
|
|
4426
5811
|
});
|
|
4427
5812
|
window.dispatchEvent(event);
|
|
4428
5813
|
} catch (eventError) {
|
|
4429
|
-
|
|
5814
|
+
consola13.warn("Failed to dispatch validation error event:", eventError);
|
|
4430
5815
|
}
|
|
4431
5816
|
}
|
|
4432
5817
|
throw error;
|
|
@@ -4434,25 +5819,25 @@ Method: POST`);
|
|
|
4434
5819
|
}
|
|
4435
5820
|
__name(createWebpushSubscribeCreate, "createWebpushSubscribeCreate");
|
|
4436
5821
|
async function getWebpushVapidRetrieve(client) {
|
|
4437
|
-
const api = client ||
|
|
5822
|
+
const api = client || getAPIInstance4();
|
|
4438
5823
|
const response = await api.web_push.webpushVapidRetrieve();
|
|
4439
5824
|
try {
|
|
4440
5825
|
return VapidPublicKeyResponseSchema.parse(response);
|
|
4441
5826
|
} catch (error) {
|
|
4442
|
-
|
|
4443
|
-
|
|
5827
|
+
consola13.error("\u274C Zod Validation Failed");
|
|
5828
|
+
consola13.box(`getWebpushVapidRetrieve
|
|
4444
5829
|
Path: /cfg/webpush/vapid/
|
|
4445
5830
|
Method: GET`);
|
|
4446
5831
|
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
4447
|
-
|
|
5832
|
+
consola13.error("Validation Issues:");
|
|
4448
5833
|
error.issues.forEach((issue, index) => {
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
if (issue.expected)
|
|
4452
|
-
if (issue.received)
|
|
5834
|
+
consola13.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
5835
|
+
consola13.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
5836
|
+
if (issue.expected) consola13.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
5837
|
+
if (issue.received) consola13.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
4453
5838
|
});
|
|
4454
5839
|
}
|
|
4455
|
-
|
|
5840
|
+
consola13.error("Response data:", response);
|
|
4456
5841
|
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
4457
5842
|
try {
|
|
4458
5843
|
const event = new CustomEvent("zod-validation-error", {
|
|
@@ -4469,7 +5854,7 @@ Method: GET`);
|
|
|
4469
5854
|
});
|
|
4470
5855
|
window.dispatchEvent(event);
|
|
4471
5856
|
} catch (eventError) {
|
|
4472
|
-
|
|
5857
|
+
consola13.warn("Failed to dispatch validation error event:", eventError);
|
|
4473
5858
|
}
|
|
4474
5859
|
}
|
|
4475
5860
|
throw error;
|
|
@@ -4478,18 +5863,18 @@ Method: GET`);
|
|
|
4478
5863
|
__name(getWebpushVapidRetrieve, "getWebpushVapidRetrieve");
|
|
4479
5864
|
|
|
4480
5865
|
// src/generated/cfg_webpush/index.ts
|
|
4481
|
-
var
|
|
4482
|
-
var
|
|
4483
|
-
var
|
|
5866
|
+
var TOKEN_KEY4 = "auth_token";
|
|
5867
|
+
var REFRESH_TOKEN_KEY4 = "refresh_token";
|
|
5868
|
+
var API4 = class {
|
|
4484
5869
|
constructor(baseUrl, options) {
|
|
4485
5870
|
this._token = null;
|
|
4486
5871
|
this._refreshToken = null;
|
|
4487
5872
|
this.baseUrl = baseUrl;
|
|
4488
5873
|
this.options = options;
|
|
4489
|
-
const logger = options?.loggerConfig ? new
|
|
4490
|
-
this.storage = options?.storage || new
|
|
5874
|
+
const logger = options?.loggerConfig ? new APILogger4(options.loggerConfig) : void 0;
|
|
5875
|
+
this.storage = options?.storage || new LocalStorageAdapter4(logger);
|
|
4491
5876
|
this._loadTokensFromStorage();
|
|
4492
|
-
this._client = new
|
|
5877
|
+
this._client = new APIClient4(this.baseUrl, {
|
|
4493
5878
|
retryConfig: this.options?.retryConfig,
|
|
4494
5879
|
loggerConfig: this.options?.loggerConfig
|
|
4495
5880
|
});
|
|
@@ -4500,11 +5885,11 @@ var API3 = class {
|
|
|
4500
5885
|
__name(this, "API");
|
|
4501
5886
|
}
|
|
4502
5887
|
_loadTokensFromStorage() {
|
|
4503
|
-
this._token = this.storage.getItem(
|
|
4504
|
-
this._refreshToken = this.storage.getItem(
|
|
5888
|
+
this._token = this.storage.getItem(TOKEN_KEY4);
|
|
5889
|
+
this._refreshToken = this.storage.getItem(REFRESH_TOKEN_KEY4);
|
|
4505
5890
|
}
|
|
4506
5891
|
_reinitClients() {
|
|
4507
|
-
this._client = new
|
|
5892
|
+
this._client = new APIClient4(this.baseUrl, {
|
|
4508
5893
|
retryConfig: this.options?.retryConfig,
|
|
4509
5894
|
loggerConfig: this.options?.loggerConfig
|
|
4510
5895
|
});
|
|
@@ -4529,13 +5914,13 @@ var API3 = class {
|
|
|
4529
5914
|
* Get current JWT token
|
|
4530
5915
|
*/
|
|
4531
5916
|
getToken() {
|
|
4532
|
-
return this.storage.getItem(
|
|
5917
|
+
return this.storage.getItem(TOKEN_KEY4);
|
|
4533
5918
|
}
|
|
4534
5919
|
/**
|
|
4535
5920
|
* Get current refresh token
|
|
4536
5921
|
*/
|
|
4537
5922
|
getRefreshToken() {
|
|
4538
|
-
return this.storage.getItem(
|
|
5923
|
+
return this.storage.getItem(REFRESH_TOKEN_KEY4);
|
|
4539
5924
|
}
|
|
4540
5925
|
/**
|
|
4541
5926
|
* Set JWT token and refresh token
|
|
@@ -4544,10 +5929,10 @@ var API3 = class {
|
|
|
4544
5929
|
*/
|
|
4545
5930
|
setToken(token, refreshToken) {
|
|
4546
5931
|
this._token = token;
|
|
4547
|
-
this.storage.setItem(
|
|
5932
|
+
this.storage.setItem(TOKEN_KEY4, token);
|
|
4548
5933
|
if (refreshToken) {
|
|
4549
5934
|
this._refreshToken = refreshToken;
|
|
4550
|
-
this.storage.setItem(
|
|
5935
|
+
this.storage.setItem(REFRESH_TOKEN_KEY4, refreshToken);
|
|
4551
5936
|
}
|
|
4552
5937
|
this._reinitClients();
|
|
4553
5938
|
}
|
|
@@ -4557,8 +5942,8 @@ var API3 = class {
|
|
|
4557
5942
|
clearTokens() {
|
|
4558
5943
|
this._token = null;
|
|
4559
5944
|
this._refreshToken = null;
|
|
4560
|
-
this.storage.removeItem(
|
|
4561
|
-
this.storage.removeItem(
|
|
5945
|
+
this.storage.removeItem(TOKEN_KEY4);
|
|
5946
|
+
this.storage.removeItem(REFRESH_TOKEN_KEY4);
|
|
4562
5947
|
this._reinitClients();
|
|
4563
5948
|
}
|
|
4564
5949
|
/**
|
|
@@ -4924,12 +6309,122 @@ function useCreateCentrifugoTestingSendAckCreate() {
|
|
|
4924
6309
|
}
|
|
4925
6310
|
__name(useCreateCentrifugoTestingSendAckCreate, "useCreateCentrifugoTestingSendAckCreate");
|
|
4926
6311
|
|
|
6312
|
+
// src/generated/cfg_totp/_utils/hooks/index.ts
|
|
6313
|
+
var hooks_exports3 = {};
|
|
6314
|
+
__export(hooks_exports3, {
|
|
6315
|
+
useCreateTotpBackupCodesRegenerateCreate: () => useCreateTotpBackupCodesRegenerateCreate,
|
|
6316
|
+
useCreateTotpDisableCreate: () => useCreateTotpDisableCreate,
|
|
6317
|
+
useCreateTotpSetupConfirmCreate: () => useCreateTotpSetupConfirmCreate,
|
|
6318
|
+
useCreateTotpSetupCreate: () => useCreateTotpSetupCreate,
|
|
6319
|
+
useCreateTotpVerifyBackupCreate: () => useCreateTotpVerifyBackupCreate,
|
|
6320
|
+
useCreateTotpVerifyCreate: () => useCreateTotpVerifyCreate,
|
|
6321
|
+
useDeleteTotpDevicesDestroy: () => useDeleteTotpDevicesDestroy,
|
|
6322
|
+
useTotpBackupCodesRetrieve: () => useTotpBackupCodesRetrieve,
|
|
6323
|
+
useTotpDevicesList: () => useTotpDevicesList
|
|
6324
|
+
});
|
|
6325
|
+
|
|
6326
|
+
// src/generated/cfg_totp/_utils/hooks/totp__backup_codes.ts
|
|
6327
|
+
import useSWR6 from "swr";
|
|
6328
|
+
import { useSWRConfig as useSWRConfig8 } from "swr";
|
|
6329
|
+
function useTotpBackupCodesRetrieve(client) {
|
|
6330
|
+
return useSWR6(
|
|
6331
|
+
"cfg-totp-backup-code",
|
|
6332
|
+
() => getTotpBackupCodesRetrieve(client)
|
|
6333
|
+
);
|
|
6334
|
+
}
|
|
6335
|
+
__name(useTotpBackupCodesRetrieve, "useTotpBackupCodesRetrieve");
|
|
6336
|
+
function useCreateTotpBackupCodesRegenerateCreate() {
|
|
6337
|
+
const { mutate } = useSWRConfig8();
|
|
6338
|
+
return async (data, client) => {
|
|
6339
|
+
const result = await createTotpBackupCodesRegenerateCreate(data, client);
|
|
6340
|
+
mutate("cfg-totp-backup-codes-regenerate");
|
|
6341
|
+
return result;
|
|
6342
|
+
};
|
|
6343
|
+
}
|
|
6344
|
+
__name(useCreateTotpBackupCodesRegenerateCreate, "useCreateTotpBackupCodesRegenerateCreate");
|
|
6345
|
+
|
|
6346
|
+
// src/generated/cfg_totp/_utils/hooks/totp__totp_management.ts
|
|
6347
|
+
import useSWR7 from "swr";
|
|
6348
|
+
import { useSWRConfig as useSWRConfig9 } from "swr";
|
|
6349
|
+
function useTotpDevicesList(params, client) {
|
|
6350
|
+
return useSWR7(
|
|
6351
|
+
params ? ["cfg-totp-devices", params] : "cfg-totp-devices",
|
|
6352
|
+
() => getTotpDevicesList(params, client)
|
|
6353
|
+
);
|
|
6354
|
+
}
|
|
6355
|
+
__name(useTotpDevicesList, "useTotpDevicesList");
|
|
6356
|
+
function useCreateTotpDisableCreate() {
|
|
6357
|
+
const { mutate } = useSWRConfig9();
|
|
6358
|
+
return async (data, client) => {
|
|
6359
|
+
const result = await createTotpDisableCreate(data, client);
|
|
6360
|
+
mutate("cfg-totp-disable");
|
|
6361
|
+
return result;
|
|
6362
|
+
};
|
|
6363
|
+
}
|
|
6364
|
+
__name(useCreateTotpDisableCreate, "useCreateTotpDisableCreate");
|
|
6365
|
+
|
|
6366
|
+
// src/generated/cfg_totp/_utils/hooks/totp__totp_setup.ts
|
|
6367
|
+
import { useSWRConfig as useSWRConfig10 } from "swr";
|
|
6368
|
+
function useCreateTotpSetupCreate() {
|
|
6369
|
+
const { mutate } = useSWRConfig10();
|
|
6370
|
+
return async (data, client) => {
|
|
6371
|
+
const result = await createTotpSetupCreate(data, client);
|
|
6372
|
+
mutate("cfg-totp-setup");
|
|
6373
|
+
return result;
|
|
6374
|
+
};
|
|
6375
|
+
}
|
|
6376
|
+
__name(useCreateTotpSetupCreate, "useCreateTotpSetupCreate");
|
|
6377
|
+
function useCreateTotpSetupConfirmCreate() {
|
|
6378
|
+
const { mutate } = useSWRConfig10();
|
|
6379
|
+
return async (data, client) => {
|
|
6380
|
+
const result = await createTotpSetupConfirmCreate(data, client);
|
|
6381
|
+
mutate("cfg-totp-setup-confirm");
|
|
6382
|
+
return result;
|
|
6383
|
+
};
|
|
6384
|
+
}
|
|
6385
|
+
__name(useCreateTotpSetupConfirmCreate, "useCreateTotpSetupConfirmCreate");
|
|
6386
|
+
|
|
6387
|
+
// src/generated/cfg_totp/_utils/hooks/totp__totp_verification.ts
|
|
6388
|
+
import { useSWRConfig as useSWRConfig11 } from "swr";
|
|
6389
|
+
function useCreateTotpVerifyCreate() {
|
|
6390
|
+
const { mutate } = useSWRConfig11();
|
|
6391
|
+
return async (data, client) => {
|
|
6392
|
+
const result = await createTotpVerifyCreate(data, client);
|
|
6393
|
+
mutate("cfg-totp-verify");
|
|
6394
|
+
return result;
|
|
6395
|
+
};
|
|
6396
|
+
}
|
|
6397
|
+
__name(useCreateTotpVerifyCreate, "useCreateTotpVerifyCreate");
|
|
6398
|
+
function useCreateTotpVerifyBackupCreate() {
|
|
6399
|
+
const { mutate } = useSWRConfig11();
|
|
6400
|
+
return async (data, client) => {
|
|
6401
|
+
const result = await createTotpVerifyBackupCreate(data, client);
|
|
6402
|
+
mutate("cfg-totp-verify-backup");
|
|
6403
|
+
return result;
|
|
6404
|
+
};
|
|
6405
|
+
}
|
|
6406
|
+
__name(useCreateTotpVerifyBackupCreate, "useCreateTotpVerifyBackupCreate");
|
|
6407
|
+
|
|
6408
|
+
// src/generated/cfg_totp/_utils/hooks/totp.ts
|
|
6409
|
+
import { useSWRConfig as useSWRConfig12 } from "swr";
|
|
6410
|
+
function useDeleteTotpDevicesDestroy() {
|
|
6411
|
+
const { mutate } = useSWRConfig12();
|
|
6412
|
+
return async (id, client) => {
|
|
6413
|
+
const result = await deleteTotpDevicesDestroy(id, client);
|
|
6414
|
+
mutate("cfg-totp-devices");
|
|
6415
|
+
mutate("cfg-totp-device");
|
|
6416
|
+
return result;
|
|
6417
|
+
};
|
|
6418
|
+
}
|
|
6419
|
+
__name(useDeleteTotpDevicesDestroy, "useDeleteTotpDevicesDestroy");
|
|
6420
|
+
|
|
4927
6421
|
// src/clients.ts
|
|
4928
6422
|
var isStaticBuild = process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
|
|
4929
6423
|
var apiUrl = isStaticBuild ? "" : process.env.NEXT_PUBLIC_API_URL || "";
|
|
4930
6424
|
var storage = new LocalStorageAdapter();
|
|
4931
6425
|
var apiAccounts = new API(apiUrl, { storage });
|
|
4932
|
-
var
|
|
6426
|
+
var apiTotp = new API3(apiUrl, { storage });
|
|
6427
|
+
var apiWebPush = new API4(apiUrl, { storage });
|
|
4933
6428
|
var apiCentrifugo = new API2(apiUrl, { storage });
|
|
4934
6429
|
export {
|
|
4935
6430
|
API as AccountsAPI,
|
|
@@ -4955,14 +6450,19 @@ export {
|
|
|
4955
6450
|
PatchedUserProfileUpdateRequestSchema,
|
|
4956
6451
|
TokenRefreshRequestSchema,
|
|
4957
6452
|
TokenRefreshSchema,
|
|
6453
|
+
API3 as TotpAPI,
|
|
6454
|
+
fetchers_exports3 as TotpFetchers,
|
|
6455
|
+
hooks_exports3 as TotpHooks,
|
|
6456
|
+
schemas_exports3 as TotpTypes,
|
|
4958
6457
|
UserProfileUpdateRequestSchema,
|
|
4959
6458
|
UserSchema,
|
|
4960
|
-
|
|
4961
|
-
|
|
6459
|
+
API4 as WebPushAPI,
|
|
6460
|
+
fetchers_exports4 as WebPushFetchers,
|
|
4962
6461
|
hooks_exports as WebPushHooks,
|
|
4963
|
-
|
|
6462
|
+
schemas_exports4 as WebPushTypes,
|
|
4964
6463
|
apiAccounts,
|
|
4965
6464
|
apiCentrifugo,
|
|
6465
|
+
apiTotp,
|
|
4966
6466
|
apiWebPush,
|
|
4967
6467
|
createAccountsOauthDisconnectCreate,
|
|
4968
6468
|
createAccountsOauthGithubAuthorizeCreate,
|