@djangocfg/api 2.1.87 → 2.1.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth-server.cjs +1963 -4
- package/dist/auth-server.cjs.map +1 -1
- package/dist/auth-server.d.cts +35 -1
- package/dist/auth-server.d.ts +35 -1
- package/dist/auth-server.mjs +1953 -4
- package/dist/auth-server.mjs.map +1 -1
- package/dist/auth.cjs +692 -497
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +18 -2
- package/dist/auth.d.ts +18 -2
- package/dist/auth.mjs +655 -460
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +460 -383
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +26 -6
- package/dist/clients.d.ts +26 -6
- package/dist/clients.mjs +460 -383
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +130 -105
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +24 -4
- package/dist/hooks.d.ts +24 -4
- package/dist/hooks.mjs +130 -105
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +373 -311
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +54 -8
- package/dist/index.d.ts +54 -8
- package/dist/index.mjs +373 -311
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/auth/context/AccountsContext.tsx +3 -3
- package/src/auth/context/AuthContext.tsx +56 -10
- package/src/auth/hooks/index.ts +3 -0
- package/src/auth/hooks/useProfileCache.ts +1 -1
- package/src/auth/hooks/useTokenRefresh.ts +161 -0
- package/src/auth/middlewares/index.ts +8 -1
- package/src/auth/middlewares/tokenRefresh.ts +158 -0
- package/src/generated/cfg_accounts/CLAUDE.md +2 -9
- package/src/generated/cfg_accounts/_utils/fetchers/accounts__user_profile.ts +2 -1
- package/src/generated/cfg_accounts/_utils/hooks/accounts__user_profile.ts +2 -1
- package/src/generated/cfg_accounts/_utils/schemas/CfgAccountsProfileAvatarCreateRequest.schema.ts +15 -0
- package/src/generated/cfg_accounts/_utils/schemas/index.ts +1 -0
- package/src/generated/cfg_accounts/accounts/models.ts +0 -1
- package/src/generated/cfg_accounts/accounts__user_profile/client.ts +4 -2
- package/src/generated/cfg_accounts/accounts__user_profile/models.ts +9 -1
- package/src/generated/cfg_accounts/client.ts +18 -0
- package/src/generated/cfg_accounts/index.ts +3 -1
- package/src/generated/cfg_accounts/schema.json +2 -2
- package/src/generated/cfg_centrifugo/CLAUDE.md +1 -8
- package/src/generated/cfg_centrifugo/client.ts +18 -0
- package/src/generated/cfg_centrifugo/index.ts +3 -1
- package/src/generated/cfg_totp/CLAUDE.md +1 -8
- package/src/generated/cfg_totp/client.ts +18 -0
- package/src/generated/cfg_totp/index.ts +3 -1
- package/src/generated/cfg_totp/totp/models.ts +2 -0
- package/src/generated/cfg_webpush/CLAUDE.md +1 -8
- package/src/generated/cfg_webpush/client.ts +18 -0
- package/src/generated/cfg_webpush/index.ts +3 -1
package/dist/auth.cjs
CHANGED
|
@@ -59,6 +59,7 @@ __export(auth_exports, {
|
|
|
59
59
|
useGithubAuth: () => useGithubAuth,
|
|
60
60
|
useLocalStorage: () => useLocalStorage2,
|
|
61
61
|
useSessionStorage: () => useSessionStorage,
|
|
62
|
+
useTokenRefresh: () => useTokenRefresh,
|
|
62
63
|
useTwoFactor: () => useTwoFactor,
|
|
63
64
|
useTwoFactorSetup: () => useTwoFactorSetup,
|
|
64
65
|
useTwoFactorStatus: () => useTwoFactorStatus,
|
|
@@ -69,7 +70,7 @@ module.exports = __toCommonJS(auth_exports);
|
|
|
69
70
|
|
|
70
71
|
// src/auth/context/AuthContext.tsx
|
|
71
72
|
var import_navigation = require("next/navigation");
|
|
72
|
-
var
|
|
73
|
+
var import_react4 = require("react");
|
|
73
74
|
var import_hooks2 = require("@djangocfg/ui-nextjs/hooks");
|
|
74
75
|
|
|
75
76
|
// src/generated/cfg_accounts/accounts__auth/client.ts
|
|
@@ -170,7 +171,9 @@ var UserProfile = class {
|
|
|
170
171
|
* multipart/form-data with 'avatar' field.
|
|
171
172
|
*/
|
|
172
173
|
async accountsProfileAvatarCreate(data) {
|
|
173
|
-
const
|
|
174
|
+
const formData = new FormData();
|
|
175
|
+
formData.append("avatar", data.avatar);
|
|
176
|
+
const response = await this.client.request("POST", "/cfg/accounts/profile/avatar/", { formData });
|
|
174
177
|
return response;
|
|
175
178
|
}
|
|
176
179
|
/**
|
|
@@ -606,8 +609,10 @@ var APIClient = class {
|
|
|
606
609
|
constructor(baseUrl, options) {
|
|
607
610
|
this.logger = null;
|
|
608
611
|
this.retryConfig = null;
|
|
612
|
+
this.tokenGetter = null;
|
|
609
613
|
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
610
614
|
this.httpClient = options?.httpClient || new FetchAdapter();
|
|
615
|
+
this.tokenGetter = options?.tokenGetter || null;
|
|
611
616
|
if (options?.loggerConfig !== void 0) {
|
|
612
617
|
this.logger = new APILogger(options.loggerConfig);
|
|
613
618
|
}
|
|
@@ -636,6 +641,19 @@ var APIClient = class {
|
|
|
636
641
|
}
|
|
637
642
|
return null;
|
|
638
643
|
}
|
|
644
|
+
/**
|
|
645
|
+
* Get the base URL for building streaming/download URLs.
|
|
646
|
+
*/
|
|
647
|
+
getBaseUrl() {
|
|
648
|
+
return this.baseUrl;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Get JWT token for URL authentication (used in streaming endpoints).
|
|
652
|
+
* Returns null if no token getter is configured or no token is available.
|
|
653
|
+
*/
|
|
654
|
+
getToken() {
|
|
655
|
+
return this.tokenGetter ? this.tokenGetter() : null;
|
|
656
|
+
}
|
|
639
657
|
/**
|
|
640
658
|
* Make HTTP request with Django CSRF and session handling.
|
|
641
659
|
* Automatically retries on network errors and 5xx server errors.
|
|
@@ -883,168 +901,174 @@ var CentrifugoTokenSchema = import_zod.z.object({
|
|
|
883
901
|
channels: import_zod.z.array(import_zod.z.string())
|
|
884
902
|
});
|
|
885
903
|
|
|
886
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
904
|
+
// src/generated/cfg_accounts/_utils/schemas/CfgAccountsProfileAvatarCreateRequest.schema.ts
|
|
887
905
|
var import_zod2 = require("zod");
|
|
888
|
-
var
|
|
889
|
-
|
|
890
|
-
source_url: import_zod2.z.union([import_zod2.z.url(), import_zod2.z.literal("")]).optional()
|
|
906
|
+
var CfgAccountsProfileAvatarCreateRequestSchema = import_zod2.z.object({
|
|
907
|
+
avatar: import_zod2.z.union([import_zod2.z.instanceof(File), import_zod2.z.instanceof(Blob)])
|
|
891
908
|
});
|
|
892
909
|
|
|
893
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
910
|
+
// src/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeRequestRequest.schema.ts
|
|
894
911
|
var import_zod3 = require("zod");
|
|
895
|
-
var
|
|
896
|
-
|
|
897
|
-
|
|
912
|
+
var OAuthAuthorizeRequestRequestSchema = import_zod3.z.object({
|
|
913
|
+
redirect_uri: import_zod3.z.union([import_zod3.z.url(), import_zod3.z.literal("")]).optional(),
|
|
914
|
+
source_url: import_zod3.z.union([import_zod3.z.url(), import_zod3.z.literal("")]).optional()
|
|
898
915
|
});
|
|
899
916
|
|
|
900
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
917
|
+
// src/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeResponse.schema.ts
|
|
901
918
|
var import_zod4 = require("zod");
|
|
902
|
-
var
|
|
903
|
-
|
|
904
|
-
state: import_zod4.z.string()
|
|
905
|
-
redirect_uri: import_zod4.z.union([import_zod4.z.url(), import_zod4.z.literal("")]).optional()
|
|
919
|
+
var OAuthAuthorizeResponseSchema = import_zod4.z.object({
|
|
920
|
+
authorization_url: import_zod4.z.union([import_zod4.z.url(), import_zod4.z.literal("")]),
|
|
921
|
+
state: import_zod4.z.string()
|
|
906
922
|
});
|
|
907
923
|
|
|
908
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
924
|
+
// src/generated/cfg_accounts/_utils/schemas/OAuthCallbackRequestRequest.schema.ts
|
|
909
925
|
var import_zod5 = require("zod");
|
|
910
|
-
var
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
provider_username: import_zod5.z.string(),
|
|
915
|
-
provider_email: import_zod5.z.email(),
|
|
916
|
-
provider_avatar_url: import_zod5.z.union([import_zod5.z.url(), import_zod5.z.literal("")]),
|
|
917
|
-
connected_at: import_zod5.z.iso.datetime(),
|
|
918
|
-
last_login_at: import_zod5.z.iso.datetime()
|
|
926
|
+
var OAuthCallbackRequestRequestSchema = import_zod5.z.object({
|
|
927
|
+
code: import_zod5.z.string().min(10).max(500),
|
|
928
|
+
state: import_zod5.z.string().min(20).max(100),
|
|
929
|
+
redirect_uri: import_zod5.z.union([import_zod5.z.url(), import_zod5.z.literal("")]).optional()
|
|
919
930
|
});
|
|
920
931
|
|
|
921
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
932
|
+
// src/generated/cfg_accounts/_utils/schemas/OAuthConnection.schema.ts
|
|
922
933
|
var import_zod6 = require("zod");
|
|
923
|
-
var
|
|
924
|
-
|
|
934
|
+
var OAuthConnectionSchema = import_zod6.z.object({
|
|
935
|
+
id: import_zod6.z.int(),
|
|
936
|
+
provider: import_zod6.z.nativeEnum(OAuthConnectionProvider),
|
|
937
|
+
provider_display: import_zod6.z.string(),
|
|
938
|
+
provider_username: import_zod6.z.string(),
|
|
939
|
+
provider_email: import_zod6.z.email(),
|
|
940
|
+
provider_avatar_url: import_zod6.z.union([import_zod6.z.url(), import_zod6.z.literal("")]),
|
|
941
|
+
connected_at: import_zod6.z.iso.datetime(),
|
|
942
|
+
last_login_at: import_zod6.z.iso.datetime()
|
|
925
943
|
});
|
|
926
944
|
|
|
927
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
945
|
+
// src/generated/cfg_accounts/_utils/schemas/OAuthDisconnectRequestRequest.schema.ts
|
|
928
946
|
var import_zod7 = require("zod");
|
|
929
|
-
var
|
|
930
|
-
|
|
931
|
-
error_description: import_zod7.z.string().optional()
|
|
947
|
+
var OAuthDisconnectRequestRequestSchema = import_zod7.z.object({
|
|
948
|
+
provider: import_zod7.z.nativeEnum(OAuthDisconnectRequestRequestProvider)
|
|
932
949
|
});
|
|
933
950
|
|
|
934
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
951
|
+
// src/generated/cfg_accounts/_utils/schemas/OAuthError.schema.ts
|
|
935
952
|
var import_zod8 = require("zod");
|
|
936
|
-
var
|
|
937
|
-
|
|
953
|
+
var OAuthErrorSchema = import_zod8.z.object({
|
|
954
|
+
error: import_zod8.z.string(),
|
|
955
|
+
error_description: import_zod8.z.string().optional()
|
|
938
956
|
});
|
|
939
957
|
|
|
940
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
958
|
+
// src/generated/cfg_accounts/_utils/schemas/OAuthProvidersResponse.schema.ts
|
|
941
959
|
var import_zod9 = require("zod");
|
|
942
|
-
var
|
|
943
|
-
|
|
944
|
-
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(),
|
|
945
|
-
access: import_zod9.z.string().nullable().optional(),
|
|
946
|
-
refresh: import_zod9.z.string().nullable().optional(),
|
|
947
|
-
user: import_zod9.z.record(import_zod9.z.string(), import_zod9.z.any()).nullable().optional(),
|
|
948
|
-
is_new_user: import_zod9.z.boolean(),
|
|
949
|
-
is_new_connection: import_zod9.z.boolean(),
|
|
950
|
-
should_prompt_2fa: import_zod9.z.boolean().optional()
|
|
960
|
+
var OAuthProvidersResponseSchema = import_zod9.z.object({
|
|
961
|
+
providers: import_zod9.z.array(import_zod9.z.record(import_zod9.z.string(), import_zod9.z.any()))
|
|
951
962
|
});
|
|
952
963
|
|
|
953
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
964
|
+
// src/generated/cfg_accounts/_utils/schemas/OAuthTokenResponse.schema.ts
|
|
954
965
|
var import_zod10 = require("zod");
|
|
955
|
-
var
|
|
956
|
-
|
|
966
|
+
var OAuthTokenResponseSchema = import_zod10.z.object({
|
|
967
|
+
requires_2fa: import_zod10.z.boolean().optional(),
|
|
968
|
+
session_id: import_zod10.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(),
|
|
969
|
+
access: import_zod10.z.string().nullable().optional(),
|
|
970
|
+
refresh: import_zod10.z.string().nullable().optional(),
|
|
971
|
+
user: import_zod10.z.record(import_zod10.z.string(), import_zod10.z.any()).nullable().optional(),
|
|
972
|
+
is_new_user: import_zod10.z.boolean(),
|
|
973
|
+
is_new_connection: import_zod10.z.boolean(),
|
|
974
|
+
should_prompt_2fa: import_zod10.z.boolean().optional()
|
|
957
975
|
});
|
|
958
976
|
|
|
959
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
977
|
+
// src/generated/cfg_accounts/_utils/schemas/OTPErrorResponse.schema.ts
|
|
960
978
|
var import_zod11 = require("zod");
|
|
961
|
-
var
|
|
962
|
-
|
|
963
|
-
channel: import_zod11.z.nativeEnum(OTPRequestRequestChannel).optional(),
|
|
964
|
-
source_url: import_zod11.z.union([import_zod11.z.url(), import_zod11.z.literal("")]).optional()
|
|
979
|
+
var OTPErrorResponseSchema = import_zod11.z.object({
|
|
980
|
+
error: import_zod11.z.string()
|
|
965
981
|
});
|
|
966
982
|
|
|
967
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
983
|
+
// src/generated/cfg_accounts/_utils/schemas/OTPRequestRequest.schema.ts
|
|
968
984
|
var import_zod12 = require("zod");
|
|
969
|
-
var
|
|
970
|
-
|
|
985
|
+
var OTPRequestRequestSchema = import_zod12.z.object({
|
|
986
|
+
identifier: import_zod12.z.string().min(1),
|
|
987
|
+
channel: import_zod12.z.nativeEnum(OTPRequestRequestChannel).optional(),
|
|
988
|
+
source_url: import_zod12.z.union([import_zod12.z.url(), import_zod12.z.literal("")]).optional()
|
|
971
989
|
});
|
|
972
990
|
|
|
973
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
991
|
+
// src/generated/cfg_accounts/_utils/schemas/OTPRequestResponse.schema.ts
|
|
974
992
|
var import_zod13 = require("zod");
|
|
975
|
-
var
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
993
|
+
var OTPRequestResponseSchema = import_zod13.z.object({
|
|
994
|
+
message: import_zod13.z.string()
|
|
995
|
+
});
|
|
996
|
+
|
|
997
|
+
// src/generated/cfg_accounts/_utils/schemas/OTPVerifyRequest.schema.ts
|
|
998
|
+
var import_zod14 = require("zod");
|
|
999
|
+
var OTPVerifyRequestSchema = import_zod14.z.object({
|
|
1000
|
+
identifier: import_zod14.z.string().min(1),
|
|
1001
|
+
otp: import_zod14.z.string().min(6).max(6),
|
|
1002
|
+
channel: import_zod14.z.nativeEnum(OTPVerifyRequestChannel).optional(),
|
|
1003
|
+
source_url: import_zod14.z.union([import_zod14.z.url(), import_zod14.z.literal("")]).optional()
|
|
980
1004
|
});
|
|
981
1005
|
|
|
982
1006
|
// src/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts
|
|
983
|
-
var
|
|
1007
|
+
var import_zod16 = require("zod");
|
|
984
1008
|
|
|
985
1009
|
// src/generated/cfg_accounts/_utils/schemas/User.schema.ts
|
|
986
|
-
var
|
|
987
|
-
var UserSchema =
|
|
988
|
-
id:
|
|
989
|
-
email:
|
|
990
|
-
first_name:
|
|
991
|
-
last_name:
|
|
992
|
-
full_name:
|
|
993
|
-
initials:
|
|
994
|
-
display_username:
|
|
995
|
-
company:
|
|
996
|
-
phone:
|
|
997
|
-
position:
|
|
998
|
-
avatar:
|
|
999
|
-
is_staff:
|
|
1000
|
-
is_superuser:
|
|
1001
|
-
date_joined:
|
|
1002
|
-
last_login:
|
|
1003
|
-
unanswered_messages_count:
|
|
1010
|
+
var import_zod15 = require("zod");
|
|
1011
|
+
var UserSchema = import_zod15.z.object({
|
|
1012
|
+
id: import_zod15.z.int(),
|
|
1013
|
+
email: import_zod15.z.email(),
|
|
1014
|
+
first_name: import_zod15.z.string().max(50).optional(),
|
|
1015
|
+
last_name: import_zod15.z.string().max(50).optional(),
|
|
1016
|
+
full_name: import_zod15.z.string(),
|
|
1017
|
+
initials: import_zod15.z.string(),
|
|
1018
|
+
display_username: import_zod15.z.string(),
|
|
1019
|
+
company: import_zod15.z.string().max(100).optional(),
|
|
1020
|
+
phone: import_zod15.z.string().max(20).optional(),
|
|
1021
|
+
position: import_zod15.z.string().max(100).optional(),
|
|
1022
|
+
avatar: import_zod15.z.union([import_zod15.z.url(), import_zod15.z.literal("")]).nullable(),
|
|
1023
|
+
is_staff: import_zod15.z.boolean(),
|
|
1024
|
+
is_superuser: import_zod15.z.boolean(),
|
|
1025
|
+
date_joined: import_zod15.z.iso.datetime(),
|
|
1026
|
+
last_login: import_zod15.z.iso.datetime().nullable(),
|
|
1027
|
+
unanswered_messages_count: import_zod15.z.int(),
|
|
1004
1028
|
centrifugo: CentrifugoTokenSchema.nullable()
|
|
1005
1029
|
});
|
|
1006
1030
|
|
|
1007
1031
|
// src/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts
|
|
1008
|
-
var OTPVerifyResponseSchema =
|
|
1009
|
-
requires_2fa:
|
|
1010
|
-
session_id:
|
|
1011
|
-
refresh:
|
|
1012
|
-
access:
|
|
1032
|
+
var OTPVerifyResponseSchema = import_zod16.z.object({
|
|
1033
|
+
requires_2fa: import_zod16.z.boolean().optional(),
|
|
1034
|
+
session_id: import_zod16.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(),
|
|
1035
|
+
refresh: import_zod16.z.string().nullable().optional(),
|
|
1036
|
+
access: import_zod16.z.string().nullable().optional(),
|
|
1013
1037
|
user: UserSchema.nullable().optional(),
|
|
1014
|
-
should_prompt_2fa:
|
|
1038
|
+
should_prompt_2fa: import_zod16.z.boolean().optional()
|
|
1015
1039
|
});
|
|
1016
1040
|
|
|
1017
1041
|
// src/generated/cfg_accounts/_utils/schemas/PatchedUserProfileUpdateRequest.schema.ts
|
|
1018
|
-
var
|
|
1019
|
-
var PatchedUserProfileUpdateRequestSchema =
|
|
1020
|
-
first_name:
|
|
1021
|
-
last_name:
|
|
1022
|
-
company:
|
|
1023
|
-
phone:
|
|
1024
|
-
position:
|
|
1042
|
+
var import_zod17 = require("zod");
|
|
1043
|
+
var PatchedUserProfileUpdateRequestSchema = import_zod17.z.object({
|
|
1044
|
+
first_name: import_zod17.z.string().max(50).optional(),
|
|
1045
|
+
last_name: import_zod17.z.string().max(50).optional(),
|
|
1046
|
+
company: import_zod17.z.string().max(100).optional(),
|
|
1047
|
+
phone: import_zod17.z.string().max(20).optional(),
|
|
1048
|
+
position: import_zod17.z.string().max(100).optional()
|
|
1025
1049
|
});
|
|
1026
1050
|
|
|
1027
1051
|
// src/generated/cfg_accounts/_utils/schemas/TokenRefresh.schema.ts
|
|
1028
|
-
var
|
|
1029
|
-
var TokenRefreshSchema =
|
|
1030
|
-
access:
|
|
1031
|
-
refresh:
|
|
1052
|
+
var import_zod18 = require("zod");
|
|
1053
|
+
var TokenRefreshSchema = import_zod18.z.object({
|
|
1054
|
+
access: import_zod18.z.string(),
|
|
1055
|
+
refresh: import_zod18.z.string()
|
|
1032
1056
|
});
|
|
1033
1057
|
|
|
1034
1058
|
// src/generated/cfg_accounts/_utils/schemas/TokenRefreshRequest.schema.ts
|
|
1035
|
-
var
|
|
1036
|
-
var TokenRefreshRequestSchema =
|
|
1037
|
-
refresh:
|
|
1059
|
+
var import_zod19 = require("zod");
|
|
1060
|
+
var TokenRefreshRequestSchema = import_zod19.z.object({
|
|
1061
|
+
refresh: import_zod19.z.string().min(1)
|
|
1038
1062
|
});
|
|
1039
1063
|
|
|
1040
1064
|
// src/generated/cfg_accounts/_utils/schemas/UserProfileUpdateRequest.schema.ts
|
|
1041
|
-
var
|
|
1042
|
-
var UserProfileUpdateRequestSchema =
|
|
1043
|
-
first_name:
|
|
1044
|
-
last_name:
|
|
1045
|
-
company:
|
|
1046
|
-
phone:
|
|
1047
|
-
position:
|
|
1065
|
+
var import_zod20 = require("zod");
|
|
1066
|
+
var UserProfileUpdateRequestSchema = import_zod20.z.object({
|
|
1067
|
+
first_name: import_zod20.z.string().max(50).optional(),
|
|
1068
|
+
last_name: import_zod20.z.string().max(50).optional(),
|
|
1069
|
+
company: import_zod20.z.string().max(100).optional(),
|
|
1070
|
+
phone: import_zod20.z.string().max(20).optional(),
|
|
1071
|
+
position: import_zod20.z.string().max(100).optional()
|
|
1048
1072
|
});
|
|
1049
1073
|
|
|
1050
1074
|
// src/generated/cfg_accounts/_utils/fetchers/accounts.ts
|
|
@@ -1401,7 +1425,8 @@ var API = class {
|
|
|
1401
1425
|
this._loadTokensFromStorage();
|
|
1402
1426
|
this._client = new APIClient(this.baseUrl, {
|
|
1403
1427
|
retryConfig: this.options?.retryConfig,
|
|
1404
|
-
loggerConfig: this.options?.loggerConfig
|
|
1428
|
+
loggerConfig: this.options?.loggerConfig,
|
|
1429
|
+
tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
|
|
1405
1430
|
});
|
|
1406
1431
|
this._injectAuthHeader();
|
|
1407
1432
|
this.auth = this._client.auth;
|
|
@@ -1419,7 +1444,8 @@ var API = class {
|
|
|
1419
1444
|
_reinitClients() {
|
|
1420
1445
|
this._client = new APIClient(this.baseUrl, {
|
|
1421
1446
|
retryConfig: this.options?.retryConfig,
|
|
1422
|
-
loggerConfig: this.options?.loggerConfig
|
|
1447
|
+
loggerConfig: this.options?.loggerConfig,
|
|
1448
|
+
tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
|
|
1423
1449
|
});
|
|
1424
1450
|
this._injectAuthHeader();
|
|
1425
1451
|
this.auth = this._client.auth;
|
|
@@ -2090,8 +2116,10 @@ var APIClient2 = class {
|
|
|
2090
2116
|
constructor(baseUrl, options) {
|
|
2091
2117
|
this.logger = null;
|
|
2092
2118
|
this.retryConfig = null;
|
|
2119
|
+
this.tokenGetter = null;
|
|
2093
2120
|
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
2094
2121
|
this.httpClient = options?.httpClient || new FetchAdapter2();
|
|
2122
|
+
this.tokenGetter = options?.tokenGetter || null;
|
|
2095
2123
|
if (options?.loggerConfig !== void 0) {
|
|
2096
2124
|
this.logger = new APILogger2(options.loggerConfig);
|
|
2097
2125
|
}
|
|
@@ -2120,6 +2148,19 @@ var APIClient2 = class {
|
|
|
2120
2148
|
}
|
|
2121
2149
|
return null;
|
|
2122
2150
|
}
|
|
2151
|
+
/**
|
|
2152
|
+
* Get the base URL for building streaming/download URLs.
|
|
2153
|
+
*/
|
|
2154
|
+
getBaseUrl() {
|
|
2155
|
+
return this.baseUrl;
|
|
2156
|
+
}
|
|
2157
|
+
/**
|
|
2158
|
+
* Get JWT token for URL authentication (used in streaming endpoints).
|
|
2159
|
+
* Returns null if no token getter is configured or no token is available.
|
|
2160
|
+
*/
|
|
2161
|
+
getToken() {
|
|
2162
|
+
return this.tokenGetter ? this.tokenGetter() : null;
|
|
2163
|
+
}
|
|
2123
2164
|
/**
|
|
2124
2165
|
* Make HTTP request with Django CSRF and session handling.
|
|
2125
2166
|
* Automatically retries on network errors and 5xx server errors.
|
|
@@ -2332,320 +2373,320 @@ var LocalStorageAdapter2 = class {
|
|
|
2332
2373
|
};
|
|
2333
2374
|
|
|
2334
2375
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoChannelInfo.schema.ts
|
|
2335
|
-
var
|
|
2336
|
-
var CentrifugoChannelInfoSchema =
|
|
2337
|
-
num_clients:
|
|
2376
|
+
var import_zod21 = require("zod");
|
|
2377
|
+
var CentrifugoChannelInfoSchema = import_zod21.z.object({
|
|
2378
|
+
num_clients: import_zod21.z.int()
|
|
2338
2379
|
});
|
|
2339
2380
|
|
|
2340
2381
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoChannelsRequestRequest.schema.ts
|
|
2341
|
-
var
|
|
2342
|
-
var CentrifugoChannelsRequestRequestSchema =
|
|
2343
|
-
pattern:
|
|
2382
|
+
var import_zod22 = require("zod");
|
|
2383
|
+
var CentrifugoChannelsRequestRequestSchema = import_zod22.z.object({
|
|
2384
|
+
pattern: import_zod22.z.string().nullable().optional()
|
|
2344
2385
|
});
|
|
2345
2386
|
|
|
2346
2387
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoChannelsResponse.schema.ts
|
|
2347
|
-
var
|
|
2388
|
+
var import_zod25 = require("zod");
|
|
2348
2389
|
|
|
2349
2390
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoChannelsResult.schema.ts
|
|
2350
|
-
var
|
|
2351
|
-
var CentrifugoChannelsResultSchema =
|
|
2352
|
-
channels:
|
|
2391
|
+
var import_zod23 = require("zod");
|
|
2392
|
+
var CentrifugoChannelsResultSchema = import_zod23.z.object({
|
|
2393
|
+
channels: import_zod23.z.record(import_zod23.z.string(), CentrifugoChannelInfoSchema)
|
|
2353
2394
|
});
|
|
2354
2395
|
|
|
2355
2396
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoError.schema.ts
|
|
2356
|
-
var
|
|
2357
|
-
var CentrifugoErrorSchema =
|
|
2358
|
-
code:
|
|
2359
|
-
message:
|
|
2397
|
+
var import_zod24 = require("zod");
|
|
2398
|
+
var CentrifugoErrorSchema = import_zod24.z.object({
|
|
2399
|
+
code: import_zod24.z.int().optional(),
|
|
2400
|
+
message: import_zod24.z.string().optional()
|
|
2360
2401
|
});
|
|
2361
2402
|
|
|
2362
2403
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoChannelsResponse.schema.ts
|
|
2363
|
-
var CentrifugoChannelsResponseSchema =
|
|
2404
|
+
var CentrifugoChannelsResponseSchema = import_zod25.z.object({
|
|
2364
2405
|
error: CentrifugoErrorSchema.optional(),
|
|
2365
2406
|
result: CentrifugoChannelsResultSchema.optional()
|
|
2366
2407
|
});
|
|
2367
2408
|
|
|
2368
2409
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoClientInfo.schema.ts
|
|
2369
|
-
var
|
|
2370
|
-
var CentrifugoClientInfoSchema =
|
|
2371
|
-
user:
|
|
2372
|
-
client:
|
|
2373
|
-
conn_info:
|
|
2374
|
-
chan_info:
|
|
2410
|
+
var import_zod26 = require("zod");
|
|
2411
|
+
var CentrifugoClientInfoSchema = import_zod26.z.object({
|
|
2412
|
+
user: import_zod26.z.string(),
|
|
2413
|
+
client: import_zod26.z.string(),
|
|
2414
|
+
conn_info: import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any()).nullable().optional(),
|
|
2415
|
+
chan_info: import_zod26.z.record(import_zod26.z.string(), import_zod26.z.any()).nullable().optional()
|
|
2375
2416
|
});
|
|
2376
2417
|
|
|
2377
2418
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoHealthCheck.schema.ts
|
|
2378
|
-
var
|
|
2379
|
-
var CentrifugoHealthCheckSchema =
|
|
2380
|
-
status:
|
|
2381
|
-
wrapper_url:
|
|
2382
|
-
has_api_key:
|
|
2383
|
-
timestamp:
|
|
2419
|
+
var import_zod27 = require("zod");
|
|
2420
|
+
var CentrifugoHealthCheckSchema = import_zod27.z.object({
|
|
2421
|
+
status: import_zod27.z.string(),
|
|
2422
|
+
wrapper_url: import_zod27.z.string(),
|
|
2423
|
+
has_api_key: import_zod27.z.boolean(),
|
|
2424
|
+
timestamp: import_zod27.z.string()
|
|
2384
2425
|
});
|
|
2385
2426
|
|
|
2386
2427
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoHistoryRequestRequest.schema.ts
|
|
2387
|
-
var
|
|
2428
|
+
var import_zod29 = require("zod");
|
|
2388
2429
|
|
|
2389
2430
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoStreamPosition.schema.ts
|
|
2390
|
-
var
|
|
2391
|
-
var CentrifugoStreamPositionSchema =
|
|
2392
|
-
offset:
|
|
2393
|
-
epoch:
|
|
2431
|
+
var import_zod28 = require("zod");
|
|
2432
|
+
var CentrifugoStreamPositionSchema = import_zod28.z.object({
|
|
2433
|
+
offset: import_zod28.z.int(),
|
|
2434
|
+
epoch: import_zod28.z.string()
|
|
2394
2435
|
});
|
|
2395
2436
|
|
|
2396
2437
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoHistoryRequestRequest.schema.ts
|
|
2397
|
-
var CentrifugoHistoryRequestRequestSchema =
|
|
2398
|
-
channel:
|
|
2399
|
-
limit:
|
|
2438
|
+
var CentrifugoHistoryRequestRequestSchema = import_zod29.z.object({
|
|
2439
|
+
channel: import_zod29.z.string(),
|
|
2440
|
+
limit: import_zod29.z.int().nullable().optional(),
|
|
2400
2441
|
since: CentrifugoStreamPositionSchema.optional(),
|
|
2401
|
-
reverse:
|
|
2442
|
+
reverse: import_zod29.z.boolean().nullable().optional()
|
|
2402
2443
|
});
|
|
2403
2444
|
|
|
2404
2445
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoHistoryResponse.schema.ts
|
|
2405
|
-
var
|
|
2446
|
+
var import_zod32 = require("zod");
|
|
2406
2447
|
|
|
2407
2448
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoHistoryResult.schema.ts
|
|
2408
|
-
var
|
|
2449
|
+
var import_zod31 = require("zod");
|
|
2409
2450
|
|
|
2410
2451
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoPublication.schema.ts
|
|
2411
|
-
var
|
|
2412
|
-
var CentrifugoPublicationSchema =
|
|
2413
|
-
data:
|
|
2452
|
+
var import_zod30 = require("zod");
|
|
2453
|
+
var CentrifugoPublicationSchema = import_zod30.z.object({
|
|
2454
|
+
data: import_zod30.z.record(import_zod30.z.string(), import_zod30.z.any()),
|
|
2414
2455
|
info: CentrifugoClientInfoSchema.optional(),
|
|
2415
|
-
offset:
|
|
2416
|
-
tags:
|
|
2456
|
+
offset: import_zod30.z.int(),
|
|
2457
|
+
tags: import_zod30.z.record(import_zod30.z.string(), import_zod30.z.any()).nullable().optional()
|
|
2417
2458
|
});
|
|
2418
2459
|
|
|
2419
2460
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoHistoryResult.schema.ts
|
|
2420
|
-
var CentrifugoHistoryResultSchema =
|
|
2421
|
-
publications:
|
|
2422
|
-
epoch:
|
|
2423
|
-
offset:
|
|
2461
|
+
var CentrifugoHistoryResultSchema = import_zod31.z.object({
|
|
2462
|
+
publications: import_zod31.z.array(CentrifugoPublicationSchema),
|
|
2463
|
+
epoch: import_zod31.z.string(),
|
|
2464
|
+
offset: import_zod31.z.int()
|
|
2424
2465
|
});
|
|
2425
2466
|
|
|
2426
2467
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoHistoryResponse.schema.ts
|
|
2427
|
-
var CentrifugoHistoryResponseSchema =
|
|
2468
|
+
var CentrifugoHistoryResponseSchema = import_zod32.z.object({
|
|
2428
2469
|
error: CentrifugoErrorSchema.optional(),
|
|
2429
2470
|
result: CentrifugoHistoryResultSchema.optional()
|
|
2430
2471
|
});
|
|
2431
2472
|
|
|
2432
2473
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoInfoResponse.schema.ts
|
|
2433
|
-
var
|
|
2474
|
+
var import_zod37 = require("zod");
|
|
2434
2475
|
|
|
2435
2476
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoInfoResult.schema.ts
|
|
2436
|
-
var
|
|
2477
|
+
var import_zod36 = require("zod");
|
|
2437
2478
|
|
|
2438
2479
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoNodeInfo.schema.ts
|
|
2439
|
-
var
|
|
2480
|
+
var import_zod35 = require("zod");
|
|
2440
2481
|
|
|
2441
2482
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoMetrics.schema.ts
|
|
2442
|
-
var
|
|
2443
|
-
var CentrifugoMetricsSchema =
|
|
2444
|
-
interval:
|
|
2445
|
-
items:
|
|
2483
|
+
var import_zod33 = require("zod");
|
|
2484
|
+
var CentrifugoMetricsSchema = import_zod33.z.object({
|
|
2485
|
+
interval: import_zod33.z.number(),
|
|
2486
|
+
items: import_zod33.z.record(import_zod33.z.string(), import_zod33.z.number())
|
|
2446
2487
|
});
|
|
2447
2488
|
|
|
2448
2489
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoProcess.schema.ts
|
|
2449
|
-
var
|
|
2450
|
-
var CentrifugoProcessSchema =
|
|
2451
|
-
cpu:
|
|
2452
|
-
rss:
|
|
2490
|
+
var import_zod34 = require("zod");
|
|
2491
|
+
var CentrifugoProcessSchema = import_zod34.z.object({
|
|
2492
|
+
cpu: import_zod34.z.number(),
|
|
2493
|
+
rss: import_zod34.z.int()
|
|
2453
2494
|
});
|
|
2454
2495
|
|
|
2455
2496
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoNodeInfo.schema.ts
|
|
2456
|
-
var CentrifugoNodeInfoSchema =
|
|
2457
|
-
uid:
|
|
2458
|
-
name:
|
|
2459
|
-
version:
|
|
2460
|
-
num_clients:
|
|
2461
|
-
num_users:
|
|
2462
|
-
num_channels:
|
|
2463
|
-
uptime:
|
|
2464
|
-
num_subs:
|
|
2497
|
+
var CentrifugoNodeInfoSchema = import_zod35.z.object({
|
|
2498
|
+
uid: import_zod35.z.string(),
|
|
2499
|
+
name: import_zod35.z.string(),
|
|
2500
|
+
version: import_zod35.z.string(),
|
|
2501
|
+
num_clients: import_zod35.z.int(),
|
|
2502
|
+
num_users: import_zod35.z.int(),
|
|
2503
|
+
num_channels: import_zod35.z.int(),
|
|
2504
|
+
uptime: import_zod35.z.int(),
|
|
2505
|
+
num_subs: import_zod35.z.int(),
|
|
2465
2506
|
metrics: CentrifugoMetricsSchema.optional(),
|
|
2466
2507
|
process: CentrifugoProcessSchema.optional()
|
|
2467
2508
|
});
|
|
2468
2509
|
|
|
2469
2510
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoInfoResult.schema.ts
|
|
2470
|
-
var CentrifugoInfoResultSchema =
|
|
2471
|
-
nodes:
|
|
2511
|
+
var CentrifugoInfoResultSchema = import_zod36.z.object({
|
|
2512
|
+
nodes: import_zod36.z.array(CentrifugoNodeInfoSchema)
|
|
2472
2513
|
});
|
|
2473
2514
|
|
|
2474
2515
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoInfoResponse.schema.ts
|
|
2475
|
-
var CentrifugoInfoResponseSchema =
|
|
2516
|
+
var CentrifugoInfoResponseSchema = import_zod37.z.object({
|
|
2476
2517
|
error: CentrifugoErrorSchema.optional(),
|
|
2477
2518
|
result: CentrifugoInfoResultSchema.optional()
|
|
2478
2519
|
});
|
|
2479
2520
|
|
|
2480
2521
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoOverviewStats.schema.ts
|
|
2481
|
-
var
|
|
2482
|
-
var CentrifugoOverviewStatsSchema =
|
|
2483
|
-
total:
|
|
2484
|
-
successful:
|
|
2485
|
-
failed:
|
|
2486
|
-
timeout:
|
|
2487
|
-
success_rate:
|
|
2488
|
-
avg_duration_ms:
|
|
2489
|
-
avg_acks_received:
|
|
2490
|
-
period_hours:
|
|
2522
|
+
var import_zod38 = require("zod");
|
|
2523
|
+
var CentrifugoOverviewStatsSchema = import_zod38.z.object({
|
|
2524
|
+
total: import_zod38.z.int(),
|
|
2525
|
+
successful: import_zod38.z.int(),
|
|
2526
|
+
failed: import_zod38.z.int(),
|
|
2527
|
+
timeout: import_zod38.z.int(),
|
|
2528
|
+
success_rate: import_zod38.z.number(),
|
|
2529
|
+
avg_duration_ms: import_zod38.z.number(),
|
|
2530
|
+
avg_acks_received: import_zod38.z.number(),
|
|
2531
|
+
period_hours: import_zod38.z.int()
|
|
2491
2532
|
});
|
|
2492
2533
|
|
|
2493
2534
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoPresenceRequestRequest.schema.ts
|
|
2494
|
-
var
|
|
2495
|
-
var CentrifugoPresenceRequestRequestSchema =
|
|
2496
|
-
channel:
|
|
2535
|
+
var import_zod39 = require("zod");
|
|
2536
|
+
var CentrifugoPresenceRequestRequestSchema = import_zod39.z.object({
|
|
2537
|
+
channel: import_zod39.z.string()
|
|
2497
2538
|
});
|
|
2498
2539
|
|
|
2499
2540
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoPresenceResponse.schema.ts
|
|
2500
|
-
var
|
|
2541
|
+
var import_zod41 = require("zod");
|
|
2501
2542
|
|
|
2502
2543
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoPresenceResult.schema.ts
|
|
2503
|
-
var
|
|
2504
|
-
var CentrifugoPresenceResultSchema =
|
|
2505
|
-
presence:
|
|
2544
|
+
var import_zod40 = require("zod");
|
|
2545
|
+
var CentrifugoPresenceResultSchema = import_zod40.z.object({
|
|
2546
|
+
presence: import_zod40.z.record(import_zod40.z.string(), CentrifugoClientInfoSchema)
|
|
2506
2547
|
});
|
|
2507
2548
|
|
|
2508
2549
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoPresenceResponse.schema.ts
|
|
2509
|
-
var CentrifugoPresenceResponseSchema =
|
|
2550
|
+
var CentrifugoPresenceResponseSchema = import_zod41.z.object({
|
|
2510
2551
|
error: CentrifugoErrorSchema.optional(),
|
|
2511
2552
|
result: CentrifugoPresenceResultSchema.optional()
|
|
2512
2553
|
});
|
|
2513
2554
|
|
|
2514
2555
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoPresenceStatsRequestRequest.schema.ts
|
|
2515
|
-
var
|
|
2516
|
-
var CentrifugoPresenceStatsRequestRequestSchema =
|
|
2517
|
-
channel:
|
|
2556
|
+
var import_zod42 = require("zod");
|
|
2557
|
+
var CentrifugoPresenceStatsRequestRequestSchema = import_zod42.z.object({
|
|
2558
|
+
channel: import_zod42.z.string()
|
|
2518
2559
|
});
|
|
2519
2560
|
|
|
2520
2561
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoPresenceStatsResponse.schema.ts
|
|
2521
|
-
var
|
|
2562
|
+
var import_zod44 = require("zod");
|
|
2522
2563
|
|
|
2523
2564
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoPresenceStatsResult.schema.ts
|
|
2524
|
-
var
|
|
2525
|
-
var CentrifugoPresenceStatsResultSchema =
|
|
2526
|
-
num_clients:
|
|
2527
|
-
num_users:
|
|
2565
|
+
var import_zod43 = require("zod");
|
|
2566
|
+
var CentrifugoPresenceStatsResultSchema = import_zod43.z.object({
|
|
2567
|
+
num_clients: import_zod43.z.int(),
|
|
2568
|
+
num_users: import_zod43.z.int()
|
|
2528
2569
|
});
|
|
2529
2570
|
|
|
2530
2571
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoPresenceStatsResponse.schema.ts
|
|
2531
|
-
var CentrifugoPresenceStatsResponseSchema =
|
|
2572
|
+
var CentrifugoPresenceStatsResponseSchema = import_zod44.z.object({
|
|
2532
2573
|
error: CentrifugoErrorSchema.optional(),
|
|
2533
2574
|
result: CentrifugoPresenceStatsResultSchema.optional()
|
|
2534
2575
|
});
|
|
2535
2576
|
|
|
2536
2577
|
// src/generated/cfg_centrifugo/_utils/schemas/ChannelList.schema.ts
|
|
2537
|
-
var
|
|
2578
|
+
var import_zod46 = require("zod");
|
|
2538
2579
|
|
|
2539
2580
|
// src/generated/cfg_centrifugo/_utils/schemas/ChannelStats.schema.ts
|
|
2540
|
-
var
|
|
2541
|
-
var ChannelStatsSchema =
|
|
2542
|
-
channel:
|
|
2543
|
-
total:
|
|
2544
|
-
successful:
|
|
2545
|
-
failed:
|
|
2546
|
-
avg_duration_ms:
|
|
2547
|
-
avg_acks:
|
|
2548
|
-
last_activity_at:
|
|
2581
|
+
var import_zod45 = require("zod");
|
|
2582
|
+
var ChannelStatsSchema = import_zod45.z.object({
|
|
2583
|
+
channel: import_zod45.z.string(),
|
|
2584
|
+
total: import_zod45.z.int(),
|
|
2585
|
+
successful: import_zod45.z.int(),
|
|
2586
|
+
failed: import_zod45.z.int(),
|
|
2587
|
+
avg_duration_ms: import_zod45.z.number(),
|
|
2588
|
+
avg_acks: import_zod45.z.number(),
|
|
2589
|
+
last_activity_at: import_zod45.z.string().nullable()
|
|
2549
2590
|
});
|
|
2550
2591
|
|
|
2551
2592
|
// src/generated/cfg_centrifugo/_utils/schemas/ChannelList.schema.ts
|
|
2552
|
-
var ChannelListSchema =
|
|
2553
|
-
channels:
|
|
2554
|
-
total_channels:
|
|
2593
|
+
var ChannelListSchema = import_zod46.z.object({
|
|
2594
|
+
channels: import_zod46.z.array(ChannelStatsSchema),
|
|
2595
|
+
total_channels: import_zod46.z.int()
|
|
2555
2596
|
});
|
|
2556
2597
|
|
|
2557
2598
|
// src/generated/cfg_centrifugo/_utils/schemas/ConnectionTokenResponse.schema.ts
|
|
2558
|
-
var
|
|
2559
|
-
var ConnectionTokenResponseSchema =
|
|
2560
|
-
token:
|
|
2561
|
-
centrifugo_url:
|
|
2562
|
-
expires_at:
|
|
2563
|
-
channels:
|
|
2599
|
+
var import_zod47 = require("zod");
|
|
2600
|
+
var ConnectionTokenResponseSchema = import_zod47.z.object({
|
|
2601
|
+
token: import_zod47.z.string(),
|
|
2602
|
+
centrifugo_url: import_zod47.z.string(),
|
|
2603
|
+
expires_at: import_zod47.z.string(),
|
|
2604
|
+
channels: import_zod47.z.array(import_zod47.z.string())
|
|
2564
2605
|
});
|
|
2565
2606
|
|
|
2566
2607
|
// src/generated/cfg_centrifugo/_utils/schemas/ManualAckRequestRequest.schema.ts
|
|
2567
|
-
var
|
|
2568
|
-
var ManualAckRequestRequestSchema =
|
|
2569
|
-
message_id:
|
|
2570
|
-
client_id:
|
|
2608
|
+
var import_zod48 = require("zod");
|
|
2609
|
+
var ManualAckRequestRequestSchema = import_zod48.z.object({
|
|
2610
|
+
message_id: import_zod48.z.string(),
|
|
2611
|
+
client_id: import_zod48.z.string()
|
|
2571
2612
|
});
|
|
2572
2613
|
|
|
2573
2614
|
// src/generated/cfg_centrifugo/_utils/schemas/ManualAckResponse.schema.ts
|
|
2574
|
-
var
|
|
2575
|
-
var ManualAckResponseSchema =
|
|
2576
|
-
success:
|
|
2577
|
-
message_id:
|
|
2578
|
-
error:
|
|
2615
|
+
var import_zod49 = require("zod");
|
|
2616
|
+
var ManualAckResponseSchema = import_zod49.z.object({
|
|
2617
|
+
success: import_zod49.z.boolean(),
|
|
2618
|
+
message_id: import_zod49.z.string(),
|
|
2619
|
+
error: import_zod49.z.string().nullable().optional()
|
|
2579
2620
|
});
|
|
2580
2621
|
|
|
2581
2622
|
// src/generated/cfg_centrifugo/_utils/schemas/PaginatedPublishList.schema.ts
|
|
2582
|
-
var
|
|
2623
|
+
var import_zod51 = require("zod");
|
|
2583
2624
|
|
|
2584
2625
|
// src/generated/cfg_centrifugo/_utils/schemas/Publish.schema.ts
|
|
2585
|
-
var
|
|
2586
|
-
var PublishSchema =
|
|
2587
|
-
message_id:
|
|
2588
|
-
channel:
|
|
2589
|
-
status:
|
|
2590
|
-
wait_for_ack:
|
|
2591
|
-
acks_received:
|
|
2592
|
-
acks_expected:
|
|
2593
|
-
duration_ms:
|
|
2594
|
-
created_at:
|
|
2595
|
-
completed_at:
|
|
2596
|
-
error_code:
|
|
2597
|
-
error_message:
|
|
2626
|
+
var import_zod50 = require("zod");
|
|
2627
|
+
var PublishSchema = import_zod50.z.object({
|
|
2628
|
+
message_id: import_zod50.z.string(),
|
|
2629
|
+
channel: import_zod50.z.string(),
|
|
2630
|
+
status: import_zod50.z.string(),
|
|
2631
|
+
wait_for_ack: import_zod50.z.boolean(),
|
|
2632
|
+
acks_received: import_zod50.z.int(),
|
|
2633
|
+
acks_expected: import_zod50.z.int().nullable(),
|
|
2634
|
+
duration_ms: import_zod50.z.number().nullable(),
|
|
2635
|
+
created_at: import_zod50.z.iso.datetime(),
|
|
2636
|
+
completed_at: import_zod50.z.iso.datetime().nullable(),
|
|
2637
|
+
error_code: import_zod50.z.string().nullable(),
|
|
2638
|
+
error_message: import_zod50.z.string().nullable()
|
|
2598
2639
|
});
|
|
2599
2640
|
|
|
2600
2641
|
// src/generated/cfg_centrifugo/_utils/schemas/PaginatedPublishList.schema.ts
|
|
2601
|
-
var PaginatedPublishListSchema =
|
|
2602
|
-
count:
|
|
2603
|
-
page:
|
|
2604
|
-
pages:
|
|
2605
|
-
page_size:
|
|
2606
|
-
has_next:
|
|
2607
|
-
has_previous:
|
|
2608
|
-
next_page:
|
|
2609
|
-
previous_page:
|
|
2610
|
-
results:
|
|
2642
|
+
var PaginatedPublishListSchema = import_zod51.z.object({
|
|
2643
|
+
count: import_zod51.z.int(),
|
|
2644
|
+
page: import_zod51.z.int(),
|
|
2645
|
+
pages: import_zod51.z.int(),
|
|
2646
|
+
page_size: import_zod51.z.int(),
|
|
2647
|
+
has_next: import_zod51.z.boolean(),
|
|
2648
|
+
has_previous: import_zod51.z.boolean(),
|
|
2649
|
+
next_page: import_zod51.z.int().nullable().optional(),
|
|
2650
|
+
previous_page: import_zod51.z.int().nullable().optional(),
|
|
2651
|
+
results: import_zod51.z.array(PublishSchema)
|
|
2611
2652
|
});
|
|
2612
2653
|
|
|
2613
2654
|
// src/generated/cfg_centrifugo/_utils/schemas/PublishTestRequestRequest.schema.ts
|
|
2614
|
-
var
|
|
2615
|
-
var PublishTestRequestRequestSchema =
|
|
2616
|
-
channel:
|
|
2617
|
-
data:
|
|
2618
|
-
wait_for_ack:
|
|
2619
|
-
ack_timeout:
|
|
2655
|
+
var import_zod52 = require("zod");
|
|
2656
|
+
var PublishTestRequestRequestSchema = import_zod52.z.object({
|
|
2657
|
+
channel: import_zod52.z.string(),
|
|
2658
|
+
data: import_zod52.z.record(import_zod52.z.string(), import_zod52.z.any()),
|
|
2659
|
+
wait_for_ack: import_zod52.z.boolean().optional(),
|
|
2660
|
+
ack_timeout: import_zod52.z.int().min(1).max(60).optional()
|
|
2620
2661
|
});
|
|
2621
2662
|
|
|
2622
2663
|
// src/generated/cfg_centrifugo/_utils/schemas/PublishTestResponse.schema.ts
|
|
2623
|
-
var
|
|
2624
|
-
var PublishTestResponseSchema =
|
|
2625
|
-
success:
|
|
2626
|
-
message_id:
|
|
2627
|
-
channel:
|
|
2628
|
-
acks_received:
|
|
2629
|
-
delivered:
|
|
2630
|
-
error:
|
|
2664
|
+
var import_zod53 = require("zod");
|
|
2665
|
+
var PublishTestResponseSchema = import_zod53.z.object({
|
|
2666
|
+
success: import_zod53.z.boolean(),
|
|
2667
|
+
message_id: import_zod53.z.string(),
|
|
2668
|
+
channel: import_zod53.z.string(),
|
|
2669
|
+
acks_received: import_zod53.z.int().optional(),
|
|
2670
|
+
delivered: import_zod53.z.boolean().optional(),
|
|
2671
|
+
error: import_zod53.z.string().nullable().optional()
|
|
2631
2672
|
});
|
|
2632
2673
|
|
|
2633
2674
|
// src/generated/cfg_centrifugo/_utils/schemas/TimelineItem.schema.ts
|
|
2634
|
-
var
|
|
2635
|
-
var TimelineItemSchema =
|
|
2636
|
-
timestamp:
|
|
2637
|
-
count:
|
|
2638
|
-
successful:
|
|
2639
|
-
failed:
|
|
2640
|
-
timeout:
|
|
2675
|
+
var import_zod54 = require("zod");
|
|
2676
|
+
var TimelineItemSchema = import_zod54.z.object({
|
|
2677
|
+
timestamp: import_zod54.z.string(),
|
|
2678
|
+
count: import_zod54.z.int(),
|
|
2679
|
+
successful: import_zod54.z.int(),
|
|
2680
|
+
failed: import_zod54.z.int(),
|
|
2681
|
+
timeout: import_zod54.z.int()
|
|
2641
2682
|
});
|
|
2642
2683
|
|
|
2643
2684
|
// src/generated/cfg_centrifugo/_utils/schemas/TimelineResponse.schema.ts
|
|
2644
|
-
var
|
|
2645
|
-
var TimelineResponseSchema =
|
|
2646
|
-
timeline:
|
|
2647
|
-
period_hours:
|
|
2648
|
-
interval:
|
|
2685
|
+
var import_zod55 = require("zod");
|
|
2686
|
+
var TimelineResponseSchema = import_zod55.z.object({
|
|
2687
|
+
timeline: import_zod55.z.array(TimelineItemSchema),
|
|
2688
|
+
period_hours: import_zod55.z.int(),
|
|
2689
|
+
interval: import_zod55.z.string()
|
|
2649
2690
|
});
|
|
2650
2691
|
|
|
2651
2692
|
// src/generated/cfg_centrifugo/_utils/fetchers/centrifugo__centrifugo_admin_api.ts
|
|
@@ -2674,7 +2715,8 @@ var API2 = class {
|
|
|
2674
2715
|
this._loadTokensFromStorage();
|
|
2675
2716
|
this._client = new APIClient2(this.baseUrl, {
|
|
2676
2717
|
retryConfig: this.options?.retryConfig,
|
|
2677
|
-
loggerConfig: this.options?.loggerConfig
|
|
2718
|
+
loggerConfig: this.options?.loggerConfig,
|
|
2719
|
+
tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
|
|
2678
2720
|
});
|
|
2679
2721
|
this._injectAuthHeader();
|
|
2680
2722
|
this.centrifugo_admin_api = this._client.centrifugo_admin_api;
|
|
@@ -2692,7 +2734,8 @@ var API2 = class {
|
|
|
2692
2734
|
_reinitClients() {
|
|
2693
2735
|
this._client = new APIClient2(this.baseUrl, {
|
|
2694
2736
|
retryConfig: this.options?.retryConfig,
|
|
2695
|
-
loggerConfig: this.options?.loggerConfig
|
|
2737
|
+
loggerConfig: this.options?.loggerConfig,
|
|
2738
|
+
tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
|
|
2696
2739
|
});
|
|
2697
2740
|
this._injectAuthHeader();
|
|
2698
2741
|
this.centrifugo_admin_api = this._client.centrifugo_admin_api;
|
|
@@ -3191,8 +3234,10 @@ var APIClient3 = class {
|
|
|
3191
3234
|
constructor(baseUrl, options) {
|
|
3192
3235
|
this.logger = null;
|
|
3193
3236
|
this.retryConfig = null;
|
|
3237
|
+
this.tokenGetter = null;
|
|
3194
3238
|
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
3195
3239
|
this.httpClient = options?.httpClient || new FetchAdapter3();
|
|
3240
|
+
this.tokenGetter = options?.tokenGetter || null;
|
|
3196
3241
|
if (options?.loggerConfig !== void 0) {
|
|
3197
3242
|
this.logger = new APILogger3(options.loggerConfig);
|
|
3198
3243
|
}
|
|
@@ -3218,6 +3263,19 @@ var APIClient3 = class {
|
|
|
3218
3263
|
}
|
|
3219
3264
|
return null;
|
|
3220
3265
|
}
|
|
3266
|
+
/**
|
|
3267
|
+
* Get the base URL for building streaming/download URLs.
|
|
3268
|
+
*/
|
|
3269
|
+
getBaseUrl() {
|
|
3270
|
+
return this.baseUrl;
|
|
3271
|
+
}
|
|
3272
|
+
/**
|
|
3273
|
+
* Get JWT token for URL authentication (used in streaming endpoints).
|
|
3274
|
+
* Returns null if no token getter is configured or no token is available.
|
|
3275
|
+
*/
|
|
3276
|
+
getToken() {
|
|
3277
|
+
return this.tokenGetter ? this.tokenGetter() : null;
|
|
3278
|
+
}
|
|
3221
3279
|
/**
|
|
3222
3280
|
* Make HTTP request with Django CSRF and session handling.
|
|
3223
3281
|
* Automatically retries on network errors and 5xx server errors.
|
|
@@ -3430,40 +3488,40 @@ var LocalStorageAdapter3 = class {
|
|
|
3430
3488
|
};
|
|
3431
3489
|
|
|
3432
3490
|
// src/generated/cfg_webpush/_utils/schemas/SendPushRequestRequest.schema.ts
|
|
3433
|
-
var
|
|
3434
|
-
var SendPushRequestRequestSchema =
|
|
3435
|
-
title:
|
|
3436
|
-
body:
|
|
3437
|
-
icon:
|
|
3438
|
-
url:
|
|
3491
|
+
var import_zod56 = require("zod");
|
|
3492
|
+
var SendPushRequestRequestSchema = import_zod56.z.object({
|
|
3493
|
+
title: import_zod56.z.string().min(1).max(255),
|
|
3494
|
+
body: import_zod56.z.string().min(1),
|
|
3495
|
+
icon: import_zod56.z.union([import_zod56.z.url(), import_zod56.z.literal("")]).nullable().optional(),
|
|
3496
|
+
url: import_zod56.z.union([import_zod56.z.url(), import_zod56.z.literal("")]).nullable().optional()
|
|
3439
3497
|
});
|
|
3440
3498
|
|
|
3441
3499
|
// src/generated/cfg_webpush/_utils/schemas/SendPushResponse.schema.ts
|
|
3442
|
-
var
|
|
3443
|
-
var SendPushResponseSchema =
|
|
3444
|
-
success:
|
|
3445
|
-
sent_to:
|
|
3500
|
+
var import_zod57 = require("zod");
|
|
3501
|
+
var SendPushResponseSchema = import_zod57.z.object({
|
|
3502
|
+
success: import_zod57.z.boolean(),
|
|
3503
|
+
sent_to: import_zod57.z.int()
|
|
3446
3504
|
});
|
|
3447
3505
|
|
|
3448
3506
|
// src/generated/cfg_webpush/_utils/schemas/SubscribeRequestRequest.schema.ts
|
|
3449
|
-
var
|
|
3450
|
-
var SubscribeRequestRequestSchema =
|
|
3451
|
-
endpoint:
|
|
3452
|
-
keys:
|
|
3507
|
+
var import_zod58 = require("zod");
|
|
3508
|
+
var SubscribeRequestRequestSchema = import_zod58.z.object({
|
|
3509
|
+
endpoint: import_zod58.z.union([import_zod58.z.url(), import_zod58.z.literal("")]),
|
|
3510
|
+
keys: import_zod58.z.record(import_zod58.z.string(), import_zod58.z.string().min(1))
|
|
3453
3511
|
});
|
|
3454
3512
|
|
|
3455
3513
|
// src/generated/cfg_webpush/_utils/schemas/SubscribeResponse.schema.ts
|
|
3456
|
-
var
|
|
3457
|
-
var SubscribeResponseSchema =
|
|
3458
|
-
success:
|
|
3459
|
-
subscription_id:
|
|
3460
|
-
created:
|
|
3514
|
+
var import_zod59 = require("zod");
|
|
3515
|
+
var SubscribeResponseSchema = import_zod59.z.object({
|
|
3516
|
+
success: import_zod59.z.boolean(),
|
|
3517
|
+
subscription_id: import_zod59.z.int(),
|
|
3518
|
+
created: import_zod59.z.boolean()
|
|
3461
3519
|
});
|
|
3462
3520
|
|
|
3463
3521
|
// src/generated/cfg_webpush/_utils/schemas/VapidPublicKeyResponse.schema.ts
|
|
3464
|
-
var
|
|
3465
|
-
var VapidPublicKeyResponseSchema =
|
|
3466
|
-
publicKey:
|
|
3522
|
+
var import_zod60 = require("zod");
|
|
3523
|
+
var VapidPublicKeyResponseSchema = import_zod60.z.object({
|
|
3524
|
+
publicKey: import_zod60.z.string()
|
|
3467
3525
|
});
|
|
3468
3526
|
|
|
3469
3527
|
// src/generated/cfg_webpush/_utils/fetchers/webpush__web_push.ts
|
|
@@ -3483,7 +3541,8 @@ var API3 = class {
|
|
|
3483
3541
|
this._loadTokensFromStorage();
|
|
3484
3542
|
this._client = new APIClient3(this.baseUrl, {
|
|
3485
3543
|
retryConfig: this.options?.retryConfig,
|
|
3486
|
-
loggerConfig: this.options?.loggerConfig
|
|
3544
|
+
loggerConfig: this.options?.loggerConfig,
|
|
3545
|
+
tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
|
|
3487
3546
|
});
|
|
3488
3547
|
this._injectAuthHeader();
|
|
3489
3548
|
this.web_push = this._client.web_push;
|
|
@@ -3498,7 +3557,8 @@ var API3 = class {
|
|
|
3498
3557
|
_reinitClients() {
|
|
3499
3558
|
this._client = new APIClient3(this.baseUrl, {
|
|
3500
3559
|
retryConfig: this.options?.retryConfig,
|
|
3501
|
-
loggerConfig: this.options?.loggerConfig
|
|
3560
|
+
loggerConfig: this.options?.loggerConfig,
|
|
3561
|
+
tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
|
|
3502
3562
|
});
|
|
3503
3563
|
this._injectAuthHeader();
|
|
3504
3564
|
this.web_push = this._client.web_push;
|
|
@@ -3672,7 +3732,7 @@ __name(useBase64, "useBase64");
|
|
|
3672
3732
|
// src/auth/hooks/useProfileCache.ts
|
|
3673
3733
|
var CACHE_KEY = "user_profile_cache";
|
|
3674
3734
|
var CACHE_VERSION = 1;
|
|
3675
|
-
var DEFAULT_TTL =
|
|
3735
|
+
var DEFAULT_TTL = 144e5;
|
|
3676
3736
|
function getCachedProfile() {
|
|
3677
3737
|
try {
|
|
3678
3738
|
if (typeof window === "undefined") return null;
|
|
@@ -3958,6 +4018,100 @@ var useAuthRedirectManager = /* @__PURE__ */ __name((options = {}) => {
|
|
|
3958
4018
|
};
|
|
3959
4019
|
}, "useAuthRedirectManager");
|
|
3960
4020
|
|
|
4021
|
+
// src/auth/hooks/useTokenRefresh.ts
|
|
4022
|
+
var import_react2 = require("react");
|
|
4023
|
+
var TOKEN_REFRESH_THRESHOLD_MS = 10 * 60 * 1e3;
|
|
4024
|
+
var CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
4025
|
+
function getTokenExpiry(token) {
|
|
4026
|
+
try {
|
|
4027
|
+
const payload = JSON.parse(atob(token.split(".")[1]));
|
|
4028
|
+
return payload.exp * 1e3;
|
|
4029
|
+
} catch {
|
|
4030
|
+
return null;
|
|
4031
|
+
}
|
|
4032
|
+
}
|
|
4033
|
+
__name(getTokenExpiry, "getTokenExpiry");
|
|
4034
|
+
function isTokenExpiringSoon(token, thresholdMs) {
|
|
4035
|
+
const expiry = getTokenExpiry(token);
|
|
4036
|
+
if (!expiry) return false;
|
|
4037
|
+
const timeUntilExpiry = expiry - Date.now();
|
|
4038
|
+
return timeUntilExpiry < thresholdMs;
|
|
4039
|
+
}
|
|
4040
|
+
__name(isTokenExpiringSoon, "isTokenExpiringSoon");
|
|
4041
|
+
function useTokenRefresh(options = {}) {
|
|
4042
|
+
const { enabled = true, onRefresh, onRefreshError } = options;
|
|
4043
|
+
const isRefreshingRef = (0, import_react2.useRef)(false);
|
|
4044
|
+
const refreshToken = (0, import_react2.useCallback)(async () => {
|
|
4045
|
+
if (isRefreshingRef.current) {
|
|
4046
|
+
authLogger.debug("Token refresh already in progress");
|
|
4047
|
+
return false;
|
|
4048
|
+
}
|
|
4049
|
+
const refreshTokenValue = api.getRefreshToken();
|
|
4050
|
+
if (!refreshTokenValue) {
|
|
4051
|
+
authLogger.warn("No refresh token available");
|
|
4052
|
+
return false;
|
|
4053
|
+
}
|
|
4054
|
+
isRefreshingRef.current = true;
|
|
4055
|
+
authLogger.info("Refreshing token...");
|
|
4056
|
+
try {
|
|
4057
|
+
const result = await api.auth.accountsTokenRefreshCreate({
|
|
4058
|
+
refresh: refreshTokenValue
|
|
4059
|
+
});
|
|
4060
|
+
const newAccessToken = result.access;
|
|
4061
|
+
if (!newAccessToken) {
|
|
4062
|
+
throw new Error("No access token in refresh response");
|
|
4063
|
+
}
|
|
4064
|
+
api.setToken(newAccessToken, refreshTokenValue);
|
|
4065
|
+
authLogger.info("Token refreshed successfully");
|
|
4066
|
+
onRefresh?.(newAccessToken);
|
|
4067
|
+
return true;
|
|
4068
|
+
} catch (error) {
|
|
4069
|
+
authLogger.error("Token refresh error:", error);
|
|
4070
|
+
onRefreshError?.(error instanceof Error ? error : new Error(String(error)));
|
|
4071
|
+
return false;
|
|
4072
|
+
} finally {
|
|
4073
|
+
isRefreshingRef.current = false;
|
|
4074
|
+
}
|
|
4075
|
+
}, [onRefresh, onRefreshError]);
|
|
4076
|
+
const checkAndRefresh = (0, import_react2.useCallback)(async () => {
|
|
4077
|
+
const token = api.getToken();
|
|
4078
|
+
if (!token) return;
|
|
4079
|
+
if (isTokenExpiringSoon(token, TOKEN_REFRESH_THRESHOLD_MS)) {
|
|
4080
|
+
authLogger.info("Token expiring soon, refreshing proactively");
|
|
4081
|
+
await refreshToken();
|
|
4082
|
+
}
|
|
4083
|
+
}, [refreshToken]);
|
|
4084
|
+
(0, import_react2.useEffect)(() => {
|
|
4085
|
+
if (!enabled) return;
|
|
4086
|
+
checkAndRefresh();
|
|
4087
|
+
const intervalId = setInterval(checkAndRefresh, CHECK_INTERVAL_MS);
|
|
4088
|
+
return () => clearInterval(intervalId);
|
|
4089
|
+
}, [enabled, checkAndRefresh]);
|
|
4090
|
+
(0, import_react2.useEffect)(() => {
|
|
4091
|
+
if (!enabled) return;
|
|
4092
|
+
const handleFocus = /* @__PURE__ */ __name(() => {
|
|
4093
|
+
authLogger.debug("Window focused, checking token...");
|
|
4094
|
+
checkAndRefresh();
|
|
4095
|
+
}, "handleFocus");
|
|
4096
|
+
window.addEventListener("focus", handleFocus);
|
|
4097
|
+
return () => window.removeEventListener("focus", handleFocus);
|
|
4098
|
+
}, [enabled, checkAndRefresh]);
|
|
4099
|
+
(0, import_react2.useEffect)(() => {
|
|
4100
|
+
if (!enabled) return;
|
|
4101
|
+
const handleOnline = /* @__PURE__ */ __name(() => {
|
|
4102
|
+
authLogger.info("Network reconnected, checking token...");
|
|
4103
|
+
checkAndRefresh();
|
|
4104
|
+
}, "handleOnline");
|
|
4105
|
+
window.addEventListener("online", handleOnline);
|
|
4106
|
+
return () => window.removeEventListener("online", handleOnline);
|
|
4107
|
+
}, [enabled, checkAndRefresh]);
|
|
4108
|
+
return {
|
|
4109
|
+
refreshToken,
|
|
4110
|
+
checkAndRefresh
|
|
4111
|
+
};
|
|
4112
|
+
}
|
|
4113
|
+
__name(useTokenRefresh, "useTokenRefresh");
|
|
4114
|
+
|
|
3961
4115
|
// src/auth/utils/analytics.ts
|
|
3962
4116
|
var AnalyticsEvent = /* @__PURE__ */ ((AnalyticsEvent2) => {
|
|
3963
4117
|
AnalyticsEvent2["AUTH_OTP_REQUEST"] = "auth_otp_request";
|
|
@@ -3995,7 +4149,7 @@ var Analytics = {
|
|
|
3995
4149
|
};
|
|
3996
4150
|
|
|
3997
4151
|
// src/auth/context/AccountsContext.tsx
|
|
3998
|
-
var
|
|
4152
|
+
var import_react3 = require("react");
|
|
3999
4153
|
|
|
4000
4154
|
// src/generated/cfg_accounts/_utils/hooks/accounts__auth.ts
|
|
4001
4155
|
var import_swr = require("swr");
|
|
@@ -4067,20 +4221,20 @@ __name(useCreateAccountsOtpVerifyCreate, "useCreateAccountsOtpVerifyCreate");
|
|
|
4067
4221
|
|
|
4068
4222
|
// src/auth/context/AccountsContext.tsx
|
|
4069
4223
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
4070
|
-
var AccountsContext = (0,
|
|
4224
|
+
var AccountsContext = (0, import_react3.createContext)(void 0);
|
|
4071
4225
|
function AccountsProvider({ children }) {
|
|
4072
|
-
const [profile, setProfile] = (0,
|
|
4226
|
+
const [profile, setProfile] = (0, import_react3.useState)(() => {
|
|
4073
4227
|
const cached = getCachedProfile();
|
|
4074
4228
|
return cached || void 0;
|
|
4075
4229
|
});
|
|
4076
|
-
const [isLoadingProfile, setIsLoadingProfile] = (0,
|
|
4077
|
-
const [profileError, setProfileError] = (0,
|
|
4078
|
-
const profileRef = (0,
|
|
4079
|
-
const isLoadingRef = (0,
|
|
4080
|
-
(0,
|
|
4230
|
+
const [isLoadingProfile, setIsLoadingProfile] = (0, import_react3.useState)(false);
|
|
4231
|
+
const [profileError, setProfileError] = (0, import_react3.useState)(null);
|
|
4232
|
+
const profileRef = (0, import_react3.useRef)(profile);
|
|
4233
|
+
const isLoadingRef = (0, import_react3.useRef)(false);
|
|
4234
|
+
(0, import_react3.useEffect)(() => {
|
|
4081
4235
|
profileRef.current = profile;
|
|
4082
4236
|
}, [profile]);
|
|
4083
|
-
(0,
|
|
4237
|
+
(0, import_react3.useEffect)(() => {
|
|
4084
4238
|
isLoadingRef.current = isLoadingProfile;
|
|
4085
4239
|
}, [isLoadingProfile]);
|
|
4086
4240
|
const updateMutation = useUpdateAccountsProfileUpdateUpdate();
|
|
@@ -4089,7 +4243,7 @@ function AccountsProvider({ children }) {
|
|
|
4089
4243
|
const otpRequestMutation = useCreateAccountsOtpRequestCreate();
|
|
4090
4244
|
const otpVerifyMutation = useCreateAccountsOtpVerifyCreate();
|
|
4091
4245
|
const tokenRefreshMutation = useCreateAccountsTokenRefreshCreate();
|
|
4092
|
-
const refreshProfile = (0,
|
|
4246
|
+
const refreshProfile = (0, import_react3.useCallback)(async (callerId) => {
|
|
4093
4247
|
const currentProfile = profileRef.current;
|
|
4094
4248
|
const currentLoading = isLoadingRef.current;
|
|
4095
4249
|
if (currentProfile && !currentLoading) {
|
|
@@ -4127,8 +4281,8 @@ function AccountsProvider({ children }) {
|
|
|
4127
4281
|
await refreshProfile("AccountsContext.partialUpdateProfile");
|
|
4128
4282
|
return result;
|
|
4129
4283
|
}, "partialUpdateProfile");
|
|
4130
|
-
const uploadAvatar = /* @__PURE__ */ __name(async (
|
|
4131
|
-
const result = await avatarMutation(
|
|
4284
|
+
const uploadAvatar = /* @__PURE__ */ __name(async (avatar) => {
|
|
4285
|
+
const result = await avatarMutation({ avatar }, api);
|
|
4132
4286
|
await refreshProfile("AccountsContext.uploadAvatar");
|
|
4133
4287
|
return result;
|
|
4134
4288
|
}, "uploadAvatar");
|
|
@@ -4155,7 +4309,7 @@ function AccountsProvider({ children }) {
|
|
|
4155
4309
|
}
|
|
4156
4310
|
return result;
|
|
4157
4311
|
}, "refreshToken");
|
|
4158
|
-
const logout = (0,
|
|
4312
|
+
const logout = (0, import_react3.useCallback)(() => {
|
|
4159
4313
|
api.clearTokens();
|
|
4160
4314
|
setProfile(void 0);
|
|
4161
4315
|
setProfileError(null);
|
|
@@ -4178,7 +4332,7 @@ function AccountsProvider({ children }) {
|
|
|
4178
4332
|
}
|
|
4179
4333
|
__name(AccountsProvider, "AccountsProvider");
|
|
4180
4334
|
function useAccountsContext() {
|
|
4181
|
-
const context = (0,
|
|
4335
|
+
const context = (0, import_react3.useContext)(AccountsContext);
|
|
4182
4336
|
if (!context) {
|
|
4183
4337
|
throw new Error("useAccountsContext must be used within AccountsProvider");
|
|
4184
4338
|
}
|
|
@@ -4193,7 +4347,7 @@ var defaultRoutes = {
|
|
|
4193
4347
|
defaultCallback: "/dashboard",
|
|
4194
4348
|
defaultAuthCallback: "/auth"
|
|
4195
4349
|
};
|
|
4196
|
-
var AuthContext = (0,
|
|
4350
|
+
var AuthContext = (0, import_react4.createContext)(void 0);
|
|
4197
4351
|
var EMAIL_STORAGE_KEY = "auth_email";
|
|
4198
4352
|
var PHONE_STORAGE_KEY = "auth_phone";
|
|
4199
4353
|
var hasValidTokens = /* @__PURE__ */ __name(() => {
|
|
@@ -4206,45 +4360,58 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4206
4360
|
fallbackUrl: config?.routes?.defaultCallback || defaultRoutes.defaultCallback,
|
|
4207
4361
|
clearOnUse: true
|
|
4208
4362
|
});
|
|
4209
|
-
const [isLoading, setIsLoading] = (0,
|
|
4363
|
+
const [isLoading, setIsLoading] = (0, import_react4.useState)(() => {
|
|
4210
4364
|
if (typeof window !== "undefined") {
|
|
4211
4365
|
const hasTokens = hasValidTokens();
|
|
4212
4366
|
return !hasTokens;
|
|
4213
4367
|
}
|
|
4214
4368
|
return true;
|
|
4215
4369
|
});
|
|
4216
|
-
const [initialized, setInitialized] = (0,
|
|
4370
|
+
const [initialized, setInitialized] = (0, import_react4.useState)(false);
|
|
4217
4371
|
const router = (0, import_hooks2.useCfgRouter)();
|
|
4218
4372
|
const pathname = (0, import_navigation.usePathname)();
|
|
4219
4373
|
const queryParams = (0, import_hooks2.useQueryParams)();
|
|
4220
4374
|
const [storedEmail, setStoredEmail, clearStoredEmail] = (0, import_hooks2.useLocalStorage)(EMAIL_STORAGE_KEY, null);
|
|
4221
4375
|
const [storedPhone, setStoredPhone, clearStoredPhone] = (0, import_hooks2.useLocalStorage)(PHONE_STORAGE_KEY, null);
|
|
4376
|
+
useTokenRefresh({
|
|
4377
|
+
enabled: true,
|
|
4378
|
+
onRefresh: /* @__PURE__ */ __name((newToken) => {
|
|
4379
|
+
authLogger.info("Token auto-refreshed successfully");
|
|
4380
|
+
}, "onRefresh"),
|
|
4381
|
+
onRefreshError: /* @__PURE__ */ __name((error) => {
|
|
4382
|
+
authLogger.warn("Token auto-refresh failed:", error.message);
|
|
4383
|
+
}, "onRefreshError")
|
|
4384
|
+
});
|
|
4222
4385
|
const user = accounts.profile;
|
|
4223
|
-
const userRef = (0,
|
|
4224
|
-
const configRef = (0,
|
|
4225
|
-
const isLoadingProfileRef = (0,
|
|
4226
|
-
(0,
|
|
4386
|
+
const userRef = (0, import_react4.useRef)(user);
|
|
4387
|
+
const configRef = (0, import_react4.useRef)(config);
|
|
4388
|
+
const isLoadingProfileRef = (0, import_react4.useRef)(false);
|
|
4389
|
+
(0, import_react4.useEffect)(() => {
|
|
4227
4390
|
userRef.current = user;
|
|
4228
4391
|
}, [user]);
|
|
4229
|
-
(0,
|
|
4392
|
+
(0, import_react4.useEffect)(() => {
|
|
4230
4393
|
configRef.current = config;
|
|
4231
4394
|
}, [config]);
|
|
4232
|
-
const clearAuthState = (0,
|
|
4395
|
+
const clearAuthState = (0, import_react4.useCallback)((caller) => {
|
|
4233
4396
|
authLogger.info("clearAuthState >> caller", caller);
|
|
4234
4397
|
api.clearTokens();
|
|
4235
4398
|
clearProfileCache();
|
|
4236
4399
|
setInitialized(true);
|
|
4237
4400
|
setIsLoading(false);
|
|
4238
4401
|
}, []);
|
|
4239
|
-
const handleGlobalAuthError = (0,
|
|
4240
|
-
|
|
4241
|
-
|
|
4402
|
+
const handleGlobalAuthError = (0, import_react4.useCallback)((error, context = "API Request") => {
|
|
4403
|
+
const isAuthError = error?.status === 401 || error?.statusCode === 401 || error?.code === "token_not_valid" || error?.code === "authentication_failed";
|
|
4404
|
+
if (isAuthError) {
|
|
4405
|
+
authLogger.warn(`Authentication error in ${context}, clearing tokens`);
|
|
4242
4406
|
clearAuthState(`globalAuthError:${context}`);
|
|
4243
4407
|
return true;
|
|
4244
4408
|
}
|
|
4409
|
+
if (error?.success === false) {
|
|
4410
|
+
authLogger.warn(`Non-auth error in ${context} (not clearing session):`, error?.message || error);
|
|
4411
|
+
}
|
|
4245
4412
|
return false;
|
|
4246
4413
|
}, [clearAuthState]);
|
|
4247
|
-
const loadCurrentProfile = (0,
|
|
4414
|
+
const loadCurrentProfile = (0, import_react4.useCallback)(async (callerId) => {
|
|
4248
4415
|
const finalCallerId = callerId || "AuthContext.loadCurrentProfile";
|
|
4249
4416
|
if (isLoadingProfileRef.current) {
|
|
4250
4417
|
authLogger.debug(`Profile loading already in progress, skipping duplicate call from: ${finalCallerId}`);
|
|
@@ -4273,14 +4440,19 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4273
4440
|
setInitialized(true);
|
|
4274
4441
|
} catch (error) {
|
|
4275
4442
|
authLogger.error("Failed to load profile:", error);
|
|
4276
|
-
|
|
4277
|
-
|
|
4443
|
+
const isAuthError = error?.status === 401 || error?.statusCode === 401 || error?.code === "token_not_valid" || error?.code === "authentication_failed";
|
|
4444
|
+
if (isAuthError) {
|
|
4445
|
+
authLogger.warn("Authentication error, clearing session");
|
|
4446
|
+
clearAuthState("loadCurrentProfile:authError");
|
|
4447
|
+
} else {
|
|
4448
|
+
authLogger.warn("Profile load failed but keeping session (non-auth error)");
|
|
4449
|
+
setInitialized(true);
|
|
4278
4450
|
}
|
|
4279
4451
|
} finally {
|
|
4280
4452
|
isLoadingProfileRef.current = false;
|
|
4281
4453
|
}
|
|
4282
4454
|
}, [clearAuthState, handleGlobalAuthError, accounts]);
|
|
4283
|
-
(0,
|
|
4455
|
+
(0, import_react4.useEffect)(() => {
|
|
4284
4456
|
if (initialized) return;
|
|
4285
4457
|
const initializeAuth = /* @__PURE__ */ __name(async () => {
|
|
4286
4458
|
authLogger.info("Initializing auth...");
|
|
@@ -4320,7 +4492,13 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4320
4492
|
await loadCurrentProfile("AuthContext.initializeAuth");
|
|
4321
4493
|
} catch (error) {
|
|
4322
4494
|
authLogger.error("Failed to load profile during initialization:", error);
|
|
4323
|
-
|
|
4495
|
+
const isAuthError = error?.status === 401 || error?.statusCode === 401 || error?.code === "token_not_valid" || error?.code === "authentication_failed";
|
|
4496
|
+
if (isAuthError) {
|
|
4497
|
+
clearAuthState("initializeAuth:authError");
|
|
4498
|
+
} else {
|
|
4499
|
+
authLogger.warn("Init profile load failed but keeping session");
|
|
4500
|
+
setInitialized(true);
|
|
4501
|
+
}
|
|
4324
4502
|
}
|
|
4325
4503
|
setIsLoading(false);
|
|
4326
4504
|
} else {
|
|
@@ -4330,7 +4508,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4330
4508
|
}, "initializeAuth");
|
|
4331
4509
|
initializeAuth();
|
|
4332
4510
|
}, [initialized]);
|
|
4333
|
-
(0,
|
|
4511
|
+
(0, import_react4.useEffect)(() => {
|
|
4334
4512
|
if (!initialized) return;
|
|
4335
4513
|
const isAuthenticated = api.isAuthenticated();
|
|
4336
4514
|
const authRoute = config?.routes?.auth || defaultRoutes.auth;
|
|
@@ -4341,15 +4519,15 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4341
4519
|
router.push(callbackUrl);
|
|
4342
4520
|
}
|
|
4343
4521
|
}, [initialized, pathname, queryParams, config?.routes]);
|
|
4344
|
-
const pushToDefaultCallbackUrl = (0,
|
|
4522
|
+
const pushToDefaultCallbackUrl = (0, import_react4.useCallback)(() => {
|
|
4345
4523
|
const callbackUrl = config?.routes?.defaultCallback || defaultRoutes.defaultCallback;
|
|
4346
4524
|
router.push(callbackUrl);
|
|
4347
4525
|
}, [config?.routes, router]);
|
|
4348
|
-
const pushToDefaultAuthCallbackUrl = (0,
|
|
4526
|
+
const pushToDefaultAuthCallbackUrl = (0, import_react4.useCallback)(() => {
|
|
4349
4527
|
const authCallbackUrl = config?.routes?.defaultAuthCallback || defaultRoutes.defaultAuthCallback;
|
|
4350
4528
|
router.push(authCallbackUrl);
|
|
4351
4529
|
}, [config?.routes, router]);
|
|
4352
|
-
const checkAuthAndRedirect = (0,
|
|
4530
|
+
const checkAuthAndRedirect = (0, import_react4.useCallback)(async () => {
|
|
4353
4531
|
try {
|
|
4354
4532
|
setIsLoading(true);
|
|
4355
4533
|
const isAuthenticated = api.isAuthenticated();
|
|
@@ -4371,7 +4549,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4371
4549
|
setIsLoading(false);
|
|
4372
4550
|
}
|
|
4373
4551
|
}, [loadCurrentProfile, clearAuthState, pushToDefaultCallbackUrl, pushToDefaultAuthCallbackUrl, handleGlobalAuthError]);
|
|
4374
|
-
const requestOTP = (0,
|
|
4552
|
+
const requestOTP = (0, import_react4.useCallback)(
|
|
4375
4553
|
async (identifier, channel, sourceUrl) => {
|
|
4376
4554
|
api.clearTokens();
|
|
4377
4555
|
try {
|
|
@@ -4399,7 +4577,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4399
4577
|
},
|
|
4400
4578
|
[accounts]
|
|
4401
4579
|
);
|
|
4402
|
-
const verifyOTP = (0,
|
|
4580
|
+
const verifyOTP = (0, import_react4.useCallback)(
|
|
4403
4581
|
async (identifier, otpCode, channel, sourceUrl, redirectUrl, skipRedirect) => {
|
|
4404
4582
|
try {
|
|
4405
4583
|
const channelValue = channel === "phone" ? enums_exports.OTPVerifyRequestChannel.PHONE : enums_exports.OTPVerifyRequestChannel.EMAIL;
|
|
@@ -4466,7 +4644,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4466
4644
|
},
|
|
4467
4645
|
[setStoredEmail, setStoredPhone, clearStoredEmail, clearStoredPhone, config?.routes?.defaultCallback, accounts, router]
|
|
4468
4646
|
);
|
|
4469
|
-
const refreshToken = (0,
|
|
4647
|
+
const refreshToken = (0, import_react4.useCallback)(async () => {
|
|
4470
4648
|
try {
|
|
4471
4649
|
const refreshTokenValue = api.getRefreshToken();
|
|
4472
4650
|
if (!refreshTokenValue) {
|
|
@@ -4499,7 +4677,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4499
4677
|
};
|
|
4500
4678
|
}
|
|
4501
4679
|
}, [clearAuthState, accounts]);
|
|
4502
|
-
const logout = (0,
|
|
4680
|
+
const logout = (0, import_react4.useCallback)(async () => {
|
|
4503
4681
|
const performLogout = /* @__PURE__ */ __name(() => {
|
|
4504
4682
|
Analytics.event("auth_logout" /* AUTH_LOGOUT */, {
|
|
4505
4683
|
category: "auth" /* AUTH */
|
|
@@ -4528,10 +4706,10 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4528
4706
|
}
|
|
4529
4707
|
}
|
|
4530
4708
|
}, [accounts, config?.routes?.defaultAuthCallback, router]);
|
|
4531
|
-
const isAdminUser = (0,
|
|
4709
|
+
const isAdminUser = (0, import_react4.useMemo)(() => {
|
|
4532
4710
|
return Boolean(user?.is_staff || user?.is_superuser);
|
|
4533
4711
|
}, [user]);
|
|
4534
|
-
const value = (0,
|
|
4712
|
+
const value = (0, import_react4.useMemo)(
|
|
4535
4713
|
() => ({
|
|
4536
4714
|
user,
|
|
4537
4715
|
isLoading,
|
|
@@ -4583,7 +4761,7 @@ var AuthProvider = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4583
4761
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AccountsProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AuthProviderInternal, { config, children }) });
|
|
4584
4762
|
}, "AuthProvider");
|
|
4585
4763
|
var useAuth = /* @__PURE__ */ __name(() => {
|
|
4586
|
-
const context = (0,
|
|
4764
|
+
const context = (0, import_react4.useContext)(AuthContext);
|
|
4587
4765
|
if (context === void 0) {
|
|
4588
4766
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
4589
4767
|
}
|
|
@@ -4591,20 +4769,20 @@ var useAuth = /* @__PURE__ */ __name(() => {
|
|
|
4591
4769
|
}, "useAuth");
|
|
4592
4770
|
|
|
4593
4771
|
// src/auth/hooks/useAuthFormState.ts
|
|
4594
|
-
var
|
|
4772
|
+
var import_react5 = require("react");
|
|
4595
4773
|
var useAuthFormState = /* @__PURE__ */ __name((initialIdentifier = "", initialChannel = "email") => {
|
|
4596
|
-
const [identifier, setIdentifier] = (0,
|
|
4597
|
-
const [channel, setChannel] = (0,
|
|
4598
|
-
const [otp, setOtp] = (0,
|
|
4599
|
-
const [isLoading, setIsLoading] = (0,
|
|
4600
|
-
const [acceptedTerms, setAcceptedTerms] = (0,
|
|
4601
|
-
const [step, setStep] = (0,
|
|
4602
|
-
const [error, setError] = (0,
|
|
4603
|
-
const [twoFactorSessionId, setTwoFactorSessionId] = (0,
|
|
4604
|
-
const [shouldPrompt2FA, setShouldPrompt2FA] = (0,
|
|
4605
|
-
const [twoFactorCode, setTwoFactorCode] = (0,
|
|
4606
|
-
const [useBackupCode, setUseBackupCode] = (0,
|
|
4607
|
-
const clearError = (0,
|
|
4774
|
+
const [identifier, setIdentifier] = (0, import_react5.useState)(initialIdentifier);
|
|
4775
|
+
const [channel, setChannel] = (0, import_react5.useState)(initialChannel);
|
|
4776
|
+
const [otp, setOtp] = (0, import_react5.useState)("");
|
|
4777
|
+
const [isLoading, setIsLoading] = (0, import_react5.useState)(false);
|
|
4778
|
+
const [acceptedTerms, setAcceptedTerms] = (0, import_react5.useState)(false);
|
|
4779
|
+
const [step, setStep] = (0, import_react5.useState)("identifier");
|
|
4780
|
+
const [error, setError] = (0, import_react5.useState)("");
|
|
4781
|
+
const [twoFactorSessionId, setTwoFactorSessionId] = (0, import_react5.useState)(null);
|
|
4782
|
+
const [shouldPrompt2FA, setShouldPrompt2FA] = (0, import_react5.useState)(false);
|
|
4783
|
+
const [twoFactorCode, setTwoFactorCode] = (0, import_react5.useState)("");
|
|
4784
|
+
const [useBackupCode, setUseBackupCode] = (0, import_react5.useState)(false);
|
|
4785
|
+
const clearError = (0, import_react5.useCallback)(() => setError(""), []);
|
|
4608
4786
|
return {
|
|
4609
4787
|
// State
|
|
4610
4788
|
identifier,
|
|
@@ -4635,11 +4813,11 @@ var useAuthFormState = /* @__PURE__ */ __name((initialIdentifier = "", initialCh
|
|
|
4635
4813
|
}, "useAuthFormState");
|
|
4636
4814
|
|
|
4637
4815
|
// src/auth/hooks/useAuthValidation.ts
|
|
4638
|
-
var
|
|
4816
|
+
var import_react6 = require("react");
|
|
4639
4817
|
var EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
4640
4818
|
var PHONE_REGEX = /^\+[1-9]\d{6,14}$/;
|
|
4641
4819
|
var useAuthValidation = /* @__PURE__ */ __name(() => {
|
|
4642
|
-
const detectChannelFromIdentifier2 = (0,
|
|
4820
|
+
const detectChannelFromIdentifier2 = (0, import_react6.useCallback)((id) => {
|
|
4643
4821
|
if (!id) return null;
|
|
4644
4822
|
if (id.includes("@")) {
|
|
4645
4823
|
return "email";
|
|
@@ -4649,7 +4827,7 @@ var useAuthValidation = /* @__PURE__ */ __name(() => {
|
|
|
4649
4827
|
}
|
|
4650
4828
|
return null;
|
|
4651
4829
|
}, []);
|
|
4652
|
-
const validateIdentifier2 = (0,
|
|
4830
|
+
const validateIdentifier2 = (0, import_react6.useCallback)((id, channelType) => {
|
|
4653
4831
|
if (!id) return false;
|
|
4654
4832
|
const channel = channelType || detectChannelFromIdentifier2(id);
|
|
4655
4833
|
if (channel === "email") {
|
|
@@ -4680,11 +4858,11 @@ var validateIdentifier = /* @__PURE__ */ __name((id, channelType) => {
|
|
|
4680
4858
|
}, "validateIdentifier");
|
|
4681
4859
|
|
|
4682
4860
|
// src/auth/hooks/useAuthForm.ts
|
|
4683
|
-
var
|
|
4861
|
+
var import_react9 = require("react");
|
|
4684
4862
|
|
|
4685
4863
|
// src/auth/hooks/useAutoAuth.ts
|
|
4686
4864
|
var import_navigation2 = require("next/navigation");
|
|
4687
|
-
var
|
|
4865
|
+
var import_react7 = require("react");
|
|
4688
4866
|
var import_hooks3 = require("@djangocfg/ui-nextjs/hooks");
|
|
4689
4867
|
var useAutoAuth = /* @__PURE__ */ __name((options = {}) => {
|
|
4690
4868
|
const { onOTPDetected, cleanupUrl = true, allowedPaths = ["/auth"] } = options;
|
|
@@ -4694,7 +4872,7 @@ var useAutoAuth = /* @__PURE__ */ __name((options = {}) => {
|
|
|
4694
4872
|
const isAllowedPath = allowedPaths.some((path) => pathname === path || pathname?.startsWith(path + "/"));
|
|
4695
4873
|
const hasOTP = !!queryParams.get("otp");
|
|
4696
4874
|
const isReady = !!pathname && hasOTP && isAllowedPath;
|
|
4697
|
-
(0,
|
|
4875
|
+
(0, import_react7.useEffect)(() => {
|
|
4698
4876
|
if (!isReady) return;
|
|
4699
4877
|
const queryOtp = queryParams.get("otp");
|
|
4700
4878
|
if (queryOtp && typeof queryOtp === "string" && queryOtp.length === 6) {
|
|
@@ -4716,7 +4894,7 @@ var useAutoAuth = /* @__PURE__ */ __name((options = {}) => {
|
|
|
4716
4894
|
}, "useAutoAuth");
|
|
4717
4895
|
|
|
4718
4896
|
// src/auth/hooks/useTwoFactor.ts
|
|
4719
|
-
var
|
|
4897
|
+
var import_react8 = require("react");
|
|
4720
4898
|
var import_hooks4 = require("@djangocfg/ui-nextjs/hooks");
|
|
4721
4899
|
|
|
4722
4900
|
// src/generated/cfg_totp/totp__backup_codes/client.ts
|
|
@@ -5211,8 +5389,10 @@ var APIClient4 = class {
|
|
|
5211
5389
|
constructor(baseUrl, options) {
|
|
5212
5390
|
this.logger = null;
|
|
5213
5391
|
this.retryConfig = null;
|
|
5392
|
+
this.tokenGetter = null;
|
|
5214
5393
|
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
5215
5394
|
this.httpClient = options?.httpClient || new FetchAdapter4();
|
|
5395
|
+
this.tokenGetter = options?.tokenGetter || null;
|
|
5216
5396
|
if (options?.loggerConfig !== void 0) {
|
|
5217
5397
|
this.logger = new APILogger4(options.loggerConfig);
|
|
5218
5398
|
}
|
|
@@ -5242,6 +5422,19 @@ var APIClient4 = class {
|
|
|
5242
5422
|
}
|
|
5243
5423
|
return null;
|
|
5244
5424
|
}
|
|
5425
|
+
/**
|
|
5426
|
+
* Get the base URL for building streaming/download URLs.
|
|
5427
|
+
*/
|
|
5428
|
+
getBaseUrl() {
|
|
5429
|
+
return this.baseUrl;
|
|
5430
|
+
}
|
|
5431
|
+
/**
|
|
5432
|
+
* Get JWT token for URL authentication (used in streaming endpoints).
|
|
5433
|
+
* Returns null if no token getter is configured or no token is available.
|
|
5434
|
+
*/
|
|
5435
|
+
getToken() {
|
|
5436
|
+
return this.tokenGetter ? this.tokenGetter() : null;
|
|
5437
|
+
}
|
|
5245
5438
|
/**
|
|
5246
5439
|
* Make HTTP request with Django CSRF and session handling.
|
|
5247
5440
|
* Automatically retries on network errors and 5xx server errors.
|
|
@@ -5462,112 +5655,112 @@ var DeviceListStatus = /* @__PURE__ */ ((DeviceListStatus2) => {
|
|
|
5462
5655
|
})(DeviceListStatus || {});
|
|
5463
5656
|
|
|
5464
5657
|
// src/generated/cfg_totp/_utils/schemas/BackupCodesRegenerateRequest.schema.ts
|
|
5465
|
-
var
|
|
5466
|
-
var BackupCodesRegenerateRequestSchema =
|
|
5467
|
-
code:
|
|
5658
|
+
var import_zod61 = require("zod");
|
|
5659
|
+
var BackupCodesRegenerateRequestSchema = import_zod61.z.object({
|
|
5660
|
+
code: import_zod61.z.string().min(6).max(6)
|
|
5468
5661
|
});
|
|
5469
5662
|
|
|
5470
5663
|
// src/generated/cfg_totp/_utils/schemas/BackupCodesRegenerateResponse.schema.ts
|
|
5471
|
-
var
|
|
5472
|
-
var BackupCodesRegenerateResponseSchema =
|
|
5473
|
-
backup_codes:
|
|
5474
|
-
warning:
|
|
5664
|
+
var import_zod62 = require("zod");
|
|
5665
|
+
var BackupCodesRegenerateResponseSchema = import_zod62.z.object({
|
|
5666
|
+
backup_codes: import_zod62.z.array(import_zod62.z.string()),
|
|
5667
|
+
warning: import_zod62.z.string()
|
|
5475
5668
|
});
|
|
5476
5669
|
|
|
5477
5670
|
// src/generated/cfg_totp/_utils/schemas/BackupCodesStatus.schema.ts
|
|
5478
|
-
var
|
|
5479
|
-
var BackupCodesStatusSchema =
|
|
5480
|
-
remaining_count:
|
|
5481
|
-
total_generated:
|
|
5482
|
-
warning:
|
|
5671
|
+
var import_zod63 = require("zod");
|
|
5672
|
+
var BackupCodesStatusSchema = import_zod63.z.object({
|
|
5673
|
+
remaining_count: import_zod63.z.int(),
|
|
5674
|
+
total_generated: import_zod63.z.int(),
|
|
5675
|
+
warning: import_zod63.z.string().nullable().optional()
|
|
5483
5676
|
});
|
|
5484
5677
|
|
|
5485
5678
|
// src/generated/cfg_totp/_utils/schemas/ConfirmSetupRequest.schema.ts
|
|
5486
|
-
var
|
|
5487
|
-
var ConfirmSetupRequestSchema =
|
|
5488
|
-
device_id:
|
|
5489
|
-
code:
|
|
5679
|
+
var import_zod64 = require("zod");
|
|
5680
|
+
var ConfirmSetupRequestSchema = import_zod64.z.object({
|
|
5681
|
+
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),
|
|
5682
|
+
code: import_zod64.z.string().min(6).max(6)
|
|
5490
5683
|
});
|
|
5491
5684
|
|
|
5492
5685
|
// src/generated/cfg_totp/_utils/schemas/ConfirmSetupResponse.schema.ts
|
|
5493
|
-
var
|
|
5494
|
-
var ConfirmSetupResponseSchema =
|
|
5495
|
-
message:
|
|
5496
|
-
backup_codes:
|
|
5497
|
-
backup_codes_warning:
|
|
5686
|
+
var import_zod65 = require("zod");
|
|
5687
|
+
var ConfirmSetupResponseSchema = import_zod65.z.object({
|
|
5688
|
+
message: import_zod65.z.string(),
|
|
5689
|
+
backup_codes: import_zod65.z.array(import_zod65.z.string()),
|
|
5690
|
+
backup_codes_warning: import_zod65.z.string()
|
|
5498
5691
|
});
|
|
5499
5692
|
|
|
5500
5693
|
// src/generated/cfg_totp/_utils/schemas/DeviceList.schema.ts
|
|
5501
|
-
var
|
|
5502
|
-
var DeviceListSchema =
|
|
5503
|
-
id:
|
|
5504
|
-
name:
|
|
5505
|
-
is_primary:
|
|
5506
|
-
status:
|
|
5507
|
-
created_at:
|
|
5508
|
-
confirmed_at:
|
|
5509
|
-
last_used_at:
|
|
5694
|
+
var import_zod66 = require("zod");
|
|
5695
|
+
var DeviceListSchema = import_zod66.z.object({
|
|
5696
|
+
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),
|
|
5697
|
+
name: import_zod66.z.string(),
|
|
5698
|
+
is_primary: import_zod66.z.boolean(),
|
|
5699
|
+
status: import_zod66.z.nativeEnum(DeviceListStatus),
|
|
5700
|
+
created_at: import_zod66.z.iso.datetime(),
|
|
5701
|
+
confirmed_at: import_zod66.z.iso.datetime().nullable(),
|
|
5702
|
+
last_used_at: import_zod66.z.iso.datetime().nullable()
|
|
5510
5703
|
});
|
|
5511
5704
|
|
|
5512
5705
|
// src/generated/cfg_totp/_utils/schemas/DisableRequest.schema.ts
|
|
5513
|
-
var
|
|
5514
|
-
var DisableRequestSchema =
|
|
5515
|
-
code:
|
|
5706
|
+
var import_zod67 = require("zod");
|
|
5707
|
+
var DisableRequestSchema = import_zod67.z.object({
|
|
5708
|
+
code: import_zod67.z.string().min(6).max(6)
|
|
5516
5709
|
});
|
|
5517
5710
|
|
|
5518
5711
|
// src/generated/cfg_totp/_utils/schemas/PaginatedDeviceListList.schema.ts
|
|
5519
|
-
var
|
|
5520
|
-
var PaginatedDeviceListListSchema =
|
|
5521
|
-
count:
|
|
5522
|
-
page:
|
|
5523
|
-
pages:
|
|
5524
|
-
page_size:
|
|
5525
|
-
has_next:
|
|
5526
|
-
has_previous:
|
|
5527
|
-
next_page:
|
|
5528
|
-
previous_page:
|
|
5529
|
-
results:
|
|
5712
|
+
var import_zod68 = require("zod");
|
|
5713
|
+
var PaginatedDeviceListListSchema = import_zod68.z.object({
|
|
5714
|
+
count: import_zod68.z.int(),
|
|
5715
|
+
page: import_zod68.z.int(),
|
|
5716
|
+
pages: import_zod68.z.int(),
|
|
5717
|
+
page_size: import_zod68.z.int(),
|
|
5718
|
+
has_next: import_zod68.z.boolean(),
|
|
5719
|
+
has_previous: import_zod68.z.boolean(),
|
|
5720
|
+
next_page: import_zod68.z.int().nullable().optional(),
|
|
5721
|
+
previous_page: import_zod68.z.int().nullable().optional(),
|
|
5722
|
+
results: import_zod68.z.array(DeviceListSchema)
|
|
5530
5723
|
});
|
|
5531
5724
|
|
|
5532
5725
|
// src/generated/cfg_totp/_utils/schemas/SetupRequest.schema.ts
|
|
5533
|
-
var
|
|
5534
|
-
var SetupRequestSchema =
|
|
5535
|
-
device_name:
|
|
5726
|
+
var import_zod69 = require("zod");
|
|
5727
|
+
var SetupRequestSchema = import_zod69.z.object({
|
|
5728
|
+
device_name: import_zod69.z.string().min(1).max(100).optional()
|
|
5536
5729
|
});
|
|
5537
5730
|
|
|
5538
5731
|
// src/generated/cfg_totp/_utils/schemas/SetupResponse.schema.ts
|
|
5539
|
-
var
|
|
5540
|
-
var SetupResponseSchema =
|
|
5541
|
-
device_id:
|
|
5542
|
-
secret:
|
|
5543
|
-
provisioning_uri:
|
|
5544
|
-
qr_code_base64:
|
|
5545
|
-
expires_in:
|
|
5732
|
+
var import_zod70 = require("zod");
|
|
5733
|
+
var SetupResponseSchema = import_zod70.z.object({
|
|
5734
|
+
device_id: import_zod70.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
5735
|
+
secret: import_zod70.z.string(),
|
|
5736
|
+
provisioning_uri: import_zod70.z.string(),
|
|
5737
|
+
qr_code_base64: import_zod70.z.string(),
|
|
5738
|
+
expires_in: import_zod70.z.int()
|
|
5546
5739
|
});
|
|
5547
5740
|
|
|
5548
5741
|
// src/generated/cfg_totp/_utils/schemas/VerifyBackupRequest.schema.ts
|
|
5549
|
-
var
|
|
5550
|
-
var VerifyBackupRequestSchema =
|
|
5551
|
-
session_id:
|
|
5552
|
-
backup_code:
|
|
5742
|
+
var import_zod71 = require("zod");
|
|
5743
|
+
var VerifyBackupRequestSchema = import_zod71.z.object({
|
|
5744
|
+
session_id: import_zod71.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
5745
|
+
backup_code: import_zod71.z.string().min(8).max(8)
|
|
5553
5746
|
});
|
|
5554
5747
|
|
|
5555
5748
|
// src/generated/cfg_totp/_utils/schemas/VerifyRequest.schema.ts
|
|
5556
|
-
var
|
|
5557
|
-
var VerifyRequestSchema =
|
|
5558
|
-
session_id:
|
|
5559
|
-
code:
|
|
5749
|
+
var import_zod72 = require("zod");
|
|
5750
|
+
var VerifyRequestSchema = import_zod72.z.object({
|
|
5751
|
+
session_id: import_zod72.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
5752
|
+
code: import_zod72.z.string().min(6).max(6)
|
|
5560
5753
|
});
|
|
5561
5754
|
|
|
5562
5755
|
// src/generated/cfg_totp/_utils/schemas/VerifyResponse.schema.ts
|
|
5563
|
-
var
|
|
5564
|
-
var VerifyResponseSchema =
|
|
5565
|
-
message:
|
|
5566
|
-
access_token:
|
|
5567
|
-
refresh_token:
|
|
5568
|
-
user:
|
|
5569
|
-
remaining_backup_codes:
|
|
5570
|
-
warning:
|
|
5756
|
+
var import_zod73 = require("zod");
|
|
5757
|
+
var VerifyResponseSchema = import_zod73.z.object({
|
|
5758
|
+
message: import_zod73.z.string(),
|
|
5759
|
+
access_token: import_zod73.z.string(),
|
|
5760
|
+
refresh_token: import_zod73.z.string(),
|
|
5761
|
+
user: import_zod73.z.record(import_zod73.z.string(), import_zod73.z.any()),
|
|
5762
|
+
remaining_backup_codes: import_zod73.z.int().optional(),
|
|
5763
|
+
warning: import_zod73.z.string().optional()
|
|
5571
5764
|
});
|
|
5572
5765
|
|
|
5573
5766
|
// src/generated/cfg_totp/_utils/fetchers/totp__backup_codes.ts
|
|
@@ -5596,7 +5789,8 @@ var API4 = class {
|
|
|
5596
5789
|
this._loadTokensFromStorage();
|
|
5597
5790
|
this._client = new APIClient4(this.baseUrl, {
|
|
5598
5791
|
retryConfig: this.options?.retryConfig,
|
|
5599
|
-
loggerConfig: this.options?.loggerConfig
|
|
5792
|
+
loggerConfig: this.options?.loggerConfig,
|
|
5793
|
+
tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
|
|
5600
5794
|
});
|
|
5601
5795
|
this._injectAuthHeader();
|
|
5602
5796
|
this.backup_codes = this._client.backup_codes;
|
|
@@ -5615,7 +5809,8 @@ var API4 = class {
|
|
|
5615
5809
|
_reinitClients() {
|
|
5616
5810
|
this._client = new APIClient4(this.baseUrl, {
|
|
5617
5811
|
retryConfig: this.options?.retryConfig,
|
|
5618
|
-
loggerConfig: this.options?.loggerConfig
|
|
5812
|
+
loggerConfig: this.options?.loggerConfig,
|
|
5813
|
+
tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
|
|
5619
5814
|
});
|
|
5620
5815
|
this._injectAuthHeader();
|
|
5621
5816
|
this.backup_codes = this._client.backup_codes;
|
|
@@ -5757,14 +5952,14 @@ var apiCentrifugo = new API2(apiUrl2, { storage });
|
|
|
5757
5952
|
var useTwoFactor = /* @__PURE__ */ __name((options = {}) => {
|
|
5758
5953
|
const { onSuccess, onError, redirectUrl, skipRedirect = false } = options;
|
|
5759
5954
|
const router = (0, import_hooks4.useCfgRouter)();
|
|
5760
|
-
const [isLoading, setIsLoading] = (0,
|
|
5761
|
-
const [error, setError] = (0,
|
|
5762
|
-
const [warning, setWarning] = (0,
|
|
5763
|
-
const [remainingBackupCodes, setRemainingBackupCodes] = (0,
|
|
5764
|
-
const clearError = (0,
|
|
5955
|
+
const [isLoading, setIsLoading] = (0, import_react8.useState)(false);
|
|
5956
|
+
const [error, setError] = (0, import_react8.useState)(null);
|
|
5957
|
+
const [warning, setWarning] = (0, import_react8.useState)(null);
|
|
5958
|
+
const [remainingBackupCodes, setRemainingBackupCodes] = (0, import_react8.useState)(null);
|
|
5959
|
+
const clearError = (0, import_react8.useCallback)(() => {
|
|
5765
5960
|
setError(null);
|
|
5766
5961
|
}, []);
|
|
5767
|
-
const handleSuccess = (0,
|
|
5962
|
+
const handleSuccess = (0, import_react8.useCallback)((response) => {
|
|
5768
5963
|
apiAccounts.setToken(response.access_token, response.refresh_token);
|
|
5769
5964
|
if (response.warning) {
|
|
5770
5965
|
setWarning(response.warning);
|
|
@@ -5786,7 +5981,7 @@ var useTwoFactor = /* @__PURE__ */ __name((options = {}) => {
|
|
|
5786
5981
|
router.hardPush(finalRedirectUrl);
|
|
5787
5982
|
}
|
|
5788
5983
|
}, [onSuccess, redirectUrl, router, skipRedirect]);
|
|
5789
|
-
const verifyTOTP = (0,
|
|
5984
|
+
const verifyTOTP = (0, import_react8.useCallback)(async (sessionId, code) => {
|
|
5790
5985
|
if (!sessionId) {
|
|
5791
5986
|
const msg = "Missing 2FA session ID";
|
|
5792
5987
|
setError(msg);
|
|
@@ -5826,7 +6021,7 @@ var useTwoFactor = /* @__PURE__ */ __name((options = {}) => {
|
|
|
5826
6021
|
setIsLoading(false);
|
|
5827
6022
|
}
|
|
5828
6023
|
}, [handleSuccess, onError]);
|
|
5829
|
-
const verifyBackupCode = (0,
|
|
6024
|
+
const verifyBackupCode = (0, import_react8.useCallback)(async (sessionId, backupCode) => {
|
|
5830
6025
|
if (!sessionId) {
|
|
5831
6026
|
const msg = "Missing 2FA session ID";
|
|
5832
6027
|
setError(msg);
|
|
@@ -5892,7 +6087,7 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
5892
6087
|
} = options;
|
|
5893
6088
|
const formState = useAuthFormState();
|
|
5894
6089
|
const validation = useAuthValidation();
|
|
5895
|
-
const isAutoSubmitFromUrlRef = (0,
|
|
6090
|
+
const isAutoSubmitFromUrlRef = (0, import_react9.useRef)(false);
|
|
5896
6091
|
const {
|
|
5897
6092
|
requestOTP,
|
|
5898
6093
|
verifyOTP,
|
|
@@ -5939,7 +6134,7 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
5939
6134
|
// We handle navigation via success step
|
|
5940
6135
|
});
|
|
5941
6136
|
const { detectChannelFromIdentifier: detectChannelFromIdentifier2, validateIdentifier: validateIdentifier2 } = validation;
|
|
5942
|
-
const saveIdentifierToStorage = (0,
|
|
6137
|
+
const saveIdentifierToStorage = (0, import_react9.useCallback)((id, ch) => {
|
|
5943
6138
|
if (ch === "email") {
|
|
5944
6139
|
saveEmail(id);
|
|
5945
6140
|
clearSavedPhone();
|
|
@@ -5948,7 +6143,7 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
5948
6143
|
clearSavedEmail();
|
|
5949
6144
|
}
|
|
5950
6145
|
}, [saveEmail, savePhone, clearSavedEmail, clearSavedPhone]);
|
|
5951
|
-
(0,
|
|
6146
|
+
(0, import_react9.useEffect)(() => {
|
|
5952
6147
|
const savedPhone = getSavedPhone();
|
|
5953
6148
|
const savedEmail = getSavedEmail();
|
|
5954
6149
|
if (savedPhone) {
|
|
@@ -5959,7 +6154,7 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
5959
6154
|
setChannel("email");
|
|
5960
6155
|
}
|
|
5961
6156
|
}, [getSavedEmail, getSavedPhone, setIdentifier, setChannel]);
|
|
5962
|
-
(0,
|
|
6157
|
+
(0, import_react9.useEffect)(() => {
|
|
5963
6158
|
if (identifier) {
|
|
5964
6159
|
const detected = detectChannelFromIdentifier2(identifier);
|
|
5965
6160
|
if (detected && detected !== channel) {
|
|
@@ -5967,7 +6162,7 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
5967
6162
|
}
|
|
5968
6163
|
}
|
|
5969
6164
|
}, [identifier, channel, detectChannelFromIdentifier2, setChannel]);
|
|
5970
|
-
const handleIdentifierSubmit = (0,
|
|
6165
|
+
const handleIdentifierSubmit = (0, import_react9.useCallback)(async (e) => {
|
|
5971
6166
|
e.preventDefault();
|
|
5972
6167
|
if (!identifier) {
|
|
5973
6168
|
const msg = channel === "phone" ? "Please enter your phone number" : "Please enter your email address";
|
|
@@ -6022,7 +6217,7 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
6022
6217
|
onError,
|
|
6023
6218
|
sourceUrl
|
|
6024
6219
|
]);
|
|
6025
|
-
const submitOTP = (0,
|
|
6220
|
+
const submitOTP = (0, import_react9.useCallback)(async (submitIdentifier, submitOtp, submitChannel) => {
|
|
6026
6221
|
if (!submitOtp || submitOtp.length < 6) {
|
|
6027
6222
|
const msg = "Please enter the 6-digit verification code";
|
|
6028
6223
|
setError(msg);
|
|
@@ -6072,11 +6267,11 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
6072
6267
|
setIsLoading(false);
|
|
6073
6268
|
}
|
|
6074
6269
|
}, [verifyOTP, saveIdentifierToStorage, setError, setIsLoading, clearError, onOTPSuccess, onError, sourceUrl, redirectUrl, setTwoFactorSessionId, setShouldPrompt2FA, setStep, enable2FASetup]);
|
|
6075
|
-
const handleOTPSubmit = (0,
|
|
6270
|
+
const handleOTPSubmit = (0, import_react9.useCallback)(async (e) => {
|
|
6076
6271
|
e.preventDefault();
|
|
6077
6272
|
await submitOTP(identifier, otp, channel);
|
|
6078
6273
|
}, [identifier, otp, channel, submitOTP]);
|
|
6079
|
-
const handleResendOTP = (0,
|
|
6274
|
+
const handleResendOTP = (0, import_react9.useCallback)(async () => {
|
|
6080
6275
|
setIsLoading(true);
|
|
6081
6276
|
clearError();
|
|
6082
6277
|
try {
|
|
@@ -6096,15 +6291,15 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
6096
6291
|
setIsLoading(false);
|
|
6097
6292
|
}
|
|
6098
6293
|
}, [identifier, channel, requestOTP, saveIdentifierToStorage, setOtp, setError, setIsLoading, clearError, onError, sourceUrl]);
|
|
6099
|
-
const handleBackToIdentifier = (0,
|
|
6294
|
+
const handleBackToIdentifier = (0, import_react9.useCallback)(() => {
|
|
6100
6295
|
setStep("identifier");
|
|
6101
6296
|
clearError();
|
|
6102
6297
|
}, [setStep, clearError]);
|
|
6103
|
-
const forceOTPStep = (0,
|
|
6298
|
+
const forceOTPStep = (0, import_react9.useCallback)(() => {
|
|
6104
6299
|
setStep("otp");
|
|
6105
6300
|
clearError();
|
|
6106
6301
|
}, [setStep, clearError]);
|
|
6107
|
-
const handle2FASubmit = (0,
|
|
6302
|
+
const handle2FASubmit = (0, import_react9.useCallback)(async (e) => {
|
|
6108
6303
|
e.preventDefault();
|
|
6109
6304
|
if (!twoFactorSessionId) {
|
|
6110
6305
|
const msg = "Missing 2FA session";
|
|
@@ -6118,12 +6313,12 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
6118
6313
|
await twoFactor.verifyTOTP(twoFactorSessionId, twoFactorCode);
|
|
6119
6314
|
}
|
|
6120
6315
|
}, [twoFactorSessionId, twoFactorCode, useBackupCode, twoFactor, setError, onError]);
|
|
6121
|
-
const handleUseBackupCode = (0,
|
|
6316
|
+
const handleUseBackupCode = (0, import_react9.useCallback)(() => {
|
|
6122
6317
|
setUseBackupCode(true);
|
|
6123
6318
|
setTwoFactorCode("");
|
|
6124
6319
|
clearError();
|
|
6125
6320
|
}, [setUseBackupCode, setTwoFactorCode, clearError]);
|
|
6126
|
-
const handleUseTOTP = (0,
|
|
6321
|
+
const handleUseTOTP = (0, import_react9.useCallback)(() => {
|
|
6127
6322
|
setUseBackupCode(false);
|
|
6128
6323
|
setTwoFactorCode("");
|
|
6129
6324
|
clearError();
|
|
@@ -6188,14 +6383,14 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
6188
6383
|
}, "useAuthForm");
|
|
6189
6384
|
|
|
6190
6385
|
// src/auth/hooks/useGithubAuth.ts
|
|
6191
|
-
var
|
|
6386
|
+
var import_react10 = require("react");
|
|
6192
6387
|
var import_hooks5 = require("@djangocfg/ui-nextjs/hooks");
|
|
6193
6388
|
var useGithubAuth = /* @__PURE__ */ __name((options = {}) => {
|
|
6194
6389
|
const { sourceUrl, onSuccess, onError, onRequires2FA, redirectUrl, skipRedirect = false } = options;
|
|
6195
6390
|
const router = (0, import_hooks5.useCfgRouter)();
|
|
6196
|
-
const [isLoading, setIsLoading] = (0,
|
|
6197
|
-
const [error, setError] = (0,
|
|
6198
|
-
const startGithubAuth = (0,
|
|
6391
|
+
const [isLoading, setIsLoading] = (0, import_react10.useState)(false);
|
|
6392
|
+
const [error, setError] = (0, import_react10.useState)(null);
|
|
6393
|
+
const startGithubAuth = (0, import_react10.useCallback)(async () => {
|
|
6199
6394
|
setIsLoading(true);
|
|
6200
6395
|
setError(null);
|
|
6201
6396
|
try {
|
|
@@ -6229,7 +6424,7 @@ var useGithubAuth = /* @__PURE__ */ __name((options = {}) => {
|
|
|
6229
6424
|
setIsLoading(false);
|
|
6230
6425
|
}
|
|
6231
6426
|
}, [sourceUrl, onError]);
|
|
6232
|
-
const handleGithubCallback = (0,
|
|
6427
|
+
const handleGithubCallback = (0, import_react10.useCallback)(async (code, state) => {
|
|
6233
6428
|
setIsLoading(true);
|
|
6234
6429
|
setError(null);
|
|
6235
6430
|
try {
|
|
@@ -6294,26 +6489,26 @@ var useGithubAuth = /* @__PURE__ */ __name((options = {}) => {
|
|
|
6294
6489
|
}, "useGithubAuth");
|
|
6295
6490
|
|
|
6296
6491
|
// src/auth/hooks/useTwoFactorSetup.ts
|
|
6297
|
-
var
|
|
6492
|
+
var import_react11 = require("react");
|
|
6298
6493
|
var useTwoFactorSetup = /* @__PURE__ */ __name((options = {}) => {
|
|
6299
6494
|
const { onComplete, onError } = options;
|
|
6300
|
-
const [isLoading, setIsLoading] = (0,
|
|
6301
|
-
const [error, setError] = (0,
|
|
6302
|
-
const [setupData, setSetupData] = (0,
|
|
6303
|
-
const [backupCodes, setBackupCodes] = (0,
|
|
6304
|
-
const [backupCodesWarning, setBackupCodesWarning] = (0,
|
|
6305
|
-
const [setupStep, setSetupStep] = (0,
|
|
6306
|
-
const clearError = (0,
|
|
6495
|
+
const [isLoading, setIsLoading] = (0, import_react11.useState)(false);
|
|
6496
|
+
const [error, setError] = (0, import_react11.useState)(null);
|
|
6497
|
+
const [setupData, setSetupData] = (0, import_react11.useState)(null);
|
|
6498
|
+
const [backupCodes, setBackupCodes] = (0, import_react11.useState)(null);
|
|
6499
|
+
const [backupCodesWarning, setBackupCodesWarning] = (0, import_react11.useState)(null);
|
|
6500
|
+
const [setupStep, setSetupStep] = (0, import_react11.useState)("idle");
|
|
6501
|
+
const clearError = (0, import_react11.useCallback)(() => {
|
|
6307
6502
|
setError(null);
|
|
6308
6503
|
}, []);
|
|
6309
|
-
const resetSetup = (0,
|
|
6504
|
+
const resetSetup = (0, import_react11.useCallback)(() => {
|
|
6310
6505
|
setSetupData(null);
|
|
6311
6506
|
setBackupCodes(null);
|
|
6312
6507
|
setBackupCodesWarning(null);
|
|
6313
6508
|
setSetupStep("idle");
|
|
6314
6509
|
setError(null);
|
|
6315
6510
|
}, []);
|
|
6316
|
-
const startSetup = (0,
|
|
6511
|
+
const startSetup = (0, import_react11.useCallback)(async (deviceName) => {
|
|
6317
6512
|
setIsLoading(true);
|
|
6318
6513
|
setError(null);
|
|
6319
6514
|
setSetupStep("scanning");
|
|
@@ -6343,7 +6538,7 @@ var useTwoFactorSetup = /* @__PURE__ */ __name((options = {}) => {
|
|
|
6343
6538
|
setIsLoading(false);
|
|
6344
6539
|
}
|
|
6345
6540
|
}, [onError]);
|
|
6346
|
-
const confirmSetup = (0,
|
|
6541
|
+
const confirmSetup = (0, import_react11.useCallback)(async (code) => {
|
|
6347
6542
|
if (!setupData) {
|
|
6348
6543
|
const msg = "Setup not started. Call startSetup() first.";
|
|
6349
6544
|
setError(msg);
|
|
@@ -6398,16 +6593,16 @@ var useTwoFactorSetup = /* @__PURE__ */ __name((options = {}) => {
|
|
|
6398
6593
|
}, "useTwoFactorSetup");
|
|
6399
6594
|
|
|
6400
6595
|
// src/auth/hooks/useTwoFactorStatus.ts
|
|
6401
|
-
var
|
|
6596
|
+
var import_react12 = require("react");
|
|
6402
6597
|
var useTwoFactorStatus = /* @__PURE__ */ __name(() => {
|
|
6403
|
-
const [isLoading, setIsLoading] = (0,
|
|
6404
|
-
const [error, setError] = (0,
|
|
6405
|
-
const [has2FAEnabled, setHas2FAEnabled] = (0,
|
|
6406
|
-
const [devices, setDevices] = (0,
|
|
6407
|
-
const clearError = (0,
|
|
6598
|
+
const [isLoading, setIsLoading] = (0, import_react12.useState)(false);
|
|
6599
|
+
const [error, setError] = (0, import_react12.useState)(null);
|
|
6600
|
+
const [has2FAEnabled, setHas2FAEnabled] = (0, import_react12.useState)(null);
|
|
6601
|
+
const [devices, setDevices] = (0, import_react12.useState)([]);
|
|
6602
|
+
const clearError = (0, import_react12.useCallback)(() => {
|
|
6408
6603
|
setError(null);
|
|
6409
6604
|
}, []);
|
|
6410
|
-
const fetchStatus = (0,
|
|
6605
|
+
const fetchStatus = (0, import_react12.useCallback)(async () => {
|
|
6411
6606
|
setIsLoading(true);
|
|
6412
6607
|
setError(null);
|
|
6413
6608
|
try {
|
|
@@ -6432,7 +6627,7 @@ var useTwoFactorStatus = /* @__PURE__ */ __name(() => {
|
|
|
6432
6627
|
setIsLoading(false);
|
|
6433
6628
|
}
|
|
6434
6629
|
}, []);
|
|
6435
|
-
const disable2FA = (0,
|
|
6630
|
+
const disable2FA = (0, import_react12.useCallback)(async (code) => {
|
|
6436
6631
|
if (!code || code.length !== 6) {
|
|
6437
6632
|
setError("Please enter a 6-digit code");
|
|
6438
6633
|
return false;
|
|
@@ -6467,14 +6662,14 @@ var useTwoFactorStatus = /* @__PURE__ */ __name(() => {
|
|
|
6467
6662
|
}, "useTwoFactorStatus");
|
|
6468
6663
|
|
|
6469
6664
|
// src/auth/hooks/useAuthGuard.ts
|
|
6470
|
-
var
|
|
6665
|
+
var import_react13 = require("react");
|
|
6471
6666
|
var import_hooks6 = require("@djangocfg/ui-nextjs/hooks");
|
|
6472
6667
|
var useAuthGuard = /* @__PURE__ */ __name((options = {}) => {
|
|
6473
6668
|
const { redirectTo = "/auth", requireAuth = true, saveRedirectUrl: shouldSaveUrl = true } = options;
|
|
6474
6669
|
const { isAuthenticated, isLoading, saveRedirectUrl } = useAuth();
|
|
6475
6670
|
const router = (0, import_hooks6.useCfgRouter)();
|
|
6476
|
-
const [isRedirecting, setIsRedirecting] = (0,
|
|
6477
|
-
(0,
|
|
6671
|
+
const [isRedirecting, setIsRedirecting] = (0, import_react13.useState)(false);
|
|
6672
|
+
(0, import_react13.useEffect)(() => {
|
|
6478
6673
|
if (!isLoading && requireAuth && !isAuthenticated && !isRedirecting) {
|
|
6479
6674
|
if (shouldSaveUrl && typeof window !== "undefined") {
|
|
6480
6675
|
const currentUrl = window.location.pathname + window.location.search;
|
|
@@ -6488,9 +6683,9 @@ var useAuthGuard = /* @__PURE__ */ __name((options = {}) => {
|
|
|
6488
6683
|
}, "useAuthGuard");
|
|
6489
6684
|
|
|
6490
6685
|
// src/auth/hooks/useLocalStorage.ts
|
|
6491
|
-
var
|
|
6686
|
+
var import_react14 = require("react");
|
|
6492
6687
|
function useLocalStorage2(key, initialValue) {
|
|
6493
|
-
const [storedValue, setStoredValue] = (0,
|
|
6688
|
+
const [storedValue, setStoredValue] = (0, import_react14.useState)(() => {
|
|
6494
6689
|
if (typeof window === "undefined") {
|
|
6495
6690
|
return initialValue;
|
|
6496
6691
|
}
|