@djangocfg/api 2.1.56 → 2.1.58
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.cjs
CHANGED
|
@@ -53,14 +53,19 @@ __export(clients_exports, {
|
|
|
53
53
|
PatchedUserProfileUpdateRequestSchema: () => PatchedUserProfileUpdateRequestSchema,
|
|
54
54
|
TokenRefreshRequestSchema: () => TokenRefreshRequestSchema,
|
|
55
55
|
TokenRefreshSchema: () => TokenRefreshSchema,
|
|
56
|
+
TotpAPI: () => API3,
|
|
57
|
+
TotpFetchers: () => fetchers_exports3,
|
|
58
|
+
TotpHooks: () => hooks_exports3,
|
|
59
|
+
TotpTypes: () => schemas_exports3,
|
|
56
60
|
UserProfileUpdateRequestSchema: () => UserProfileUpdateRequestSchema,
|
|
57
61
|
UserSchema: () => UserSchema,
|
|
58
|
-
WebPushAPI: () =>
|
|
59
|
-
WebPushFetchers: () =>
|
|
62
|
+
WebPushAPI: () => API4,
|
|
63
|
+
WebPushFetchers: () => fetchers_exports4,
|
|
60
64
|
WebPushHooks: () => hooks_exports,
|
|
61
|
-
WebPushTypes: () =>
|
|
65
|
+
WebPushTypes: () => schemas_exports4,
|
|
62
66
|
apiAccounts: () => apiAccounts,
|
|
63
67
|
apiCentrifugo: () => apiCentrifugo,
|
|
68
|
+
apiTotp: () => apiTotp,
|
|
64
69
|
apiWebPush: () => apiWebPush,
|
|
65
70
|
createAccountsOauthDisconnectCreate: () => createAccountsOauthDisconnectCreate,
|
|
66
71
|
createAccountsOauthGithubAuthorizeCreate: () => createAccountsOauthGithubAuthorizeCreate,
|
|
@@ -250,7 +255,10 @@ var Accounts = class {
|
|
|
250
255
|
return response;
|
|
251
256
|
}
|
|
252
257
|
/**
|
|
253
|
-
* Verify OTP code and return JWT tokens.
|
|
258
|
+
* Verify OTP code and return JWT tokens or 2FA session. If user has 2FA
|
|
259
|
+
* enabled: - Returns requires_2fa=True with session_id - Client must
|
|
260
|
+
* complete 2FA verification at /cfg/totp/verify/ If user has no 2FA: -
|
|
261
|
+
* Returns JWT tokens and user data directly
|
|
254
262
|
*/
|
|
255
263
|
async otpVerifyCreate(data) {
|
|
256
264
|
const response = await this.client.request("POST", "/cfg/accounts/otp/verify/", { body: data });
|
|
@@ -264,7 +272,7 @@ var FetchAdapter = class {
|
|
|
264
272
|
__name(this, "FetchAdapter");
|
|
265
273
|
}
|
|
266
274
|
async request(request) {
|
|
267
|
-
const { method, url, headers, body, params, formData } = request;
|
|
275
|
+
const { method, url, headers, body, params, formData, binaryBody } = request;
|
|
268
276
|
let finalUrl = url;
|
|
269
277
|
if (params) {
|
|
270
278
|
const searchParams = new URLSearchParams();
|
|
@@ -282,6 +290,9 @@ var FetchAdapter = class {
|
|
|
282
290
|
let requestBody;
|
|
283
291
|
if (formData) {
|
|
284
292
|
requestBody = formData;
|
|
293
|
+
} else if (binaryBody) {
|
|
294
|
+
finalHeaders["Content-Type"] = "application/octet-stream";
|
|
295
|
+
requestBody = binaryBody;
|
|
285
296
|
} else if (body) {
|
|
286
297
|
finalHeaders["Content-Type"] = "application/json";
|
|
287
298
|
requestBody = JSON.stringify(body);
|
|
@@ -681,7 +692,7 @@ var APIClient = class {
|
|
|
681
692
|
const headers = {
|
|
682
693
|
...options?.headers || {}
|
|
683
694
|
};
|
|
684
|
-
if (!options?.formData && !headers["Content-Type"]) {
|
|
695
|
+
if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
|
|
685
696
|
headers["Content-Type"] = "application/json";
|
|
686
697
|
}
|
|
687
698
|
if (this.logger) {
|
|
@@ -700,7 +711,8 @@ var APIClient = class {
|
|
|
700
711
|
headers,
|
|
701
712
|
params: options?.params,
|
|
702
713
|
body: options?.body,
|
|
703
|
-
formData: options?.formData
|
|
714
|
+
formData: options?.formData,
|
|
715
|
+
binaryBody: options?.binaryBody
|
|
704
716
|
});
|
|
705
717
|
const duration = Date.now() - startTime;
|
|
706
718
|
if (response.status >= 400) {
|
|
@@ -954,11 +966,14 @@ var OAuthProvidersResponseSchema = import_zod8.z.object({
|
|
|
954
966
|
// src/generated/cfg_accounts/_utils/schemas/OAuthTokenResponse.schema.ts
|
|
955
967
|
var import_zod9 = require("zod");
|
|
956
968
|
var OAuthTokenResponseSchema = import_zod9.z.object({
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
969
|
+
requires_2fa: import_zod9.z.boolean().optional(),
|
|
970
|
+
session_id: import_zod9.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i).nullable().optional(),
|
|
971
|
+
access: import_zod9.z.string().nullable().optional(),
|
|
972
|
+
refresh: import_zod9.z.string().nullable().optional(),
|
|
973
|
+
user: import_zod9.z.record(import_zod9.z.string(), import_zod9.z.any()).nullable().optional(),
|
|
960
974
|
is_new_user: import_zod9.z.boolean(),
|
|
961
|
-
is_new_connection: import_zod9.z.boolean()
|
|
975
|
+
is_new_connection: import_zod9.z.boolean(),
|
|
976
|
+
should_prompt_2fa: import_zod9.z.boolean().optional()
|
|
962
977
|
});
|
|
963
978
|
|
|
964
979
|
// src/generated/cfg_accounts/_utils/schemas/OTPErrorResponse.schema.ts
|
|
@@ -1017,9 +1032,12 @@ var UserSchema = import_zod14.z.object({
|
|
|
1017
1032
|
|
|
1018
1033
|
// src/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts
|
|
1019
1034
|
var OTPVerifyResponseSchema = import_zod15.z.object({
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1035
|
+
requires_2fa: import_zod15.z.boolean().optional(),
|
|
1036
|
+
session_id: import_zod15.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i).nullable().optional(),
|
|
1037
|
+
refresh: import_zod15.z.string().nullable().optional(),
|
|
1038
|
+
access: import_zod15.z.string().nullable().optional(),
|
|
1039
|
+
user: UserSchema.nullable().optional(),
|
|
1040
|
+
should_prompt_2fa: import_zod15.z.boolean().optional()
|
|
1023
1041
|
});
|
|
1024
1042
|
|
|
1025
1043
|
// src/generated/cfg_accounts/_utils/schemas/PatchedUserProfileUpdateRequest.schema.ts
|
|
@@ -1965,7 +1983,7 @@ var FetchAdapter2 = class {
|
|
|
1965
1983
|
__name(this, "FetchAdapter");
|
|
1966
1984
|
}
|
|
1967
1985
|
async request(request) {
|
|
1968
|
-
const { method, url, headers, body, params, formData } = request;
|
|
1986
|
+
const { method, url, headers, body, params, formData, binaryBody } = request;
|
|
1969
1987
|
let finalUrl = url;
|
|
1970
1988
|
if (params) {
|
|
1971
1989
|
const searchParams = new URLSearchParams();
|
|
@@ -1983,6 +2001,9 @@ var FetchAdapter2 = class {
|
|
|
1983
2001
|
let requestBody;
|
|
1984
2002
|
if (formData) {
|
|
1985
2003
|
requestBody = formData;
|
|
2004
|
+
} else if (binaryBody) {
|
|
2005
|
+
finalHeaders["Content-Type"] = "application/octet-stream";
|
|
2006
|
+
requestBody = binaryBody;
|
|
1986
2007
|
} else if (body) {
|
|
1987
2008
|
finalHeaders["Content-Type"] = "application/json";
|
|
1988
2009
|
requestBody = JSON.stringify(body);
|
|
@@ -2382,7 +2403,7 @@ var APIClient2 = class {
|
|
|
2382
2403
|
const headers = {
|
|
2383
2404
|
...options?.headers || {}
|
|
2384
2405
|
};
|
|
2385
|
-
if (!options?.formData && !headers["Content-Type"]) {
|
|
2406
|
+
if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
|
|
2386
2407
|
headers["Content-Type"] = "application/json";
|
|
2387
2408
|
}
|
|
2388
2409
|
if (this.logger) {
|
|
@@ -2401,7 +2422,8 @@ var APIClient2 = class {
|
|
|
2401
2422
|
headers,
|
|
2402
2423
|
params: options?.params,
|
|
2403
2424
|
body: options?.body,
|
|
2404
|
-
formData: options?.formData
|
|
2425
|
+
formData: options?.formData,
|
|
2426
|
+
binaryBody: options?.binaryBody
|
|
2405
2427
|
});
|
|
2406
2428
|
const duration = Date.now() - startTime;
|
|
2407
2429
|
if (response.status >= 400) {
|
|
@@ -3713,6 +3735,1370 @@ var API2 = class {
|
|
|
3713
3735
|
}
|
|
3714
3736
|
};
|
|
3715
3737
|
|
|
3738
|
+
// src/generated/cfg_totp/totp__backup_codes/client.ts
|
|
3739
|
+
var BackupCodes = class {
|
|
3740
|
+
static {
|
|
3741
|
+
__name(this, "BackupCodes");
|
|
3742
|
+
}
|
|
3743
|
+
constructor(client) {
|
|
3744
|
+
this.client = client;
|
|
3745
|
+
}
|
|
3746
|
+
/**
|
|
3747
|
+
* Get backup codes status for user.
|
|
3748
|
+
*/
|
|
3749
|
+
async totpBackupCodesRetrieve() {
|
|
3750
|
+
const response = await this.client.request("GET", "/cfg/totp/backup-codes/");
|
|
3751
|
+
return response;
|
|
3752
|
+
}
|
|
3753
|
+
/**
|
|
3754
|
+
* Regenerate backup codes. Requires TOTP code for verification.
|
|
3755
|
+
* Invalidates all existing codes.
|
|
3756
|
+
*/
|
|
3757
|
+
async totpBackupCodesRegenerateCreate(data) {
|
|
3758
|
+
const response = await this.client.request("POST", "/cfg/totp/backup-codes/regenerate/", { body: data });
|
|
3759
|
+
return response;
|
|
3760
|
+
}
|
|
3761
|
+
};
|
|
3762
|
+
|
|
3763
|
+
// src/generated/cfg_totp/totp__totp_management/client.ts
|
|
3764
|
+
var TotpManagement = class {
|
|
3765
|
+
static {
|
|
3766
|
+
__name(this, "TotpManagement");
|
|
3767
|
+
}
|
|
3768
|
+
constructor(client) {
|
|
3769
|
+
this.client = client;
|
|
3770
|
+
}
|
|
3771
|
+
/**
|
|
3772
|
+
* List all TOTP devices for user.
|
|
3773
|
+
*/
|
|
3774
|
+
async totpDevicesList(...args) {
|
|
3775
|
+
const isParamsObject = args.length === 1 && typeof args[0] === "object" && args[0] !== null && !Array.isArray(args[0]);
|
|
3776
|
+
let params;
|
|
3777
|
+
if (isParamsObject) {
|
|
3778
|
+
params = args[0];
|
|
3779
|
+
} else {
|
|
3780
|
+
params = { page: args[0], page_size: args[1] };
|
|
3781
|
+
}
|
|
3782
|
+
const response = await this.client.request("GET", "/cfg/totp/devices/", { params });
|
|
3783
|
+
return response;
|
|
3784
|
+
}
|
|
3785
|
+
/**
|
|
3786
|
+
* Completely disable 2FA for account. Requires verification code.
|
|
3787
|
+
*/
|
|
3788
|
+
async totpDisableCreate(data) {
|
|
3789
|
+
const response = await this.client.request("POST", "/cfg/totp/disable/", { body: data });
|
|
3790
|
+
return response;
|
|
3791
|
+
}
|
|
3792
|
+
};
|
|
3793
|
+
|
|
3794
|
+
// src/generated/cfg_totp/totp__totp_setup/client.ts
|
|
3795
|
+
var TotpSetup = class {
|
|
3796
|
+
static {
|
|
3797
|
+
__name(this, "TotpSetup");
|
|
3798
|
+
}
|
|
3799
|
+
constructor(client) {
|
|
3800
|
+
this.client = client;
|
|
3801
|
+
}
|
|
3802
|
+
/**
|
|
3803
|
+
* Start 2FA setup process. Creates a new TOTP device and returns QR code
|
|
3804
|
+
* for scanning.
|
|
3805
|
+
*/
|
|
3806
|
+
async create(data) {
|
|
3807
|
+
const response = await this.client.request("POST", "/cfg/totp/setup/", { body: data });
|
|
3808
|
+
return response;
|
|
3809
|
+
}
|
|
3810
|
+
/**
|
|
3811
|
+
* Confirm 2FA setup with first valid code. Activates the device and
|
|
3812
|
+
* generates backup codes.
|
|
3813
|
+
*/
|
|
3814
|
+
async confirmCreate(data) {
|
|
3815
|
+
const response = await this.client.request("POST", "/cfg/totp/setup/confirm/", { body: data });
|
|
3816
|
+
return response;
|
|
3817
|
+
}
|
|
3818
|
+
};
|
|
3819
|
+
|
|
3820
|
+
// src/generated/cfg_totp/totp__totp_verification/client.ts
|
|
3821
|
+
var TotpVerification = class {
|
|
3822
|
+
static {
|
|
3823
|
+
__name(this, "TotpVerification");
|
|
3824
|
+
}
|
|
3825
|
+
constructor(client) {
|
|
3826
|
+
this.client = client;
|
|
3827
|
+
}
|
|
3828
|
+
/**
|
|
3829
|
+
* Verify TOTP code for 2FA session. Completes authentication and returns
|
|
3830
|
+
* JWT tokens on success.
|
|
3831
|
+
*/
|
|
3832
|
+
async totpVerifyCreate(data) {
|
|
3833
|
+
const response = await this.client.request("POST", "/cfg/totp/verify/", { body: data });
|
|
3834
|
+
return response;
|
|
3835
|
+
}
|
|
3836
|
+
/**
|
|
3837
|
+
* Verify backup recovery code for 2FA session. Alternative verification
|
|
3838
|
+
* method when TOTP device unavailable.
|
|
3839
|
+
*/
|
|
3840
|
+
async totpVerifyBackupCreate(data) {
|
|
3841
|
+
const response = await this.client.request("POST", "/cfg/totp/verify/backup/", { body: data });
|
|
3842
|
+
return response;
|
|
3843
|
+
}
|
|
3844
|
+
};
|
|
3845
|
+
|
|
3846
|
+
// src/generated/cfg_totp/totp/client.ts
|
|
3847
|
+
var Totp = class {
|
|
3848
|
+
static {
|
|
3849
|
+
__name(this, "Totp");
|
|
3850
|
+
}
|
|
3851
|
+
constructor(client) {
|
|
3852
|
+
this.client = client;
|
|
3853
|
+
}
|
|
3854
|
+
/**
|
|
3855
|
+
* Delete a TOTP device. Requires verification code if removing the
|
|
3856
|
+
* last/primary device.
|
|
3857
|
+
*/
|
|
3858
|
+
async devicesDestroy(id) {
|
|
3859
|
+
const response = await this.client.request("DELETE", `/cfg/totp/devices/${id}/`);
|
|
3860
|
+
return;
|
|
3861
|
+
}
|
|
3862
|
+
};
|
|
3863
|
+
|
|
3864
|
+
// src/generated/cfg_totp/http.ts
|
|
3865
|
+
var FetchAdapter3 = class {
|
|
3866
|
+
static {
|
|
3867
|
+
__name(this, "FetchAdapter");
|
|
3868
|
+
}
|
|
3869
|
+
async request(request) {
|
|
3870
|
+
const { method, url, headers, body, params, formData, binaryBody } = request;
|
|
3871
|
+
let finalUrl = url;
|
|
3872
|
+
if (params) {
|
|
3873
|
+
const searchParams = new URLSearchParams();
|
|
3874
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
3875
|
+
if (value !== null && value !== void 0) {
|
|
3876
|
+
searchParams.append(key, String(value));
|
|
3877
|
+
}
|
|
3878
|
+
});
|
|
3879
|
+
const queryString = searchParams.toString();
|
|
3880
|
+
if (queryString) {
|
|
3881
|
+
finalUrl = url.includes("?") ? `${url}&${queryString}` : `${url}?${queryString}`;
|
|
3882
|
+
}
|
|
3883
|
+
}
|
|
3884
|
+
const finalHeaders = { ...headers };
|
|
3885
|
+
let requestBody;
|
|
3886
|
+
if (formData) {
|
|
3887
|
+
requestBody = formData;
|
|
3888
|
+
} else if (binaryBody) {
|
|
3889
|
+
finalHeaders["Content-Type"] = "application/octet-stream";
|
|
3890
|
+
requestBody = binaryBody;
|
|
3891
|
+
} else if (body) {
|
|
3892
|
+
finalHeaders["Content-Type"] = "application/json";
|
|
3893
|
+
requestBody = JSON.stringify(body);
|
|
3894
|
+
}
|
|
3895
|
+
const response = await fetch(finalUrl, {
|
|
3896
|
+
method,
|
|
3897
|
+
headers: finalHeaders,
|
|
3898
|
+
body: requestBody,
|
|
3899
|
+
credentials: "include"
|
|
3900
|
+
// Include Django session cookies
|
|
3901
|
+
});
|
|
3902
|
+
let data = null;
|
|
3903
|
+
const contentType = response.headers.get("content-type");
|
|
3904
|
+
if (response.status !== 204 && contentType?.includes("application/json")) {
|
|
3905
|
+
data = await response.json();
|
|
3906
|
+
} else if (response.status !== 204) {
|
|
3907
|
+
data = await response.text();
|
|
3908
|
+
}
|
|
3909
|
+
const responseHeaders = {};
|
|
3910
|
+
response.headers.forEach((value, key) => {
|
|
3911
|
+
responseHeaders[key] = value;
|
|
3912
|
+
});
|
|
3913
|
+
return {
|
|
3914
|
+
data,
|
|
3915
|
+
status: response.status,
|
|
3916
|
+
statusText: response.statusText,
|
|
3917
|
+
headers: responseHeaders
|
|
3918
|
+
};
|
|
3919
|
+
}
|
|
3920
|
+
};
|
|
3921
|
+
|
|
3922
|
+
// src/generated/cfg_totp/errors.ts
|
|
3923
|
+
var APIError3 = class extends Error {
|
|
3924
|
+
constructor(statusCode, statusText, response, url, message) {
|
|
3925
|
+
super(message || `HTTP ${statusCode}: ${statusText}`);
|
|
3926
|
+
this.statusCode = statusCode;
|
|
3927
|
+
this.statusText = statusText;
|
|
3928
|
+
this.response = response;
|
|
3929
|
+
this.url = url;
|
|
3930
|
+
this.name = "APIError";
|
|
3931
|
+
}
|
|
3932
|
+
static {
|
|
3933
|
+
__name(this, "APIError");
|
|
3934
|
+
}
|
|
3935
|
+
/**
|
|
3936
|
+
* Get error details from response.
|
|
3937
|
+
* DRF typically returns: { "detail": "Error message" } or { "field": ["error1", "error2"] }
|
|
3938
|
+
*/
|
|
3939
|
+
get details() {
|
|
3940
|
+
if (typeof this.response === "object" && this.response !== null) {
|
|
3941
|
+
return this.response;
|
|
3942
|
+
}
|
|
3943
|
+
return null;
|
|
3944
|
+
}
|
|
3945
|
+
/**
|
|
3946
|
+
* Get field-specific validation errors from DRF.
|
|
3947
|
+
* Returns: { "field_name": ["error1", "error2"], ... }
|
|
3948
|
+
*/
|
|
3949
|
+
get fieldErrors() {
|
|
3950
|
+
const details = this.details;
|
|
3951
|
+
if (!details) return null;
|
|
3952
|
+
const fieldErrors = {};
|
|
3953
|
+
for (const [key, value] of Object.entries(details)) {
|
|
3954
|
+
if (Array.isArray(value)) {
|
|
3955
|
+
fieldErrors[key] = value;
|
|
3956
|
+
}
|
|
3957
|
+
}
|
|
3958
|
+
return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
|
|
3959
|
+
}
|
|
3960
|
+
/**
|
|
3961
|
+
* Get single error message from DRF.
|
|
3962
|
+
* Checks for "detail", "message", or first field error.
|
|
3963
|
+
*/
|
|
3964
|
+
get errorMessage() {
|
|
3965
|
+
const details = this.details;
|
|
3966
|
+
if (!details) return this.message;
|
|
3967
|
+
if (details.detail) {
|
|
3968
|
+
return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
|
|
3969
|
+
}
|
|
3970
|
+
if (details.message) {
|
|
3971
|
+
return String(details.message);
|
|
3972
|
+
}
|
|
3973
|
+
const fieldErrors = this.fieldErrors;
|
|
3974
|
+
if (fieldErrors) {
|
|
3975
|
+
const firstField = Object.keys(fieldErrors)[0];
|
|
3976
|
+
if (firstField) {
|
|
3977
|
+
return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
|
|
3978
|
+
}
|
|
3979
|
+
}
|
|
3980
|
+
return this.message;
|
|
3981
|
+
}
|
|
3982
|
+
// Helper methods for common HTTP status codes
|
|
3983
|
+
get isValidationError() {
|
|
3984
|
+
return this.statusCode === 400;
|
|
3985
|
+
}
|
|
3986
|
+
get isAuthError() {
|
|
3987
|
+
return this.statusCode === 401;
|
|
3988
|
+
}
|
|
3989
|
+
get isPermissionError() {
|
|
3990
|
+
return this.statusCode === 403;
|
|
3991
|
+
}
|
|
3992
|
+
get isNotFoundError() {
|
|
3993
|
+
return this.statusCode === 404;
|
|
3994
|
+
}
|
|
3995
|
+
get isServerError() {
|
|
3996
|
+
return this.statusCode >= 500 && this.statusCode < 600;
|
|
3997
|
+
}
|
|
3998
|
+
};
|
|
3999
|
+
var NetworkError3 = class extends Error {
|
|
4000
|
+
constructor(message, url, originalError) {
|
|
4001
|
+
super(message);
|
|
4002
|
+
this.url = url;
|
|
4003
|
+
this.originalError = originalError;
|
|
4004
|
+
this.name = "NetworkError";
|
|
4005
|
+
}
|
|
4006
|
+
static {
|
|
4007
|
+
__name(this, "NetworkError");
|
|
4008
|
+
}
|
|
4009
|
+
};
|
|
4010
|
+
|
|
4011
|
+
// src/generated/cfg_totp/logger.ts
|
|
4012
|
+
var import_consola11 = require("consola");
|
|
4013
|
+
var DEFAULT_CONFIG3 = {
|
|
4014
|
+
enabled: process.env.NODE_ENV !== "production",
|
|
4015
|
+
logRequests: true,
|
|
4016
|
+
logResponses: true,
|
|
4017
|
+
logErrors: true,
|
|
4018
|
+
logBodies: true,
|
|
4019
|
+
logHeaders: false
|
|
4020
|
+
};
|
|
4021
|
+
var SENSITIVE_HEADERS3 = [
|
|
4022
|
+
"authorization",
|
|
4023
|
+
"cookie",
|
|
4024
|
+
"set-cookie",
|
|
4025
|
+
"x-api-key",
|
|
4026
|
+
"x-csrf-token"
|
|
4027
|
+
];
|
|
4028
|
+
var APILogger3 = class {
|
|
4029
|
+
static {
|
|
4030
|
+
__name(this, "APILogger");
|
|
4031
|
+
}
|
|
4032
|
+
constructor(config = {}) {
|
|
4033
|
+
this.config = { ...DEFAULT_CONFIG3, ...config };
|
|
4034
|
+
this.consola = config.consola || (0, import_consola11.createConsola)({
|
|
4035
|
+
level: this.config.enabled ? 4 : 0
|
|
4036
|
+
});
|
|
4037
|
+
}
|
|
4038
|
+
/**
|
|
4039
|
+
* Enable logging
|
|
4040
|
+
*/
|
|
4041
|
+
enable() {
|
|
4042
|
+
this.config.enabled = true;
|
|
4043
|
+
}
|
|
4044
|
+
/**
|
|
4045
|
+
* Disable logging
|
|
4046
|
+
*/
|
|
4047
|
+
disable() {
|
|
4048
|
+
this.config.enabled = false;
|
|
4049
|
+
}
|
|
4050
|
+
/**
|
|
4051
|
+
* Update configuration
|
|
4052
|
+
*/
|
|
4053
|
+
setConfig(config) {
|
|
4054
|
+
this.config = { ...this.config, ...config };
|
|
4055
|
+
}
|
|
4056
|
+
/**
|
|
4057
|
+
* Filter sensitive headers
|
|
4058
|
+
*/
|
|
4059
|
+
filterHeaders(headers) {
|
|
4060
|
+
if (!headers) return {};
|
|
4061
|
+
const filtered = {};
|
|
4062
|
+
Object.keys(headers).forEach((key) => {
|
|
4063
|
+
const lowerKey = key.toLowerCase();
|
|
4064
|
+
if (SENSITIVE_HEADERS3.includes(lowerKey)) {
|
|
4065
|
+
filtered[key] = "***";
|
|
4066
|
+
} else {
|
|
4067
|
+
filtered[key] = headers[key] || "";
|
|
4068
|
+
}
|
|
4069
|
+
});
|
|
4070
|
+
return filtered;
|
|
4071
|
+
}
|
|
4072
|
+
/**
|
|
4073
|
+
* Log request
|
|
4074
|
+
*/
|
|
4075
|
+
logRequest(request) {
|
|
4076
|
+
if (!this.config.enabled || !this.config.logRequests) return;
|
|
4077
|
+
const { method, url, headers, body } = request;
|
|
4078
|
+
this.consola.start(`${method} ${url}`);
|
|
4079
|
+
if (this.config.logHeaders && headers) {
|
|
4080
|
+
this.consola.debug("Headers:", this.filterHeaders(headers));
|
|
4081
|
+
}
|
|
4082
|
+
if (this.config.logBodies && body) {
|
|
4083
|
+
this.consola.debug("Body:", body);
|
|
4084
|
+
}
|
|
4085
|
+
}
|
|
4086
|
+
/**
|
|
4087
|
+
* Log response
|
|
4088
|
+
*/
|
|
4089
|
+
logResponse(request, response) {
|
|
4090
|
+
if (!this.config.enabled || !this.config.logResponses) return;
|
|
4091
|
+
const { method, url } = request;
|
|
4092
|
+
const { status, statusText, data, duration } = response;
|
|
4093
|
+
const statusColor = status >= 500 ? "red" : status >= 400 ? "yellow" : status >= 300 ? "cyan" : "green";
|
|
4094
|
+
this.consola.success(
|
|
4095
|
+
`${method} ${url} ${status} ${statusText} (${duration}ms)`
|
|
4096
|
+
);
|
|
4097
|
+
if (this.config.logBodies && data) {
|
|
4098
|
+
this.consola.debug("Response:", data);
|
|
4099
|
+
}
|
|
4100
|
+
}
|
|
4101
|
+
/**
|
|
4102
|
+
* Log error
|
|
4103
|
+
*/
|
|
4104
|
+
logError(request, error) {
|
|
4105
|
+
if (!this.config.enabled || !this.config.logErrors) return;
|
|
4106
|
+
const { method, url } = request;
|
|
4107
|
+
const { message, statusCode, fieldErrors, duration } = error;
|
|
4108
|
+
this.consola.error(
|
|
4109
|
+
`${method} ${url} ${statusCode || "Network"} Error (${duration}ms)`
|
|
4110
|
+
);
|
|
4111
|
+
this.consola.error("Message:", message);
|
|
4112
|
+
if (fieldErrors && Object.keys(fieldErrors).length > 0) {
|
|
4113
|
+
this.consola.error("Field Errors:");
|
|
4114
|
+
Object.entries(fieldErrors).forEach(([field, errors]) => {
|
|
4115
|
+
errors.forEach((err) => {
|
|
4116
|
+
this.consola.error(` \u2022 ${field}: ${err}`);
|
|
4117
|
+
});
|
|
4118
|
+
});
|
|
4119
|
+
}
|
|
4120
|
+
}
|
|
4121
|
+
/**
|
|
4122
|
+
* Log general info
|
|
4123
|
+
*/
|
|
4124
|
+
info(message, ...args) {
|
|
4125
|
+
if (!this.config.enabled) return;
|
|
4126
|
+
this.consola.info(message, ...args);
|
|
4127
|
+
}
|
|
4128
|
+
/**
|
|
4129
|
+
* Log warning
|
|
4130
|
+
*/
|
|
4131
|
+
warn(message, ...args) {
|
|
4132
|
+
if (!this.config.enabled) return;
|
|
4133
|
+
this.consola.warn(message, ...args);
|
|
4134
|
+
}
|
|
4135
|
+
/**
|
|
4136
|
+
* Log error
|
|
4137
|
+
*/
|
|
4138
|
+
error(message, ...args) {
|
|
4139
|
+
if (!this.config.enabled) return;
|
|
4140
|
+
this.consola.error(message, ...args);
|
|
4141
|
+
}
|
|
4142
|
+
/**
|
|
4143
|
+
* Log debug
|
|
4144
|
+
*/
|
|
4145
|
+
debug(message, ...args) {
|
|
4146
|
+
if (!this.config.enabled) return;
|
|
4147
|
+
this.consola.debug(message, ...args);
|
|
4148
|
+
}
|
|
4149
|
+
/**
|
|
4150
|
+
* Log success
|
|
4151
|
+
*/
|
|
4152
|
+
success(message, ...args) {
|
|
4153
|
+
if (!this.config.enabled) return;
|
|
4154
|
+
this.consola.success(message, ...args);
|
|
4155
|
+
}
|
|
4156
|
+
/**
|
|
4157
|
+
* Create a sub-logger with prefix
|
|
4158
|
+
*/
|
|
4159
|
+
withTag(tag) {
|
|
4160
|
+
return this.consola.withTag(tag);
|
|
4161
|
+
}
|
|
4162
|
+
};
|
|
4163
|
+
var defaultLogger3 = new APILogger3();
|
|
4164
|
+
|
|
4165
|
+
// src/generated/cfg_totp/retry.ts
|
|
4166
|
+
var import_p_retry3 = __toESM(require("p-retry"), 1);
|
|
4167
|
+
var DEFAULT_RETRY_CONFIG3 = {
|
|
4168
|
+
retries: 3,
|
|
4169
|
+
factor: 2,
|
|
4170
|
+
minTimeout: 1e3,
|
|
4171
|
+
maxTimeout: 6e4,
|
|
4172
|
+
randomize: true,
|
|
4173
|
+
onFailedAttempt: /* @__PURE__ */ __name(() => {
|
|
4174
|
+
}, "onFailedAttempt")
|
|
4175
|
+
};
|
|
4176
|
+
function shouldRetry3(error) {
|
|
4177
|
+
if (error instanceof NetworkError3) {
|
|
4178
|
+
return true;
|
|
4179
|
+
}
|
|
4180
|
+
if (error instanceof APIError3) {
|
|
4181
|
+
const status = error.statusCode;
|
|
4182
|
+
if (status >= 500 && status < 600) {
|
|
4183
|
+
return true;
|
|
4184
|
+
}
|
|
4185
|
+
if (status === 429) {
|
|
4186
|
+
return true;
|
|
4187
|
+
}
|
|
4188
|
+
return false;
|
|
4189
|
+
}
|
|
4190
|
+
return true;
|
|
4191
|
+
}
|
|
4192
|
+
__name(shouldRetry3, "shouldRetry");
|
|
4193
|
+
async function withRetry3(fn, config) {
|
|
4194
|
+
const finalConfig = { ...DEFAULT_RETRY_CONFIG3, ...config };
|
|
4195
|
+
return (0, import_p_retry3.default)(
|
|
4196
|
+
async () => {
|
|
4197
|
+
try {
|
|
4198
|
+
return await fn();
|
|
4199
|
+
} catch (error) {
|
|
4200
|
+
if (!shouldRetry3(error)) {
|
|
4201
|
+
throw new import_p_retry3.AbortError(error);
|
|
4202
|
+
}
|
|
4203
|
+
throw error;
|
|
4204
|
+
}
|
|
4205
|
+
},
|
|
4206
|
+
{
|
|
4207
|
+
retries: finalConfig.retries,
|
|
4208
|
+
factor: finalConfig.factor,
|
|
4209
|
+
minTimeout: finalConfig.minTimeout,
|
|
4210
|
+
maxTimeout: finalConfig.maxTimeout,
|
|
4211
|
+
randomize: finalConfig.randomize,
|
|
4212
|
+
onFailedAttempt: finalConfig.onFailedAttempt ? (error) => {
|
|
4213
|
+
const pRetryError = error;
|
|
4214
|
+
finalConfig.onFailedAttempt({
|
|
4215
|
+
error: pRetryError,
|
|
4216
|
+
attemptNumber: pRetryError.attemptNumber,
|
|
4217
|
+
retriesLeft: pRetryError.retriesLeft
|
|
4218
|
+
});
|
|
4219
|
+
} : void 0
|
|
4220
|
+
}
|
|
4221
|
+
);
|
|
4222
|
+
}
|
|
4223
|
+
__name(withRetry3, "withRetry");
|
|
4224
|
+
|
|
4225
|
+
// src/generated/cfg_totp/client.ts
|
|
4226
|
+
var APIClient3 = class {
|
|
4227
|
+
constructor(baseUrl, options) {
|
|
4228
|
+
this.logger = null;
|
|
4229
|
+
this.retryConfig = null;
|
|
4230
|
+
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
4231
|
+
this.httpClient = options?.httpClient || new FetchAdapter3();
|
|
4232
|
+
if (options?.loggerConfig !== void 0) {
|
|
4233
|
+
this.logger = new APILogger3(options.loggerConfig);
|
|
4234
|
+
}
|
|
4235
|
+
if (options?.retryConfig !== void 0) {
|
|
4236
|
+
this.retryConfig = options.retryConfig;
|
|
4237
|
+
}
|
|
4238
|
+
this.backup_codes = new BackupCodes(this);
|
|
4239
|
+
this.totp_management = new TotpManagement(this);
|
|
4240
|
+
this.totp_setup = new TotpSetup(this);
|
|
4241
|
+
this.totp_verification = new TotpVerification(this);
|
|
4242
|
+
this.totp = new Totp(this);
|
|
4243
|
+
}
|
|
4244
|
+
static {
|
|
4245
|
+
__name(this, "APIClient");
|
|
4246
|
+
}
|
|
4247
|
+
/**
|
|
4248
|
+
* Get CSRF token from cookies (for SessionAuthentication).
|
|
4249
|
+
*
|
|
4250
|
+
* Returns null if cookie doesn't exist (JWT-only auth).
|
|
4251
|
+
*/
|
|
4252
|
+
getCsrfToken() {
|
|
4253
|
+
const name = "csrftoken";
|
|
4254
|
+
const value = `; ${document.cookie}`;
|
|
4255
|
+
const parts = value.split(`; ${name}=`);
|
|
4256
|
+
if (parts.length === 2) {
|
|
4257
|
+
return parts.pop()?.split(";").shift() || null;
|
|
4258
|
+
}
|
|
4259
|
+
return null;
|
|
4260
|
+
}
|
|
4261
|
+
/**
|
|
4262
|
+
* Make HTTP request with Django CSRF and session handling.
|
|
4263
|
+
* Automatically retries on network errors and 5xx server errors.
|
|
4264
|
+
*/
|
|
4265
|
+
async request(method, path, options) {
|
|
4266
|
+
if (this.retryConfig) {
|
|
4267
|
+
return withRetry3(() => this._makeRequest(method, path, options), {
|
|
4268
|
+
...this.retryConfig,
|
|
4269
|
+
onFailedAttempt: /* @__PURE__ */ __name((info) => {
|
|
4270
|
+
if (this.logger) {
|
|
4271
|
+
this.logger.warn(
|
|
4272
|
+
`Retry attempt ${info.attemptNumber}/${info.retriesLeft + info.attemptNumber} for ${method} ${path}: ${info.error.message}`
|
|
4273
|
+
);
|
|
4274
|
+
}
|
|
4275
|
+
this.retryConfig?.onFailedAttempt?.(info);
|
|
4276
|
+
}, "onFailedAttempt")
|
|
4277
|
+
});
|
|
4278
|
+
}
|
|
4279
|
+
return this._makeRequest(method, path, options);
|
|
4280
|
+
}
|
|
4281
|
+
/**
|
|
4282
|
+
* Internal request method (without retry wrapper).
|
|
4283
|
+
* Used by request() method with optional retry logic.
|
|
4284
|
+
*/
|
|
4285
|
+
async _makeRequest(method, path, options) {
|
|
4286
|
+
const url = this.baseUrl ? `${this.baseUrl}${path}` : path;
|
|
4287
|
+
const startTime = Date.now();
|
|
4288
|
+
const headers = {
|
|
4289
|
+
...options?.headers || {}
|
|
4290
|
+
};
|
|
4291
|
+
if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
|
|
4292
|
+
headers["Content-Type"] = "application/json";
|
|
4293
|
+
}
|
|
4294
|
+
if (this.logger) {
|
|
4295
|
+
this.logger.logRequest({
|
|
4296
|
+
method,
|
|
4297
|
+
url,
|
|
4298
|
+
headers,
|
|
4299
|
+
body: options?.formData || options?.body,
|
|
4300
|
+
timestamp: startTime
|
|
4301
|
+
});
|
|
4302
|
+
}
|
|
4303
|
+
try {
|
|
4304
|
+
const response = await this.httpClient.request({
|
|
4305
|
+
method,
|
|
4306
|
+
url,
|
|
4307
|
+
headers,
|
|
4308
|
+
params: options?.params,
|
|
4309
|
+
body: options?.body,
|
|
4310
|
+
formData: options?.formData,
|
|
4311
|
+
binaryBody: options?.binaryBody
|
|
4312
|
+
});
|
|
4313
|
+
const duration = Date.now() - startTime;
|
|
4314
|
+
if (response.status >= 400) {
|
|
4315
|
+
const error = new APIError3(
|
|
4316
|
+
response.status,
|
|
4317
|
+
response.statusText,
|
|
4318
|
+
response.data,
|
|
4319
|
+
url
|
|
4320
|
+
);
|
|
4321
|
+
if (this.logger) {
|
|
4322
|
+
this.logger.logError(
|
|
4323
|
+
{
|
|
4324
|
+
method,
|
|
4325
|
+
url,
|
|
4326
|
+
headers,
|
|
4327
|
+
body: options?.formData || options?.body,
|
|
4328
|
+
timestamp: startTime
|
|
4329
|
+
},
|
|
4330
|
+
{
|
|
4331
|
+
message: error.message,
|
|
4332
|
+
statusCode: response.status,
|
|
4333
|
+
duration,
|
|
4334
|
+
timestamp: Date.now()
|
|
4335
|
+
}
|
|
4336
|
+
);
|
|
4337
|
+
}
|
|
4338
|
+
throw error;
|
|
4339
|
+
}
|
|
4340
|
+
if (this.logger) {
|
|
4341
|
+
this.logger.logResponse(
|
|
4342
|
+
{
|
|
4343
|
+
method,
|
|
4344
|
+
url,
|
|
4345
|
+
headers,
|
|
4346
|
+
body: options?.formData || options?.body,
|
|
4347
|
+
timestamp: startTime
|
|
4348
|
+
},
|
|
4349
|
+
{
|
|
4350
|
+
status: response.status,
|
|
4351
|
+
statusText: response.statusText,
|
|
4352
|
+
data: response.data,
|
|
4353
|
+
duration,
|
|
4354
|
+
timestamp: Date.now()
|
|
4355
|
+
}
|
|
4356
|
+
);
|
|
4357
|
+
}
|
|
4358
|
+
return response.data;
|
|
4359
|
+
} catch (error) {
|
|
4360
|
+
const duration = Date.now() - startTime;
|
|
4361
|
+
if (error instanceof APIError3) {
|
|
4362
|
+
throw error;
|
|
4363
|
+
}
|
|
4364
|
+
const isCORSError = error instanceof TypeError && (error.message.toLowerCase().includes("cors") || error.message.toLowerCase().includes("failed to fetch") || error.message.toLowerCase().includes("network request failed"));
|
|
4365
|
+
if (this.logger) {
|
|
4366
|
+
if (isCORSError) {
|
|
4367
|
+
this.logger.error(`\u{1F6AB} CORS Error: ${method} ${url}`);
|
|
4368
|
+
this.logger.error(` \u2192 ${error instanceof Error ? error.message : String(error)}`);
|
|
4369
|
+
this.logger.error(` \u2192 Configure security_domains parameter on the server`);
|
|
4370
|
+
} else {
|
|
4371
|
+
this.logger.error(`\u26A0\uFE0F Network Error: ${method} ${url}`);
|
|
4372
|
+
this.logger.error(` \u2192 ${error instanceof Error ? error.message : String(error)}`);
|
|
4373
|
+
}
|
|
4374
|
+
}
|
|
4375
|
+
if (typeof window !== "undefined") {
|
|
4376
|
+
try {
|
|
4377
|
+
if (isCORSError) {
|
|
4378
|
+
window.dispatchEvent(new CustomEvent("cors-error", {
|
|
4379
|
+
detail: {
|
|
4380
|
+
url,
|
|
4381
|
+
method,
|
|
4382
|
+
error: error instanceof Error ? error.message : String(error),
|
|
4383
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
4384
|
+
},
|
|
4385
|
+
bubbles: true,
|
|
4386
|
+
cancelable: false
|
|
4387
|
+
}));
|
|
4388
|
+
} else {
|
|
4389
|
+
window.dispatchEvent(new CustomEvent("network-error", {
|
|
4390
|
+
detail: {
|
|
4391
|
+
url,
|
|
4392
|
+
method,
|
|
4393
|
+
error: error instanceof Error ? error.message : String(error),
|
|
4394
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
4395
|
+
},
|
|
4396
|
+
bubbles: true,
|
|
4397
|
+
cancelable: false
|
|
4398
|
+
}));
|
|
4399
|
+
}
|
|
4400
|
+
} catch (eventError) {
|
|
4401
|
+
}
|
|
4402
|
+
}
|
|
4403
|
+
const networkError = error instanceof Error ? new NetworkError3(error.message, url, error) : new NetworkError3("Unknown error", url);
|
|
4404
|
+
if (this.logger) {
|
|
4405
|
+
this.logger.logError(
|
|
4406
|
+
{
|
|
4407
|
+
method,
|
|
4408
|
+
url,
|
|
4409
|
+
headers,
|
|
4410
|
+
body: options?.formData || options?.body,
|
|
4411
|
+
timestamp: startTime
|
|
4412
|
+
},
|
|
4413
|
+
{
|
|
4414
|
+
message: networkError.message,
|
|
4415
|
+
duration,
|
|
4416
|
+
timestamp: Date.now()
|
|
4417
|
+
}
|
|
4418
|
+
);
|
|
4419
|
+
}
|
|
4420
|
+
throw networkError;
|
|
4421
|
+
}
|
|
4422
|
+
}
|
|
4423
|
+
};
|
|
4424
|
+
|
|
4425
|
+
// src/generated/cfg_totp/storage.ts
|
|
4426
|
+
var LocalStorageAdapter3 = class {
|
|
4427
|
+
static {
|
|
4428
|
+
__name(this, "LocalStorageAdapter");
|
|
4429
|
+
}
|
|
4430
|
+
constructor(logger) {
|
|
4431
|
+
this.logger = logger;
|
|
4432
|
+
}
|
|
4433
|
+
getItem(key) {
|
|
4434
|
+
try {
|
|
4435
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
4436
|
+
const value = localStorage.getItem(key);
|
|
4437
|
+
this.logger?.debug(`LocalStorage.getItem("${key}"): ${value ? "found" : "not found"}`);
|
|
4438
|
+
return value;
|
|
4439
|
+
}
|
|
4440
|
+
this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
|
|
4441
|
+
} catch (error) {
|
|
4442
|
+
this.logger?.error("LocalStorage.getItem failed:", error);
|
|
4443
|
+
}
|
|
4444
|
+
return null;
|
|
4445
|
+
}
|
|
4446
|
+
setItem(key, value) {
|
|
4447
|
+
try {
|
|
4448
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
4449
|
+
localStorage.setItem(key, value);
|
|
4450
|
+
this.logger?.debug(`LocalStorage.setItem("${key}"): success`);
|
|
4451
|
+
} else {
|
|
4452
|
+
this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
|
|
4453
|
+
}
|
|
4454
|
+
} catch (error) {
|
|
4455
|
+
this.logger?.error("LocalStorage.setItem failed:", error);
|
|
4456
|
+
}
|
|
4457
|
+
}
|
|
4458
|
+
removeItem(key) {
|
|
4459
|
+
try {
|
|
4460
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
4461
|
+
localStorage.removeItem(key);
|
|
4462
|
+
this.logger?.debug(`LocalStorage.removeItem("${key}"): success`);
|
|
4463
|
+
} else {
|
|
4464
|
+
this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
|
|
4465
|
+
}
|
|
4466
|
+
} catch (error) {
|
|
4467
|
+
this.logger?.error("LocalStorage.removeItem failed:", error);
|
|
4468
|
+
}
|
|
4469
|
+
}
|
|
4470
|
+
};
|
|
4471
|
+
|
|
4472
|
+
// src/generated/cfg_totp/enums.ts
|
|
4473
|
+
var DeviceListStatus = /* @__PURE__ */ ((DeviceListStatus2) => {
|
|
4474
|
+
DeviceListStatus2["PENDING"] = "pending";
|
|
4475
|
+
DeviceListStatus2["ACTIVE"] = "active";
|
|
4476
|
+
DeviceListStatus2["DISABLED"] = "disabled";
|
|
4477
|
+
return DeviceListStatus2;
|
|
4478
|
+
})(DeviceListStatus || {});
|
|
4479
|
+
|
|
4480
|
+
// src/generated/cfg_totp/_utils/schemas/index.ts
|
|
4481
|
+
var schemas_exports3 = {};
|
|
4482
|
+
__export(schemas_exports3, {
|
|
4483
|
+
BackupCodesRegenerateRequestSchema: () => BackupCodesRegenerateRequestSchema,
|
|
4484
|
+
BackupCodesRegenerateResponseSchema: () => BackupCodesRegenerateResponseSchema,
|
|
4485
|
+
BackupCodesStatusSchema: () => BackupCodesStatusSchema,
|
|
4486
|
+
ConfirmSetupRequestSchema: () => ConfirmSetupRequestSchema,
|
|
4487
|
+
ConfirmSetupResponseSchema: () => ConfirmSetupResponseSchema,
|
|
4488
|
+
DeviceListSchema: () => DeviceListSchema,
|
|
4489
|
+
DisableRequestSchema: () => DisableRequestSchema,
|
|
4490
|
+
PaginatedDeviceListListSchema: () => PaginatedDeviceListListSchema,
|
|
4491
|
+
SetupRequestSchema: () => SetupRequestSchema,
|
|
4492
|
+
SetupResponseSchema: () => SetupResponseSchema,
|
|
4493
|
+
VerifyBackupRequestSchema: () => VerifyBackupRequestSchema,
|
|
4494
|
+
VerifyRequestSchema: () => VerifyRequestSchema,
|
|
4495
|
+
VerifyResponseSchema: () => VerifyResponseSchema
|
|
4496
|
+
});
|
|
4497
|
+
|
|
4498
|
+
// src/generated/cfg_totp/_utils/schemas/BackupCodesRegenerateRequest.schema.ts
|
|
4499
|
+
var import_zod55 = require("zod");
|
|
4500
|
+
var BackupCodesRegenerateRequestSchema = import_zod55.z.object({
|
|
4501
|
+
code: import_zod55.z.string().min(6).max(6)
|
|
4502
|
+
});
|
|
4503
|
+
|
|
4504
|
+
// src/generated/cfg_totp/_utils/schemas/BackupCodesRegenerateResponse.schema.ts
|
|
4505
|
+
var import_zod56 = require("zod");
|
|
4506
|
+
var BackupCodesRegenerateResponseSchema = import_zod56.z.object({
|
|
4507
|
+
backup_codes: import_zod56.z.array(import_zod56.z.string()),
|
|
4508
|
+
warning: import_zod56.z.string()
|
|
4509
|
+
});
|
|
4510
|
+
|
|
4511
|
+
// src/generated/cfg_totp/_utils/schemas/BackupCodesStatus.schema.ts
|
|
4512
|
+
var import_zod57 = require("zod");
|
|
4513
|
+
var BackupCodesStatusSchema = import_zod57.z.object({
|
|
4514
|
+
remaining_count: import_zod57.z.int(),
|
|
4515
|
+
total_generated: import_zod57.z.int(),
|
|
4516
|
+
warning: import_zod57.z.string().nullable().optional()
|
|
4517
|
+
});
|
|
4518
|
+
|
|
4519
|
+
// src/generated/cfg_totp/_utils/schemas/ConfirmSetupRequest.schema.ts
|
|
4520
|
+
var import_zod58 = require("zod");
|
|
4521
|
+
var ConfirmSetupRequestSchema = import_zod58.z.object({
|
|
4522
|
+
device_id: import_zod58.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
4523
|
+
code: import_zod58.z.string().min(6).max(6)
|
|
4524
|
+
});
|
|
4525
|
+
|
|
4526
|
+
// src/generated/cfg_totp/_utils/schemas/ConfirmSetupResponse.schema.ts
|
|
4527
|
+
var import_zod59 = require("zod");
|
|
4528
|
+
var ConfirmSetupResponseSchema = import_zod59.z.object({
|
|
4529
|
+
message: import_zod59.z.string(),
|
|
4530
|
+
backup_codes: import_zod59.z.array(import_zod59.z.string()),
|
|
4531
|
+
backup_codes_warning: import_zod59.z.string()
|
|
4532
|
+
});
|
|
4533
|
+
|
|
4534
|
+
// src/generated/cfg_totp/_utils/schemas/DeviceList.schema.ts
|
|
4535
|
+
var import_zod60 = require("zod");
|
|
4536
|
+
var DeviceListSchema = import_zod60.z.object({
|
|
4537
|
+
id: import_zod60.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
4538
|
+
name: import_zod60.z.string(),
|
|
4539
|
+
is_primary: import_zod60.z.boolean(),
|
|
4540
|
+
status: import_zod60.z.nativeEnum(DeviceListStatus),
|
|
4541
|
+
created_at: import_zod60.z.iso.datetime(),
|
|
4542
|
+
confirmed_at: import_zod60.z.iso.datetime().nullable(),
|
|
4543
|
+
last_used_at: import_zod60.z.iso.datetime().nullable()
|
|
4544
|
+
});
|
|
4545
|
+
|
|
4546
|
+
// src/generated/cfg_totp/_utils/schemas/DisableRequest.schema.ts
|
|
4547
|
+
var import_zod61 = require("zod");
|
|
4548
|
+
var DisableRequestSchema = import_zod61.z.object({
|
|
4549
|
+
code: import_zod61.z.string().min(6).max(6)
|
|
4550
|
+
});
|
|
4551
|
+
|
|
4552
|
+
// src/generated/cfg_totp/_utils/schemas/PaginatedDeviceListList.schema.ts
|
|
4553
|
+
var import_zod62 = require("zod");
|
|
4554
|
+
var PaginatedDeviceListListSchema = import_zod62.z.object({
|
|
4555
|
+
count: import_zod62.z.int(),
|
|
4556
|
+
page: import_zod62.z.int(),
|
|
4557
|
+
pages: import_zod62.z.int(),
|
|
4558
|
+
page_size: import_zod62.z.int(),
|
|
4559
|
+
has_next: import_zod62.z.boolean(),
|
|
4560
|
+
has_previous: import_zod62.z.boolean(),
|
|
4561
|
+
next_page: import_zod62.z.int().nullable().optional(),
|
|
4562
|
+
previous_page: import_zod62.z.int().nullable().optional(),
|
|
4563
|
+
results: import_zod62.z.array(DeviceListSchema)
|
|
4564
|
+
});
|
|
4565
|
+
|
|
4566
|
+
// src/generated/cfg_totp/_utils/schemas/SetupRequest.schema.ts
|
|
4567
|
+
var import_zod63 = require("zod");
|
|
4568
|
+
var SetupRequestSchema = import_zod63.z.object({
|
|
4569
|
+
device_name: import_zod63.z.string().min(1).max(100).optional()
|
|
4570
|
+
});
|
|
4571
|
+
|
|
4572
|
+
// src/generated/cfg_totp/_utils/schemas/SetupResponse.schema.ts
|
|
4573
|
+
var import_zod64 = require("zod");
|
|
4574
|
+
var SetupResponseSchema = import_zod64.z.object({
|
|
4575
|
+
device_id: import_zod64.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
4576
|
+
secret: import_zod64.z.string(),
|
|
4577
|
+
provisioning_uri: import_zod64.z.string(),
|
|
4578
|
+
qr_code_base64: import_zod64.z.string(),
|
|
4579
|
+
expires_in: import_zod64.z.int()
|
|
4580
|
+
});
|
|
4581
|
+
|
|
4582
|
+
// src/generated/cfg_totp/_utils/schemas/VerifyBackupRequest.schema.ts
|
|
4583
|
+
var import_zod65 = require("zod");
|
|
4584
|
+
var VerifyBackupRequestSchema = import_zod65.z.object({
|
|
4585
|
+
session_id: import_zod65.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
4586
|
+
backup_code: import_zod65.z.string().min(8).max(8)
|
|
4587
|
+
});
|
|
4588
|
+
|
|
4589
|
+
// src/generated/cfg_totp/_utils/schemas/VerifyRequest.schema.ts
|
|
4590
|
+
var import_zod66 = require("zod");
|
|
4591
|
+
var VerifyRequestSchema = import_zod66.z.object({
|
|
4592
|
+
session_id: import_zod66.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
4593
|
+
code: import_zod66.z.string().min(6).max(6)
|
|
4594
|
+
});
|
|
4595
|
+
|
|
4596
|
+
// src/generated/cfg_totp/_utils/schemas/VerifyResponse.schema.ts
|
|
4597
|
+
var import_zod67 = require("zod");
|
|
4598
|
+
var VerifyResponseSchema = import_zod67.z.object({
|
|
4599
|
+
message: import_zod67.z.string(),
|
|
4600
|
+
access_token: import_zod67.z.string(),
|
|
4601
|
+
refresh_token: import_zod67.z.string(),
|
|
4602
|
+
user: import_zod67.z.record(import_zod67.z.string(), import_zod67.z.any()),
|
|
4603
|
+
remaining_backup_codes: import_zod67.z.int().optional(),
|
|
4604
|
+
warning: import_zod67.z.string().optional()
|
|
4605
|
+
});
|
|
4606
|
+
|
|
4607
|
+
// src/generated/cfg_totp/_utils/fetchers/index.ts
|
|
4608
|
+
var fetchers_exports3 = {};
|
|
4609
|
+
__export(fetchers_exports3, {
|
|
4610
|
+
createTotpBackupCodesRegenerateCreate: () => createTotpBackupCodesRegenerateCreate,
|
|
4611
|
+
createTotpDisableCreate: () => createTotpDisableCreate,
|
|
4612
|
+
createTotpSetupConfirmCreate: () => createTotpSetupConfirmCreate,
|
|
4613
|
+
createTotpSetupCreate: () => createTotpSetupCreate,
|
|
4614
|
+
createTotpVerifyBackupCreate: () => createTotpVerifyBackupCreate,
|
|
4615
|
+
createTotpVerifyCreate: () => createTotpVerifyCreate,
|
|
4616
|
+
deleteTotpDevicesDestroy: () => deleteTotpDevicesDestroy,
|
|
4617
|
+
getTotpBackupCodesRetrieve: () => getTotpBackupCodesRetrieve,
|
|
4618
|
+
getTotpDevicesList: () => getTotpDevicesList
|
|
4619
|
+
});
|
|
4620
|
+
|
|
4621
|
+
// src/generated/cfg_totp/api-instance.ts
|
|
4622
|
+
var globalAPI3 = null;
|
|
4623
|
+
var autoConfigAttempted3 = false;
|
|
4624
|
+
function tryAutoConfigureFromEnv3() {
|
|
4625
|
+
if (autoConfigAttempted3) return;
|
|
4626
|
+
autoConfigAttempted3 = true;
|
|
4627
|
+
if (globalAPI3) return;
|
|
4628
|
+
if (typeof process === "undefined" || !process.env) return;
|
|
4629
|
+
const baseUrl = process.env.NEXT_PUBLIC_API_URL || process.env.VITE_API_URL || process.env.REACT_APP_API_URL || process.env.API_URL;
|
|
4630
|
+
if (baseUrl) {
|
|
4631
|
+
globalAPI3 = new API3(baseUrl);
|
|
4632
|
+
}
|
|
4633
|
+
}
|
|
4634
|
+
__name(tryAutoConfigureFromEnv3, "tryAutoConfigureFromEnv");
|
|
4635
|
+
function getAPIInstance3() {
|
|
4636
|
+
tryAutoConfigureFromEnv3();
|
|
4637
|
+
if (!globalAPI3) {
|
|
4638
|
+
throw new Error(
|
|
4639
|
+
'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'
|
|
4640
|
+
);
|
|
4641
|
+
}
|
|
4642
|
+
return globalAPI3;
|
|
4643
|
+
}
|
|
4644
|
+
__name(getAPIInstance3, "getAPIInstance");
|
|
4645
|
+
|
|
4646
|
+
// src/generated/cfg_totp/_utils/fetchers/totp.ts
|
|
4647
|
+
async function deleteTotpDevicesDestroy(id, client) {
|
|
4648
|
+
const api = client || getAPIInstance3();
|
|
4649
|
+
const response = await api.totp.devicesDestroy(id);
|
|
4650
|
+
return response;
|
|
4651
|
+
}
|
|
4652
|
+
__name(deleteTotpDevicesDestroy, "deleteTotpDevicesDestroy");
|
|
4653
|
+
|
|
4654
|
+
// src/generated/cfg_totp/_utils/fetchers/totp__backup_codes.ts
|
|
4655
|
+
var import_consola12 = require("consola");
|
|
4656
|
+
async function getTotpBackupCodesRetrieve(client) {
|
|
4657
|
+
const api = client || getAPIInstance3();
|
|
4658
|
+
const response = await api.backup_codes.totpBackupCodesRetrieve();
|
|
4659
|
+
try {
|
|
4660
|
+
return BackupCodesStatusSchema.parse(response);
|
|
4661
|
+
} catch (error) {
|
|
4662
|
+
import_consola12.consola.error("\u274C Zod Validation Failed");
|
|
4663
|
+
import_consola12.consola.box(`getTotpBackupCodesRetrieve
|
|
4664
|
+
Path: /cfg/totp/backup-codes/
|
|
4665
|
+
Method: GET`);
|
|
4666
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
4667
|
+
import_consola12.consola.error("Validation Issues:");
|
|
4668
|
+
error.issues.forEach((issue, index) => {
|
|
4669
|
+
import_consola12.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
4670
|
+
import_consola12.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
4671
|
+
if (issue.expected) import_consola12.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
4672
|
+
if (issue.received) import_consola12.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
4673
|
+
});
|
|
4674
|
+
}
|
|
4675
|
+
import_consola12.consola.error("Response data:", response);
|
|
4676
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
4677
|
+
try {
|
|
4678
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
4679
|
+
detail: {
|
|
4680
|
+
operation: "getTotpBackupCodesRetrieve",
|
|
4681
|
+
path: "/cfg/totp/backup-codes/",
|
|
4682
|
+
method: "GET",
|
|
4683
|
+
error,
|
|
4684
|
+
response,
|
|
4685
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
4686
|
+
},
|
|
4687
|
+
bubbles: true,
|
|
4688
|
+
cancelable: false
|
|
4689
|
+
});
|
|
4690
|
+
window.dispatchEvent(event);
|
|
4691
|
+
} catch (eventError) {
|
|
4692
|
+
import_consola12.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
4693
|
+
}
|
|
4694
|
+
}
|
|
4695
|
+
throw error;
|
|
4696
|
+
}
|
|
4697
|
+
}
|
|
4698
|
+
__name(getTotpBackupCodesRetrieve, "getTotpBackupCodesRetrieve");
|
|
4699
|
+
async function createTotpBackupCodesRegenerateCreate(data, client) {
|
|
4700
|
+
const api = client || getAPIInstance3();
|
|
4701
|
+
const response = await api.backup_codes.totpBackupCodesRegenerateCreate(data);
|
|
4702
|
+
try {
|
|
4703
|
+
return BackupCodesRegenerateResponseSchema.parse(response);
|
|
4704
|
+
} catch (error) {
|
|
4705
|
+
import_consola12.consola.error("\u274C Zod Validation Failed");
|
|
4706
|
+
import_consola12.consola.box(`createTotpBackupCodesRegenerateCreate
|
|
4707
|
+
Path: /cfg/totp/backup-codes/regenerate/
|
|
4708
|
+
Method: POST`);
|
|
4709
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
4710
|
+
import_consola12.consola.error("Validation Issues:");
|
|
4711
|
+
error.issues.forEach((issue, index) => {
|
|
4712
|
+
import_consola12.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
4713
|
+
import_consola12.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
4714
|
+
if (issue.expected) import_consola12.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
4715
|
+
if (issue.received) import_consola12.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
4716
|
+
});
|
|
4717
|
+
}
|
|
4718
|
+
import_consola12.consola.error("Response data:", response);
|
|
4719
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
4720
|
+
try {
|
|
4721
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
4722
|
+
detail: {
|
|
4723
|
+
operation: "createTotpBackupCodesRegenerateCreate",
|
|
4724
|
+
path: "/cfg/totp/backup-codes/regenerate/",
|
|
4725
|
+
method: "POST",
|
|
4726
|
+
error,
|
|
4727
|
+
response,
|
|
4728
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
4729
|
+
},
|
|
4730
|
+
bubbles: true,
|
|
4731
|
+
cancelable: false
|
|
4732
|
+
});
|
|
4733
|
+
window.dispatchEvent(event);
|
|
4734
|
+
} catch (eventError) {
|
|
4735
|
+
import_consola12.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
4736
|
+
}
|
|
4737
|
+
}
|
|
4738
|
+
throw error;
|
|
4739
|
+
}
|
|
4740
|
+
}
|
|
4741
|
+
__name(createTotpBackupCodesRegenerateCreate, "createTotpBackupCodesRegenerateCreate");
|
|
4742
|
+
|
|
4743
|
+
// src/generated/cfg_totp/_utils/fetchers/totp__totp_management.ts
|
|
4744
|
+
var import_consola13 = require("consola");
|
|
4745
|
+
async function getTotpDevicesList(params, client) {
|
|
4746
|
+
const api = client || getAPIInstance3();
|
|
4747
|
+
const response = await api.totp_management.totpDevicesList(params?.page, params?.page_size);
|
|
4748
|
+
try {
|
|
4749
|
+
return PaginatedDeviceListListSchema.parse(response);
|
|
4750
|
+
} catch (error) {
|
|
4751
|
+
import_consola13.consola.error("\u274C Zod Validation Failed");
|
|
4752
|
+
import_consola13.consola.box(`getTotpDevicesList
|
|
4753
|
+
Path: /cfg/totp/devices/
|
|
4754
|
+
Method: GET`);
|
|
4755
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
4756
|
+
import_consola13.consola.error("Validation Issues:");
|
|
4757
|
+
error.issues.forEach((issue, index) => {
|
|
4758
|
+
import_consola13.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
4759
|
+
import_consola13.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
4760
|
+
if (issue.expected) import_consola13.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
4761
|
+
if (issue.received) import_consola13.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
4762
|
+
});
|
|
4763
|
+
}
|
|
4764
|
+
import_consola13.consola.error("Response data:", response);
|
|
4765
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
4766
|
+
try {
|
|
4767
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
4768
|
+
detail: {
|
|
4769
|
+
operation: "getTotpDevicesList",
|
|
4770
|
+
path: "/cfg/totp/devices/",
|
|
4771
|
+
method: "GET",
|
|
4772
|
+
error,
|
|
4773
|
+
response,
|
|
4774
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
4775
|
+
},
|
|
4776
|
+
bubbles: true,
|
|
4777
|
+
cancelable: false
|
|
4778
|
+
});
|
|
4779
|
+
window.dispatchEvent(event);
|
|
4780
|
+
} catch (eventError) {
|
|
4781
|
+
import_consola13.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
4782
|
+
}
|
|
4783
|
+
}
|
|
4784
|
+
throw error;
|
|
4785
|
+
}
|
|
4786
|
+
}
|
|
4787
|
+
__name(getTotpDevicesList, "getTotpDevicesList");
|
|
4788
|
+
async function createTotpDisableCreate(data, client) {
|
|
4789
|
+
const api = client || getAPIInstance3();
|
|
4790
|
+
const response = await api.totp_management.totpDisableCreate(data);
|
|
4791
|
+
return response;
|
|
4792
|
+
}
|
|
4793
|
+
__name(createTotpDisableCreate, "createTotpDisableCreate");
|
|
4794
|
+
|
|
4795
|
+
// src/generated/cfg_totp/_utils/fetchers/totp__totp_setup.ts
|
|
4796
|
+
var import_consola14 = require("consola");
|
|
4797
|
+
async function createTotpSetupCreate(data, client) {
|
|
4798
|
+
const api = client || getAPIInstance3();
|
|
4799
|
+
const response = await api.totp_setup.create(data);
|
|
4800
|
+
try {
|
|
4801
|
+
return SetupResponseSchema.parse(response);
|
|
4802
|
+
} catch (error) {
|
|
4803
|
+
import_consola14.consola.error("\u274C Zod Validation Failed");
|
|
4804
|
+
import_consola14.consola.box(`createTotpSetupCreate
|
|
4805
|
+
Path: /cfg/totp/setup/
|
|
4806
|
+
Method: POST`);
|
|
4807
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
4808
|
+
import_consola14.consola.error("Validation Issues:");
|
|
4809
|
+
error.issues.forEach((issue, index) => {
|
|
4810
|
+
import_consola14.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
4811
|
+
import_consola14.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
4812
|
+
if (issue.expected) import_consola14.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
4813
|
+
if (issue.received) import_consola14.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
4814
|
+
});
|
|
4815
|
+
}
|
|
4816
|
+
import_consola14.consola.error("Response data:", response);
|
|
4817
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
4818
|
+
try {
|
|
4819
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
4820
|
+
detail: {
|
|
4821
|
+
operation: "createTotpSetupCreate",
|
|
4822
|
+
path: "/cfg/totp/setup/",
|
|
4823
|
+
method: "POST",
|
|
4824
|
+
error,
|
|
4825
|
+
response,
|
|
4826
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
4827
|
+
},
|
|
4828
|
+
bubbles: true,
|
|
4829
|
+
cancelable: false
|
|
4830
|
+
});
|
|
4831
|
+
window.dispatchEvent(event);
|
|
4832
|
+
} catch (eventError) {
|
|
4833
|
+
import_consola14.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
4834
|
+
}
|
|
4835
|
+
}
|
|
4836
|
+
throw error;
|
|
4837
|
+
}
|
|
4838
|
+
}
|
|
4839
|
+
__name(createTotpSetupCreate, "createTotpSetupCreate");
|
|
4840
|
+
async function createTotpSetupConfirmCreate(data, client) {
|
|
4841
|
+
const api = client || getAPIInstance3();
|
|
4842
|
+
const response = await api.totp_setup.confirmCreate(data);
|
|
4843
|
+
try {
|
|
4844
|
+
return ConfirmSetupResponseSchema.parse(response);
|
|
4845
|
+
} catch (error) {
|
|
4846
|
+
import_consola14.consola.error("\u274C Zod Validation Failed");
|
|
4847
|
+
import_consola14.consola.box(`createTotpSetupConfirmCreate
|
|
4848
|
+
Path: /cfg/totp/setup/confirm/
|
|
4849
|
+
Method: POST`);
|
|
4850
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
4851
|
+
import_consola14.consola.error("Validation Issues:");
|
|
4852
|
+
error.issues.forEach((issue, index) => {
|
|
4853
|
+
import_consola14.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
4854
|
+
import_consola14.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
4855
|
+
if (issue.expected) import_consola14.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
4856
|
+
if (issue.received) import_consola14.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
4857
|
+
});
|
|
4858
|
+
}
|
|
4859
|
+
import_consola14.consola.error("Response data:", response);
|
|
4860
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
4861
|
+
try {
|
|
4862
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
4863
|
+
detail: {
|
|
4864
|
+
operation: "createTotpSetupConfirmCreate",
|
|
4865
|
+
path: "/cfg/totp/setup/confirm/",
|
|
4866
|
+
method: "POST",
|
|
4867
|
+
error,
|
|
4868
|
+
response,
|
|
4869
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
4870
|
+
},
|
|
4871
|
+
bubbles: true,
|
|
4872
|
+
cancelable: false
|
|
4873
|
+
});
|
|
4874
|
+
window.dispatchEvent(event);
|
|
4875
|
+
} catch (eventError) {
|
|
4876
|
+
import_consola14.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
4877
|
+
}
|
|
4878
|
+
}
|
|
4879
|
+
throw error;
|
|
4880
|
+
}
|
|
4881
|
+
}
|
|
4882
|
+
__name(createTotpSetupConfirmCreate, "createTotpSetupConfirmCreate");
|
|
4883
|
+
|
|
4884
|
+
// src/generated/cfg_totp/_utils/fetchers/totp__totp_verification.ts
|
|
4885
|
+
var import_consola15 = require("consola");
|
|
4886
|
+
async function createTotpVerifyCreate(data, client) {
|
|
4887
|
+
const api = client || getAPIInstance3();
|
|
4888
|
+
const response = await api.totp_verification.totpVerifyCreate(data);
|
|
4889
|
+
try {
|
|
4890
|
+
return VerifyResponseSchema.parse(response);
|
|
4891
|
+
} catch (error) {
|
|
4892
|
+
import_consola15.consola.error("\u274C Zod Validation Failed");
|
|
4893
|
+
import_consola15.consola.box(`createTotpVerifyCreate
|
|
4894
|
+
Path: /cfg/totp/verify/
|
|
4895
|
+
Method: POST`);
|
|
4896
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
4897
|
+
import_consola15.consola.error("Validation Issues:");
|
|
4898
|
+
error.issues.forEach((issue, index) => {
|
|
4899
|
+
import_consola15.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
4900
|
+
import_consola15.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
4901
|
+
if (issue.expected) import_consola15.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
4902
|
+
if (issue.received) import_consola15.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
4903
|
+
});
|
|
4904
|
+
}
|
|
4905
|
+
import_consola15.consola.error("Response data:", response);
|
|
4906
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
4907
|
+
try {
|
|
4908
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
4909
|
+
detail: {
|
|
4910
|
+
operation: "createTotpVerifyCreate",
|
|
4911
|
+
path: "/cfg/totp/verify/",
|
|
4912
|
+
method: "POST",
|
|
4913
|
+
error,
|
|
4914
|
+
response,
|
|
4915
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
4916
|
+
},
|
|
4917
|
+
bubbles: true,
|
|
4918
|
+
cancelable: false
|
|
4919
|
+
});
|
|
4920
|
+
window.dispatchEvent(event);
|
|
4921
|
+
} catch (eventError) {
|
|
4922
|
+
import_consola15.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
4923
|
+
}
|
|
4924
|
+
}
|
|
4925
|
+
throw error;
|
|
4926
|
+
}
|
|
4927
|
+
}
|
|
4928
|
+
__name(createTotpVerifyCreate, "createTotpVerifyCreate");
|
|
4929
|
+
async function createTotpVerifyBackupCreate(data, client) {
|
|
4930
|
+
const api = client || getAPIInstance3();
|
|
4931
|
+
const response = await api.totp_verification.totpVerifyBackupCreate(data);
|
|
4932
|
+
try {
|
|
4933
|
+
return VerifyResponseSchema.parse(response);
|
|
4934
|
+
} catch (error) {
|
|
4935
|
+
import_consola15.consola.error("\u274C Zod Validation Failed");
|
|
4936
|
+
import_consola15.consola.box(`createTotpVerifyBackupCreate
|
|
4937
|
+
Path: /cfg/totp/verify/backup/
|
|
4938
|
+
Method: POST`);
|
|
4939
|
+
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
4940
|
+
import_consola15.consola.error("Validation Issues:");
|
|
4941
|
+
error.issues.forEach((issue, index) => {
|
|
4942
|
+
import_consola15.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
4943
|
+
import_consola15.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
4944
|
+
if (issue.expected) import_consola15.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
4945
|
+
if (issue.received) import_consola15.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
4946
|
+
});
|
|
4947
|
+
}
|
|
4948
|
+
import_consola15.consola.error("Response data:", response);
|
|
4949
|
+
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
4950
|
+
try {
|
|
4951
|
+
const event = new CustomEvent("zod-validation-error", {
|
|
4952
|
+
detail: {
|
|
4953
|
+
operation: "createTotpVerifyBackupCreate",
|
|
4954
|
+
path: "/cfg/totp/verify/backup/",
|
|
4955
|
+
method: "POST",
|
|
4956
|
+
error,
|
|
4957
|
+
response,
|
|
4958
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
4959
|
+
},
|
|
4960
|
+
bubbles: true,
|
|
4961
|
+
cancelable: false
|
|
4962
|
+
});
|
|
4963
|
+
window.dispatchEvent(event);
|
|
4964
|
+
} catch (eventError) {
|
|
4965
|
+
import_consola15.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
4966
|
+
}
|
|
4967
|
+
}
|
|
4968
|
+
throw error;
|
|
4969
|
+
}
|
|
4970
|
+
}
|
|
4971
|
+
__name(createTotpVerifyBackupCreate, "createTotpVerifyBackupCreate");
|
|
4972
|
+
|
|
4973
|
+
// src/generated/cfg_totp/index.ts
|
|
4974
|
+
var TOKEN_KEY3 = "auth_token";
|
|
4975
|
+
var REFRESH_TOKEN_KEY3 = "refresh_token";
|
|
4976
|
+
var API3 = class {
|
|
4977
|
+
constructor(baseUrl, options) {
|
|
4978
|
+
this._token = null;
|
|
4979
|
+
this._refreshToken = null;
|
|
4980
|
+
this.baseUrl = baseUrl;
|
|
4981
|
+
this.options = options;
|
|
4982
|
+
const logger = options?.loggerConfig ? new APILogger3(options.loggerConfig) : void 0;
|
|
4983
|
+
this.storage = options?.storage || new LocalStorageAdapter3(logger);
|
|
4984
|
+
this._loadTokensFromStorage();
|
|
4985
|
+
this._client = new APIClient3(this.baseUrl, {
|
|
4986
|
+
retryConfig: this.options?.retryConfig,
|
|
4987
|
+
loggerConfig: this.options?.loggerConfig
|
|
4988
|
+
});
|
|
4989
|
+
this._injectAuthHeader();
|
|
4990
|
+
this.backup_codes = this._client.backup_codes;
|
|
4991
|
+
this.totp_management = this._client.totp_management;
|
|
4992
|
+
this.totp_setup = this._client.totp_setup;
|
|
4993
|
+
this.totp_verification = this._client.totp_verification;
|
|
4994
|
+
this.totp = this._client.totp;
|
|
4995
|
+
}
|
|
4996
|
+
static {
|
|
4997
|
+
__name(this, "API");
|
|
4998
|
+
}
|
|
4999
|
+
_loadTokensFromStorage() {
|
|
5000
|
+
this._token = this.storage.getItem(TOKEN_KEY3);
|
|
5001
|
+
this._refreshToken = this.storage.getItem(REFRESH_TOKEN_KEY3);
|
|
5002
|
+
}
|
|
5003
|
+
_reinitClients() {
|
|
5004
|
+
this._client = new APIClient3(this.baseUrl, {
|
|
5005
|
+
retryConfig: this.options?.retryConfig,
|
|
5006
|
+
loggerConfig: this.options?.loggerConfig
|
|
5007
|
+
});
|
|
5008
|
+
this._injectAuthHeader();
|
|
5009
|
+
this.backup_codes = this._client.backup_codes;
|
|
5010
|
+
this.totp_management = this._client.totp_management;
|
|
5011
|
+
this.totp_setup = this._client.totp_setup;
|
|
5012
|
+
this.totp_verification = this._client.totp_verification;
|
|
5013
|
+
this.totp = this._client.totp;
|
|
5014
|
+
}
|
|
5015
|
+
_injectAuthHeader() {
|
|
5016
|
+
const originalRequest = this._client.request.bind(this._client);
|
|
5017
|
+
this._client.request = async (method, path, options) => {
|
|
5018
|
+
const token = this.getToken();
|
|
5019
|
+
const mergedOptions = {
|
|
5020
|
+
...options,
|
|
5021
|
+
headers: {
|
|
5022
|
+
...options?.headers || {},
|
|
5023
|
+
...token ? { "Authorization": `Bearer ${token}` } : {}
|
|
5024
|
+
}
|
|
5025
|
+
};
|
|
5026
|
+
return originalRequest(method, path, mergedOptions);
|
|
5027
|
+
};
|
|
5028
|
+
}
|
|
5029
|
+
/**
|
|
5030
|
+
* Get current JWT token
|
|
5031
|
+
*/
|
|
5032
|
+
getToken() {
|
|
5033
|
+
return this.storage.getItem(TOKEN_KEY3);
|
|
5034
|
+
}
|
|
5035
|
+
/**
|
|
5036
|
+
* Get current refresh token
|
|
5037
|
+
*/
|
|
5038
|
+
getRefreshToken() {
|
|
5039
|
+
return this.storage.getItem(REFRESH_TOKEN_KEY3);
|
|
5040
|
+
}
|
|
5041
|
+
/**
|
|
5042
|
+
* Set JWT token and refresh token
|
|
5043
|
+
* @param token - JWT access token
|
|
5044
|
+
* @param refreshToken - JWT refresh token (optional)
|
|
5045
|
+
*/
|
|
5046
|
+
setToken(token, refreshToken) {
|
|
5047
|
+
this._token = token;
|
|
5048
|
+
this.storage.setItem(TOKEN_KEY3, token);
|
|
5049
|
+
if (refreshToken) {
|
|
5050
|
+
this._refreshToken = refreshToken;
|
|
5051
|
+
this.storage.setItem(REFRESH_TOKEN_KEY3, refreshToken);
|
|
5052
|
+
}
|
|
5053
|
+
this._reinitClients();
|
|
5054
|
+
}
|
|
5055
|
+
/**
|
|
5056
|
+
* Clear all tokens
|
|
5057
|
+
*/
|
|
5058
|
+
clearTokens() {
|
|
5059
|
+
this._token = null;
|
|
5060
|
+
this._refreshToken = null;
|
|
5061
|
+
this.storage.removeItem(TOKEN_KEY3);
|
|
5062
|
+
this.storage.removeItem(REFRESH_TOKEN_KEY3);
|
|
5063
|
+
this._reinitClients();
|
|
5064
|
+
}
|
|
5065
|
+
/**
|
|
5066
|
+
* Check if user is authenticated
|
|
5067
|
+
*/
|
|
5068
|
+
isAuthenticated() {
|
|
5069
|
+
return !!this.getToken();
|
|
5070
|
+
}
|
|
5071
|
+
/**
|
|
5072
|
+
* Update base URL and reinitialize clients
|
|
5073
|
+
* @param url - New base URL
|
|
5074
|
+
*/
|
|
5075
|
+
setBaseUrl(url) {
|
|
5076
|
+
this.baseUrl = url;
|
|
5077
|
+
this._reinitClients();
|
|
5078
|
+
}
|
|
5079
|
+
/**
|
|
5080
|
+
* Get current base URL
|
|
5081
|
+
*/
|
|
5082
|
+
getBaseUrl() {
|
|
5083
|
+
return this.baseUrl;
|
|
5084
|
+
}
|
|
5085
|
+
/**
|
|
5086
|
+
* Get OpenAPI schema path
|
|
5087
|
+
* @returns Path to the OpenAPI schema JSON file
|
|
5088
|
+
*
|
|
5089
|
+
* Note: The OpenAPI schema is available in the schema.json file.
|
|
5090
|
+
* You can load it dynamically using:
|
|
5091
|
+
* ```typescript
|
|
5092
|
+
* const schema = await fetch('./schema.json').then(r => r.json());
|
|
5093
|
+
* // or using fs in Node.js:
|
|
5094
|
+
* // const schema = JSON.parse(fs.readFileSync('./schema.json', 'utf-8'));
|
|
5095
|
+
* ```
|
|
5096
|
+
*/
|
|
5097
|
+
getSchemaPath() {
|
|
5098
|
+
return "./schema.json";
|
|
5099
|
+
}
|
|
5100
|
+
};
|
|
5101
|
+
|
|
3716
5102
|
// src/generated/cfg_webpush/webpush__web_push/client.ts
|
|
3717
5103
|
var WebPush = class {
|
|
3718
5104
|
static {
|
|
@@ -3752,12 +5138,12 @@ var WebPush = class {
|
|
|
3752
5138
|
};
|
|
3753
5139
|
|
|
3754
5140
|
// src/generated/cfg_webpush/http.ts
|
|
3755
|
-
var
|
|
5141
|
+
var FetchAdapter4 = class {
|
|
3756
5142
|
static {
|
|
3757
5143
|
__name(this, "FetchAdapter");
|
|
3758
5144
|
}
|
|
3759
5145
|
async request(request) {
|
|
3760
|
-
const { method, url, headers, body, params, formData } = request;
|
|
5146
|
+
const { method, url, headers, body, params, formData, binaryBody } = request;
|
|
3761
5147
|
let finalUrl = url;
|
|
3762
5148
|
if (params) {
|
|
3763
5149
|
const searchParams = new URLSearchParams();
|
|
@@ -3775,6 +5161,9 @@ var FetchAdapter3 = class {
|
|
|
3775
5161
|
let requestBody;
|
|
3776
5162
|
if (formData) {
|
|
3777
5163
|
requestBody = formData;
|
|
5164
|
+
} else if (binaryBody) {
|
|
5165
|
+
finalHeaders["Content-Type"] = "application/octet-stream";
|
|
5166
|
+
requestBody = binaryBody;
|
|
3778
5167
|
} else if (body) {
|
|
3779
5168
|
finalHeaders["Content-Type"] = "application/json";
|
|
3780
5169
|
requestBody = JSON.stringify(body);
|
|
@@ -3807,7 +5196,7 @@ var FetchAdapter3 = class {
|
|
|
3807
5196
|
};
|
|
3808
5197
|
|
|
3809
5198
|
// src/generated/cfg_webpush/errors.ts
|
|
3810
|
-
var
|
|
5199
|
+
var APIError4 = class extends Error {
|
|
3811
5200
|
constructor(statusCode, statusText, response, url, message) {
|
|
3812
5201
|
super(message || `HTTP ${statusCode}: ${statusText}`);
|
|
3813
5202
|
this.statusCode = statusCode;
|
|
@@ -3883,7 +5272,7 @@ var APIError3 = class extends Error {
|
|
|
3883
5272
|
return this.statusCode >= 500 && this.statusCode < 600;
|
|
3884
5273
|
}
|
|
3885
5274
|
};
|
|
3886
|
-
var
|
|
5275
|
+
var NetworkError4 = class extends Error {
|
|
3887
5276
|
constructor(message, url, originalError) {
|
|
3888
5277
|
super(message);
|
|
3889
5278
|
this.url = url;
|
|
@@ -3896,8 +5285,8 @@ var NetworkError3 = class extends Error {
|
|
|
3896
5285
|
};
|
|
3897
5286
|
|
|
3898
5287
|
// src/generated/cfg_webpush/logger.ts
|
|
3899
|
-
var
|
|
3900
|
-
var
|
|
5288
|
+
var import_consola16 = require("consola");
|
|
5289
|
+
var DEFAULT_CONFIG4 = {
|
|
3901
5290
|
enabled: process.env.NODE_ENV !== "production",
|
|
3902
5291
|
logRequests: true,
|
|
3903
5292
|
logResponses: true,
|
|
@@ -3905,20 +5294,20 @@ var DEFAULT_CONFIG3 = {
|
|
|
3905
5294
|
logBodies: true,
|
|
3906
5295
|
logHeaders: false
|
|
3907
5296
|
};
|
|
3908
|
-
var
|
|
5297
|
+
var SENSITIVE_HEADERS4 = [
|
|
3909
5298
|
"authorization",
|
|
3910
5299
|
"cookie",
|
|
3911
5300
|
"set-cookie",
|
|
3912
5301
|
"x-api-key",
|
|
3913
5302
|
"x-csrf-token"
|
|
3914
5303
|
];
|
|
3915
|
-
var
|
|
5304
|
+
var APILogger4 = class {
|
|
3916
5305
|
static {
|
|
3917
5306
|
__name(this, "APILogger");
|
|
3918
5307
|
}
|
|
3919
5308
|
constructor(config = {}) {
|
|
3920
|
-
this.config = { ...
|
|
3921
|
-
this.consola = config.consola || (0,
|
|
5309
|
+
this.config = { ...DEFAULT_CONFIG4, ...config };
|
|
5310
|
+
this.consola = config.consola || (0, import_consola16.createConsola)({
|
|
3922
5311
|
level: this.config.enabled ? 4 : 0
|
|
3923
5312
|
});
|
|
3924
5313
|
}
|
|
@@ -3948,7 +5337,7 @@ var APILogger3 = class {
|
|
|
3948
5337
|
const filtered = {};
|
|
3949
5338
|
Object.keys(headers).forEach((key) => {
|
|
3950
5339
|
const lowerKey = key.toLowerCase();
|
|
3951
|
-
if (
|
|
5340
|
+
if (SENSITIVE_HEADERS4.includes(lowerKey)) {
|
|
3952
5341
|
filtered[key] = "***";
|
|
3953
5342
|
} else {
|
|
3954
5343
|
filtered[key] = headers[key] || "";
|
|
@@ -4047,11 +5436,11 @@ var APILogger3 = class {
|
|
|
4047
5436
|
return this.consola.withTag(tag);
|
|
4048
5437
|
}
|
|
4049
5438
|
};
|
|
4050
|
-
var
|
|
5439
|
+
var defaultLogger4 = new APILogger4();
|
|
4051
5440
|
|
|
4052
5441
|
// src/generated/cfg_webpush/retry.ts
|
|
4053
|
-
var
|
|
4054
|
-
var
|
|
5442
|
+
var import_p_retry4 = __toESM(require("p-retry"), 1);
|
|
5443
|
+
var DEFAULT_RETRY_CONFIG4 = {
|
|
4055
5444
|
retries: 3,
|
|
4056
5445
|
factor: 2,
|
|
4057
5446
|
minTimeout: 1e3,
|
|
@@ -4060,11 +5449,11 @@ var DEFAULT_RETRY_CONFIG3 = {
|
|
|
4060
5449
|
onFailedAttempt: /* @__PURE__ */ __name(() => {
|
|
4061
5450
|
}, "onFailedAttempt")
|
|
4062
5451
|
};
|
|
4063
|
-
function
|
|
4064
|
-
if (error instanceof
|
|
5452
|
+
function shouldRetry4(error) {
|
|
5453
|
+
if (error instanceof NetworkError4) {
|
|
4065
5454
|
return true;
|
|
4066
5455
|
}
|
|
4067
|
-
if (error instanceof
|
|
5456
|
+
if (error instanceof APIError4) {
|
|
4068
5457
|
const status = error.statusCode;
|
|
4069
5458
|
if (status >= 500 && status < 600) {
|
|
4070
5459
|
return true;
|
|
@@ -4076,16 +5465,16 @@ function shouldRetry3(error) {
|
|
|
4076
5465
|
}
|
|
4077
5466
|
return true;
|
|
4078
5467
|
}
|
|
4079
|
-
__name(
|
|
4080
|
-
async function
|
|
4081
|
-
const finalConfig = { ...
|
|
4082
|
-
return (0,
|
|
5468
|
+
__name(shouldRetry4, "shouldRetry");
|
|
5469
|
+
async function withRetry4(fn, config) {
|
|
5470
|
+
const finalConfig = { ...DEFAULT_RETRY_CONFIG4, ...config };
|
|
5471
|
+
return (0, import_p_retry4.default)(
|
|
4083
5472
|
async () => {
|
|
4084
5473
|
try {
|
|
4085
5474
|
return await fn();
|
|
4086
5475
|
} catch (error) {
|
|
4087
|
-
if (!
|
|
4088
|
-
throw new
|
|
5476
|
+
if (!shouldRetry4(error)) {
|
|
5477
|
+
throw new import_p_retry4.AbortError(error);
|
|
4089
5478
|
}
|
|
4090
5479
|
throw error;
|
|
4091
5480
|
}
|
|
@@ -4107,17 +5496,17 @@ async function withRetry3(fn, config) {
|
|
|
4107
5496
|
}
|
|
4108
5497
|
);
|
|
4109
5498
|
}
|
|
4110
|
-
__name(
|
|
5499
|
+
__name(withRetry4, "withRetry");
|
|
4111
5500
|
|
|
4112
5501
|
// src/generated/cfg_webpush/client.ts
|
|
4113
|
-
var
|
|
5502
|
+
var APIClient4 = class {
|
|
4114
5503
|
constructor(baseUrl, options) {
|
|
4115
5504
|
this.logger = null;
|
|
4116
5505
|
this.retryConfig = null;
|
|
4117
5506
|
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
4118
|
-
this.httpClient = options?.httpClient || new
|
|
5507
|
+
this.httpClient = options?.httpClient || new FetchAdapter4();
|
|
4119
5508
|
if (options?.loggerConfig !== void 0) {
|
|
4120
|
-
this.logger = new
|
|
5509
|
+
this.logger = new APILogger4(options.loggerConfig);
|
|
4121
5510
|
}
|
|
4122
5511
|
if (options?.retryConfig !== void 0) {
|
|
4123
5512
|
this.retryConfig = options.retryConfig;
|
|
@@ -4147,7 +5536,7 @@ var APIClient3 = class {
|
|
|
4147
5536
|
*/
|
|
4148
5537
|
async request(method, path, options) {
|
|
4149
5538
|
if (this.retryConfig) {
|
|
4150
|
-
return
|
|
5539
|
+
return withRetry4(() => this._makeRequest(method, path, options), {
|
|
4151
5540
|
...this.retryConfig,
|
|
4152
5541
|
onFailedAttempt: /* @__PURE__ */ __name((info) => {
|
|
4153
5542
|
if (this.logger) {
|
|
@@ -4171,7 +5560,7 @@ var APIClient3 = class {
|
|
|
4171
5560
|
const headers = {
|
|
4172
5561
|
...options?.headers || {}
|
|
4173
5562
|
};
|
|
4174
|
-
if (!options?.formData && !headers["Content-Type"]) {
|
|
5563
|
+
if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
|
|
4175
5564
|
headers["Content-Type"] = "application/json";
|
|
4176
5565
|
}
|
|
4177
5566
|
if (this.logger) {
|
|
@@ -4190,11 +5579,12 @@ var APIClient3 = class {
|
|
|
4190
5579
|
headers,
|
|
4191
5580
|
params: options?.params,
|
|
4192
5581
|
body: options?.body,
|
|
4193
|
-
formData: options?.formData
|
|
5582
|
+
formData: options?.formData,
|
|
5583
|
+
binaryBody: options?.binaryBody
|
|
4194
5584
|
});
|
|
4195
5585
|
const duration = Date.now() - startTime;
|
|
4196
5586
|
if (response.status >= 400) {
|
|
4197
|
-
const error = new
|
|
5587
|
+
const error = new APIError4(
|
|
4198
5588
|
response.status,
|
|
4199
5589
|
response.statusText,
|
|
4200
5590
|
response.data,
|
|
@@ -4240,7 +5630,7 @@ var APIClient3 = class {
|
|
|
4240
5630
|
return response.data;
|
|
4241
5631
|
} catch (error) {
|
|
4242
5632
|
const duration = Date.now() - startTime;
|
|
4243
|
-
if (error instanceof
|
|
5633
|
+
if (error instanceof APIError4) {
|
|
4244
5634
|
throw error;
|
|
4245
5635
|
}
|
|
4246
5636
|
const isCORSError = error instanceof TypeError && (error.message.toLowerCase().includes("cors") || error.message.toLowerCase().includes("failed to fetch") || error.message.toLowerCase().includes("network request failed"));
|
|
@@ -4282,7 +5672,7 @@ var APIClient3 = class {
|
|
|
4282
5672
|
} catch (eventError) {
|
|
4283
5673
|
}
|
|
4284
5674
|
}
|
|
4285
|
-
const networkError = error instanceof Error ? new
|
|
5675
|
+
const networkError = error instanceof Error ? new NetworkError4(error.message, url, error) : new NetworkError4("Unknown error", url);
|
|
4286
5676
|
if (this.logger) {
|
|
4287
5677
|
this.logger.logError(
|
|
4288
5678
|
{
|
|
@@ -4305,7 +5695,7 @@ var APIClient3 = class {
|
|
|
4305
5695
|
};
|
|
4306
5696
|
|
|
4307
5697
|
// src/generated/cfg_webpush/storage.ts
|
|
4308
|
-
var
|
|
5698
|
+
var LocalStorageAdapter4 = class {
|
|
4309
5699
|
static {
|
|
4310
5700
|
__name(this, "LocalStorageAdapter");
|
|
4311
5701
|
}
|
|
@@ -4352,8 +5742,8 @@ var LocalStorageAdapter3 = class {
|
|
|
4352
5742
|
};
|
|
4353
5743
|
|
|
4354
5744
|
// src/generated/cfg_webpush/_utils/schemas/index.ts
|
|
4355
|
-
var
|
|
4356
|
-
__export(
|
|
5745
|
+
var schemas_exports4 = {};
|
|
5746
|
+
__export(schemas_exports4, {
|
|
4357
5747
|
SendPushRequestRequestSchema: () => SendPushRequestRequestSchema,
|
|
4358
5748
|
SendPushResponseSchema: () => SendPushResponseSchema,
|
|
4359
5749
|
SubscribeRequestRequestSchema: () => SubscribeRequestRequestSchema,
|
|
@@ -4362,99 +5752,99 @@ __export(schemas_exports3, {
|
|
|
4362
5752
|
});
|
|
4363
5753
|
|
|
4364
5754
|
// src/generated/cfg_webpush/_utils/schemas/SendPushRequestRequest.schema.ts
|
|
4365
|
-
var
|
|
4366
|
-
var SendPushRequestRequestSchema =
|
|
4367
|
-
title:
|
|
4368
|
-
body:
|
|
4369
|
-
icon:
|
|
4370
|
-
url:
|
|
5755
|
+
var import_zod68 = require("zod");
|
|
5756
|
+
var SendPushRequestRequestSchema = import_zod68.z.object({
|
|
5757
|
+
title: import_zod68.z.string().min(1).max(255),
|
|
5758
|
+
body: import_zod68.z.string().min(1),
|
|
5759
|
+
icon: import_zod68.z.union([import_zod68.z.url(), import_zod68.z.literal("")]).nullable().optional(),
|
|
5760
|
+
url: import_zod68.z.union([import_zod68.z.url(), import_zod68.z.literal("")]).nullable().optional()
|
|
4371
5761
|
});
|
|
4372
5762
|
|
|
4373
5763
|
// src/generated/cfg_webpush/_utils/schemas/SendPushResponse.schema.ts
|
|
4374
|
-
var
|
|
4375
|
-
var SendPushResponseSchema =
|
|
4376
|
-
success:
|
|
4377
|
-
sent_to:
|
|
5764
|
+
var import_zod69 = require("zod");
|
|
5765
|
+
var SendPushResponseSchema = import_zod69.z.object({
|
|
5766
|
+
success: import_zod69.z.boolean(),
|
|
5767
|
+
sent_to: import_zod69.z.int()
|
|
4378
5768
|
});
|
|
4379
5769
|
|
|
4380
5770
|
// src/generated/cfg_webpush/_utils/schemas/SubscribeRequestRequest.schema.ts
|
|
4381
|
-
var
|
|
4382
|
-
var SubscribeRequestRequestSchema =
|
|
4383
|
-
endpoint:
|
|
4384
|
-
keys:
|
|
5771
|
+
var import_zod70 = require("zod");
|
|
5772
|
+
var SubscribeRequestRequestSchema = import_zod70.z.object({
|
|
5773
|
+
endpoint: import_zod70.z.union([import_zod70.z.url(), import_zod70.z.literal("")]),
|
|
5774
|
+
keys: import_zod70.z.record(import_zod70.z.string(), import_zod70.z.string().min(1))
|
|
4385
5775
|
});
|
|
4386
5776
|
|
|
4387
5777
|
// src/generated/cfg_webpush/_utils/schemas/SubscribeResponse.schema.ts
|
|
4388
|
-
var
|
|
4389
|
-
var SubscribeResponseSchema =
|
|
4390
|
-
success:
|
|
4391
|
-
subscription_id:
|
|
4392
|
-
created:
|
|
5778
|
+
var import_zod71 = require("zod");
|
|
5779
|
+
var SubscribeResponseSchema = import_zod71.z.object({
|
|
5780
|
+
success: import_zod71.z.boolean(),
|
|
5781
|
+
subscription_id: import_zod71.z.int(),
|
|
5782
|
+
created: import_zod71.z.boolean()
|
|
4393
5783
|
});
|
|
4394
5784
|
|
|
4395
5785
|
// src/generated/cfg_webpush/_utils/schemas/VapidPublicKeyResponse.schema.ts
|
|
4396
|
-
var
|
|
4397
|
-
var VapidPublicKeyResponseSchema =
|
|
4398
|
-
publicKey:
|
|
5786
|
+
var import_zod72 = require("zod");
|
|
5787
|
+
var VapidPublicKeyResponseSchema = import_zod72.z.object({
|
|
5788
|
+
publicKey: import_zod72.z.string()
|
|
4399
5789
|
});
|
|
4400
5790
|
|
|
4401
5791
|
// src/generated/cfg_webpush/_utils/fetchers/index.ts
|
|
4402
|
-
var
|
|
4403
|
-
__export(
|
|
5792
|
+
var fetchers_exports4 = {};
|
|
5793
|
+
__export(fetchers_exports4, {
|
|
4404
5794
|
createWebpushSendCreate: () => createWebpushSendCreate,
|
|
4405
5795
|
createWebpushSubscribeCreate: () => createWebpushSubscribeCreate,
|
|
4406
5796
|
getWebpushVapidRetrieve: () => getWebpushVapidRetrieve
|
|
4407
5797
|
});
|
|
4408
5798
|
|
|
4409
5799
|
// src/generated/cfg_webpush/_utils/fetchers/webpush__web_push.ts
|
|
4410
|
-
var
|
|
5800
|
+
var import_consola17 = require("consola");
|
|
4411
5801
|
|
|
4412
5802
|
// src/generated/cfg_webpush/api-instance.ts
|
|
4413
|
-
var
|
|
4414
|
-
var
|
|
4415
|
-
function
|
|
4416
|
-
if (
|
|
4417
|
-
|
|
4418
|
-
if (
|
|
5803
|
+
var globalAPI4 = null;
|
|
5804
|
+
var autoConfigAttempted4 = false;
|
|
5805
|
+
function tryAutoConfigureFromEnv4() {
|
|
5806
|
+
if (autoConfigAttempted4) return;
|
|
5807
|
+
autoConfigAttempted4 = true;
|
|
5808
|
+
if (globalAPI4) return;
|
|
4419
5809
|
if (typeof process === "undefined" || !process.env) return;
|
|
4420
5810
|
const baseUrl = process.env.NEXT_PUBLIC_API_URL || process.env.VITE_API_URL || process.env.REACT_APP_API_URL || process.env.API_URL;
|
|
4421
5811
|
if (baseUrl) {
|
|
4422
|
-
|
|
5812
|
+
globalAPI4 = new API4(baseUrl);
|
|
4423
5813
|
}
|
|
4424
5814
|
}
|
|
4425
|
-
__name(
|
|
4426
|
-
function
|
|
4427
|
-
|
|
4428
|
-
if (!
|
|
5815
|
+
__name(tryAutoConfigureFromEnv4, "tryAutoConfigureFromEnv");
|
|
5816
|
+
function getAPIInstance4() {
|
|
5817
|
+
tryAutoConfigureFromEnv4();
|
|
5818
|
+
if (!globalAPI4) {
|
|
4429
5819
|
throw new Error(
|
|
4430
5820
|
'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'
|
|
4431
5821
|
);
|
|
4432
5822
|
}
|
|
4433
|
-
return
|
|
5823
|
+
return globalAPI4;
|
|
4434
5824
|
}
|
|
4435
|
-
__name(
|
|
5825
|
+
__name(getAPIInstance4, "getAPIInstance");
|
|
4436
5826
|
|
|
4437
5827
|
// src/generated/cfg_webpush/_utils/fetchers/webpush__web_push.ts
|
|
4438
5828
|
async function createWebpushSendCreate(data, client) {
|
|
4439
|
-
const api = client ||
|
|
5829
|
+
const api = client || getAPIInstance4();
|
|
4440
5830
|
const response = await api.web_push.webpushSendCreate(data);
|
|
4441
5831
|
try {
|
|
4442
5832
|
return SendPushResponseSchema.parse(response);
|
|
4443
5833
|
} catch (error) {
|
|
4444
|
-
|
|
4445
|
-
|
|
5834
|
+
import_consola17.consola.error("\u274C Zod Validation Failed");
|
|
5835
|
+
import_consola17.consola.box(`createWebpushSendCreate
|
|
4446
5836
|
Path: /cfg/webpush/send/
|
|
4447
5837
|
Method: POST`);
|
|
4448
5838
|
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
4449
|
-
|
|
5839
|
+
import_consola17.consola.error("Validation Issues:");
|
|
4450
5840
|
error.issues.forEach((issue, index) => {
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
if (issue.expected)
|
|
4454
|
-
if (issue.received)
|
|
5841
|
+
import_consola17.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
5842
|
+
import_consola17.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
5843
|
+
if (issue.expected) import_consola17.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
5844
|
+
if (issue.received) import_consola17.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
4455
5845
|
});
|
|
4456
5846
|
}
|
|
4457
|
-
|
|
5847
|
+
import_consola17.consola.error("Response data:", response);
|
|
4458
5848
|
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
4459
5849
|
try {
|
|
4460
5850
|
const event = new CustomEvent("zod-validation-error", {
|
|
@@ -4471,7 +5861,7 @@ Method: POST`);
|
|
|
4471
5861
|
});
|
|
4472
5862
|
window.dispatchEvent(event);
|
|
4473
5863
|
} catch (eventError) {
|
|
4474
|
-
|
|
5864
|
+
import_consola17.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
4475
5865
|
}
|
|
4476
5866
|
}
|
|
4477
5867
|
throw error;
|
|
@@ -4479,25 +5869,25 @@ Method: POST`);
|
|
|
4479
5869
|
}
|
|
4480
5870
|
__name(createWebpushSendCreate, "createWebpushSendCreate");
|
|
4481
5871
|
async function createWebpushSubscribeCreate(data, client) {
|
|
4482
|
-
const api = client ||
|
|
5872
|
+
const api = client || getAPIInstance4();
|
|
4483
5873
|
const response = await api.web_push.webpushSubscribeCreate(data);
|
|
4484
5874
|
try {
|
|
4485
5875
|
return SubscribeResponseSchema.parse(response);
|
|
4486
5876
|
} catch (error) {
|
|
4487
|
-
|
|
4488
|
-
|
|
5877
|
+
import_consola17.consola.error("\u274C Zod Validation Failed");
|
|
5878
|
+
import_consola17.consola.box(`createWebpushSubscribeCreate
|
|
4489
5879
|
Path: /cfg/webpush/subscribe/
|
|
4490
5880
|
Method: POST`);
|
|
4491
5881
|
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
4492
|
-
|
|
5882
|
+
import_consola17.consola.error("Validation Issues:");
|
|
4493
5883
|
error.issues.forEach((issue, index) => {
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
if (issue.expected)
|
|
4497
|
-
if (issue.received)
|
|
5884
|
+
import_consola17.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
5885
|
+
import_consola17.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
5886
|
+
if (issue.expected) import_consola17.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
5887
|
+
if (issue.received) import_consola17.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
4498
5888
|
});
|
|
4499
5889
|
}
|
|
4500
|
-
|
|
5890
|
+
import_consola17.consola.error("Response data:", response);
|
|
4501
5891
|
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
4502
5892
|
try {
|
|
4503
5893
|
const event = new CustomEvent("zod-validation-error", {
|
|
@@ -4514,7 +5904,7 @@ Method: POST`);
|
|
|
4514
5904
|
});
|
|
4515
5905
|
window.dispatchEvent(event);
|
|
4516
5906
|
} catch (eventError) {
|
|
4517
|
-
|
|
5907
|
+
import_consola17.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
4518
5908
|
}
|
|
4519
5909
|
}
|
|
4520
5910
|
throw error;
|
|
@@ -4522,25 +5912,25 @@ Method: POST`);
|
|
|
4522
5912
|
}
|
|
4523
5913
|
__name(createWebpushSubscribeCreate, "createWebpushSubscribeCreate");
|
|
4524
5914
|
async function getWebpushVapidRetrieve(client) {
|
|
4525
|
-
const api = client ||
|
|
5915
|
+
const api = client || getAPIInstance4();
|
|
4526
5916
|
const response = await api.web_push.webpushVapidRetrieve();
|
|
4527
5917
|
try {
|
|
4528
5918
|
return VapidPublicKeyResponseSchema.parse(response);
|
|
4529
5919
|
} catch (error) {
|
|
4530
|
-
|
|
4531
|
-
|
|
5920
|
+
import_consola17.consola.error("\u274C Zod Validation Failed");
|
|
5921
|
+
import_consola17.consola.box(`getWebpushVapidRetrieve
|
|
4532
5922
|
Path: /cfg/webpush/vapid/
|
|
4533
5923
|
Method: GET`);
|
|
4534
5924
|
if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
|
|
4535
|
-
|
|
5925
|
+
import_consola17.consola.error("Validation Issues:");
|
|
4536
5926
|
error.issues.forEach((issue, index) => {
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
if (issue.expected)
|
|
4540
|
-
if (issue.received)
|
|
5927
|
+
import_consola17.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
|
|
5928
|
+
import_consola17.consola.error(` \u251C\u2500 Message: ${issue.message}`);
|
|
5929
|
+
if (issue.expected) import_consola17.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
|
|
5930
|
+
if (issue.received) import_consola17.consola.error(` \u2514\u2500 Received: ${issue.received}`);
|
|
4541
5931
|
});
|
|
4542
5932
|
}
|
|
4543
|
-
|
|
5933
|
+
import_consola17.consola.error("Response data:", response);
|
|
4544
5934
|
if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
|
|
4545
5935
|
try {
|
|
4546
5936
|
const event = new CustomEvent("zod-validation-error", {
|
|
@@ -4557,7 +5947,7 @@ Method: GET`);
|
|
|
4557
5947
|
});
|
|
4558
5948
|
window.dispatchEvent(event);
|
|
4559
5949
|
} catch (eventError) {
|
|
4560
|
-
|
|
5950
|
+
import_consola17.consola.warn("Failed to dispatch validation error event:", eventError);
|
|
4561
5951
|
}
|
|
4562
5952
|
}
|
|
4563
5953
|
throw error;
|
|
@@ -4566,18 +5956,18 @@ Method: GET`);
|
|
|
4566
5956
|
__name(getWebpushVapidRetrieve, "getWebpushVapidRetrieve");
|
|
4567
5957
|
|
|
4568
5958
|
// src/generated/cfg_webpush/index.ts
|
|
4569
|
-
var
|
|
4570
|
-
var
|
|
4571
|
-
var
|
|
5959
|
+
var TOKEN_KEY4 = "auth_token";
|
|
5960
|
+
var REFRESH_TOKEN_KEY4 = "refresh_token";
|
|
5961
|
+
var API4 = class {
|
|
4572
5962
|
constructor(baseUrl, options) {
|
|
4573
5963
|
this._token = null;
|
|
4574
5964
|
this._refreshToken = null;
|
|
4575
5965
|
this.baseUrl = baseUrl;
|
|
4576
5966
|
this.options = options;
|
|
4577
|
-
const logger = options?.loggerConfig ? new
|
|
4578
|
-
this.storage = options?.storage || new
|
|
5967
|
+
const logger = options?.loggerConfig ? new APILogger4(options.loggerConfig) : void 0;
|
|
5968
|
+
this.storage = options?.storage || new LocalStorageAdapter4(logger);
|
|
4579
5969
|
this._loadTokensFromStorage();
|
|
4580
|
-
this._client = new
|
|
5970
|
+
this._client = new APIClient4(this.baseUrl, {
|
|
4581
5971
|
retryConfig: this.options?.retryConfig,
|
|
4582
5972
|
loggerConfig: this.options?.loggerConfig
|
|
4583
5973
|
});
|
|
@@ -4588,11 +5978,11 @@ var API3 = class {
|
|
|
4588
5978
|
__name(this, "API");
|
|
4589
5979
|
}
|
|
4590
5980
|
_loadTokensFromStorage() {
|
|
4591
|
-
this._token = this.storage.getItem(
|
|
4592
|
-
this._refreshToken = this.storage.getItem(
|
|
5981
|
+
this._token = this.storage.getItem(TOKEN_KEY4);
|
|
5982
|
+
this._refreshToken = this.storage.getItem(REFRESH_TOKEN_KEY4);
|
|
4593
5983
|
}
|
|
4594
5984
|
_reinitClients() {
|
|
4595
|
-
this._client = new
|
|
5985
|
+
this._client = new APIClient4(this.baseUrl, {
|
|
4596
5986
|
retryConfig: this.options?.retryConfig,
|
|
4597
5987
|
loggerConfig: this.options?.loggerConfig
|
|
4598
5988
|
});
|
|
@@ -4617,13 +6007,13 @@ var API3 = class {
|
|
|
4617
6007
|
* Get current JWT token
|
|
4618
6008
|
*/
|
|
4619
6009
|
getToken() {
|
|
4620
|
-
return this.storage.getItem(
|
|
6010
|
+
return this.storage.getItem(TOKEN_KEY4);
|
|
4621
6011
|
}
|
|
4622
6012
|
/**
|
|
4623
6013
|
* Get current refresh token
|
|
4624
6014
|
*/
|
|
4625
6015
|
getRefreshToken() {
|
|
4626
|
-
return this.storage.getItem(
|
|
6016
|
+
return this.storage.getItem(REFRESH_TOKEN_KEY4);
|
|
4627
6017
|
}
|
|
4628
6018
|
/**
|
|
4629
6019
|
* Set JWT token and refresh token
|
|
@@ -4632,10 +6022,10 @@ var API3 = class {
|
|
|
4632
6022
|
*/
|
|
4633
6023
|
setToken(token, refreshToken) {
|
|
4634
6024
|
this._token = token;
|
|
4635
|
-
this.storage.setItem(
|
|
6025
|
+
this.storage.setItem(TOKEN_KEY4, token);
|
|
4636
6026
|
if (refreshToken) {
|
|
4637
6027
|
this._refreshToken = refreshToken;
|
|
4638
|
-
this.storage.setItem(
|
|
6028
|
+
this.storage.setItem(REFRESH_TOKEN_KEY4, refreshToken);
|
|
4639
6029
|
}
|
|
4640
6030
|
this._reinitClients();
|
|
4641
6031
|
}
|
|
@@ -4645,8 +6035,8 @@ var API3 = class {
|
|
|
4645
6035
|
clearTokens() {
|
|
4646
6036
|
this._token = null;
|
|
4647
6037
|
this._refreshToken = null;
|
|
4648
|
-
this.storage.removeItem(
|
|
4649
|
-
this.storage.removeItem(
|
|
6038
|
+
this.storage.removeItem(TOKEN_KEY4);
|
|
6039
|
+
this.storage.removeItem(REFRESH_TOKEN_KEY4);
|
|
4650
6040
|
this._reinitClients();
|
|
4651
6041
|
}
|
|
4652
6042
|
/**
|
|
@@ -5012,11 +6402,121 @@ function useCreateCentrifugoTestingSendAckCreate() {
|
|
|
5012
6402
|
}
|
|
5013
6403
|
__name(useCreateCentrifugoTestingSendAckCreate, "useCreateCentrifugoTestingSendAckCreate");
|
|
5014
6404
|
|
|
6405
|
+
// src/generated/cfg_totp/_utils/hooks/index.ts
|
|
6406
|
+
var hooks_exports3 = {};
|
|
6407
|
+
__export(hooks_exports3, {
|
|
6408
|
+
useCreateTotpBackupCodesRegenerateCreate: () => useCreateTotpBackupCodesRegenerateCreate,
|
|
6409
|
+
useCreateTotpDisableCreate: () => useCreateTotpDisableCreate,
|
|
6410
|
+
useCreateTotpSetupConfirmCreate: () => useCreateTotpSetupConfirmCreate,
|
|
6411
|
+
useCreateTotpSetupCreate: () => useCreateTotpSetupCreate,
|
|
6412
|
+
useCreateTotpVerifyBackupCreate: () => useCreateTotpVerifyBackupCreate,
|
|
6413
|
+
useCreateTotpVerifyCreate: () => useCreateTotpVerifyCreate,
|
|
6414
|
+
useDeleteTotpDevicesDestroy: () => useDeleteTotpDevicesDestroy,
|
|
6415
|
+
useTotpBackupCodesRetrieve: () => useTotpBackupCodesRetrieve,
|
|
6416
|
+
useTotpDevicesList: () => useTotpDevicesList
|
|
6417
|
+
});
|
|
6418
|
+
|
|
6419
|
+
// src/generated/cfg_totp/_utils/hooks/totp__backup_codes.ts
|
|
6420
|
+
var import_swr13 = __toESM(require("swr"), 1);
|
|
6421
|
+
var import_swr14 = require("swr");
|
|
6422
|
+
function useTotpBackupCodesRetrieve(client) {
|
|
6423
|
+
return (0, import_swr13.default)(
|
|
6424
|
+
"cfg-totp-backup-code",
|
|
6425
|
+
() => getTotpBackupCodesRetrieve(client)
|
|
6426
|
+
);
|
|
6427
|
+
}
|
|
6428
|
+
__name(useTotpBackupCodesRetrieve, "useTotpBackupCodesRetrieve");
|
|
6429
|
+
function useCreateTotpBackupCodesRegenerateCreate() {
|
|
6430
|
+
const { mutate } = (0, import_swr14.useSWRConfig)();
|
|
6431
|
+
return async (data, client) => {
|
|
6432
|
+
const result = await createTotpBackupCodesRegenerateCreate(data, client);
|
|
6433
|
+
mutate("cfg-totp-backup-codes-regenerate");
|
|
6434
|
+
return result;
|
|
6435
|
+
};
|
|
6436
|
+
}
|
|
6437
|
+
__name(useCreateTotpBackupCodesRegenerateCreate, "useCreateTotpBackupCodesRegenerateCreate");
|
|
6438
|
+
|
|
6439
|
+
// src/generated/cfg_totp/_utils/hooks/totp__totp_management.ts
|
|
6440
|
+
var import_swr15 = __toESM(require("swr"), 1);
|
|
6441
|
+
var import_swr16 = require("swr");
|
|
6442
|
+
function useTotpDevicesList(params, client) {
|
|
6443
|
+
return (0, import_swr15.default)(
|
|
6444
|
+
params ? ["cfg-totp-devices", params] : "cfg-totp-devices",
|
|
6445
|
+
() => getTotpDevicesList(params, client)
|
|
6446
|
+
);
|
|
6447
|
+
}
|
|
6448
|
+
__name(useTotpDevicesList, "useTotpDevicesList");
|
|
6449
|
+
function useCreateTotpDisableCreate() {
|
|
6450
|
+
const { mutate } = (0, import_swr16.useSWRConfig)();
|
|
6451
|
+
return async (data, client) => {
|
|
6452
|
+
const result = await createTotpDisableCreate(data, client);
|
|
6453
|
+
mutate("cfg-totp-disable");
|
|
6454
|
+
return result;
|
|
6455
|
+
};
|
|
6456
|
+
}
|
|
6457
|
+
__name(useCreateTotpDisableCreate, "useCreateTotpDisableCreate");
|
|
6458
|
+
|
|
6459
|
+
// src/generated/cfg_totp/_utils/hooks/totp__totp_setup.ts
|
|
6460
|
+
var import_swr17 = require("swr");
|
|
6461
|
+
function useCreateTotpSetupCreate() {
|
|
6462
|
+
const { mutate } = (0, import_swr17.useSWRConfig)();
|
|
6463
|
+
return async (data, client) => {
|
|
6464
|
+
const result = await createTotpSetupCreate(data, client);
|
|
6465
|
+
mutate("cfg-totp-setup");
|
|
6466
|
+
return result;
|
|
6467
|
+
};
|
|
6468
|
+
}
|
|
6469
|
+
__name(useCreateTotpSetupCreate, "useCreateTotpSetupCreate");
|
|
6470
|
+
function useCreateTotpSetupConfirmCreate() {
|
|
6471
|
+
const { mutate } = (0, import_swr17.useSWRConfig)();
|
|
6472
|
+
return async (data, client) => {
|
|
6473
|
+
const result = await createTotpSetupConfirmCreate(data, client);
|
|
6474
|
+
mutate("cfg-totp-setup-confirm");
|
|
6475
|
+
return result;
|
|
6476
|
+
};
|
|
6477
|
+
}
|
|
6478
|
+
__name(useCreateTotpSetupConfirmCreate, "useCreateTotpSetupConfirmCreate");
|
|
6479
|
+
|
|
6480
|
+
// src/generated/cfg_totp/_utils/hooks/totp__totp_verification.ts
|
|
6481
|
+
var import_swr18 = require("swr");
|
|
6482
|
+
function useCreateTotpVerifyCreate() {
|
|
6483
|
+
const { mutate } = (0, import_swr18.useSWRConfig)();
|
|
6484
|
+
return async (data, client) => {
|
|
6485
|
+
const result = await createTotpVerifyCreate(data, client);
|
|
6486
|
+
mutate("cfg-totp-verify");
|
|
6487
|
+
return result;
|
|
6488
|
+
};
|
|
6489
|
+
}
|
|
6490
|
+
__name(useCreateTotpVerifyCreate, "useCreateTotpVerifyCreate");
|
|
6491
|
+
function useCreateTotpVerifyBackupCreate() {
|
|
6492
|
+
const { mutate } = (0, import_swr18.useSWRConfig)();
|
|
6493
|
+
return async (data, client) => {
|
|
6494
|
+
const result = await createTotpVerifyBackupCreate(data, client);
|
|
6495
|
+
mutate("cfg-totp-verify-backup");
|
|
6496
|
+
return result;
|
|
6497
|
+
};
|
|
6498
|
+
}
|
|
6499
|
+
__name(useCreateTotpVerifyBackupCreate, "useCreateTotpVerifyBackupCreate");
|
|
6500
|
+
|
|
6501
|
+
// src/generated/cfg_totp/_utils/hooks/totp.ts
|
|
6502
|
+
var import_swr19 = require("swr");
|
|
6503
|
+
function useDeleteTotpDevicesDestroy() {
|
|
6504
|
+
const { mutate } = (0, import_swr19.useSWRConfig)();
|
|
6505
|
+
return async (id, client) => {
|
|
6506
|
+
const result = await deleteTotpDevicesDestroy(id, client);
|
|
6507
|
+
mutate("cfg-totp-devices");
|
|
6508
|
+
mutate("cfg-totp-device");
|
|
6509
|
+
return result;
|
|
6510
|
+
};
|
|
6511
|
+
}
|
|
6512
|
+
__name(useDeleteTotpDevicesDestroy, "useDeleteTotpDevicesDestroy");
|
|
6513
|
+
|
|
5015
6514
|
// src/clients.ts
|
|
5016
6515
|
var isStaticBuild = process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
|
|
5017
6516
|
var apiUrl = isStaticBuild ? "" : process.env.NEXT_PUBLIC_API_URL || "";
|
|
5018
6517
|
var storage = new LocalStorageAdapter();
|
|
5019
6518
|
var apiAccounts = new API(apiUrl, { storage });
|
|
5020
|
-
var
|
|
6519
|
+
var apiTotp = new API3(apiUrl, { storage });
|
|
6520
|
+
var apiWebPush = new API4(apiUrl, { storage });
|
|
5021
6521
|
var apiCentrifugo = new API2(apiUrl, { storage });
|
|
5022
6522
|
//# sourceMappingURL=clients.cjs.map
|