@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.mjs
CHANGED
|
@@ -9,11 +9,11 @@ var __export = (target, all) => {
|
|
|
9
9
|
import { usePathname } from "next/navigation";
|
|
10
10
|
import {
|
|
11
11
|
createContext as createContext2,
|
|
12
|
-
useCallback as
|
|
12
|
+
useCallback as useCallback3,
|
|
13
13
|
useContext as useContext2,
|
|
14
|
-
useEffect as
|
|
14
|
+
useEffect as useEffect3,
|
|
15
15
|
useMemo,
|
|
16
|
-
useRef as
|
|
16
|
+
useRef as useRef3,
|
|
17
17
|
useState as useState3
|
|
18
18
|
} from "react";
|
|
19
19
|
import { useCfgRouter, useLocalStorage, useQueryParams } from "@djangocfg/ui-nextjs/hooks";
|
|
@@ -116,7 +116,9 @@ var UserProfile = class {
|
|
|
116
116
|
* multipart/form-data with 'avatar' field.
|
|
117
117
|
*/
|
|
118
118
|
async accountsProfileAvatarCreate(data) {
|
|
119
|
-
const
|
|
119
|
+
const formData = new FormData();
|
|
120
|
+
formData.append("avatar", data.avatar);
|
|
121
|
+
const response = await this.client.request("POST", "/cfg/accounts/profile/avatar/", { formData });
|
|
120
122
|
return response;
|
|
121
123
|
}
|
|
122
124
|
/**
|
|
@@ -552,8 +554,10 @@ var APIClient = class {
|
|
|
552
554
|
constructor(baseUrl, options) {
|
|
553
555
|
this.logger = null;
|
|
554
556
|
this.retryConfig = null;
|
|
557
|
+
this.tokenGetter = null;
|
|
555
558
|
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
556
559
|
this.httpClient = options?.httpClient || new FetchAdapter();
|
|
560
|
+
this.tokenGetter = options?.tokenGetter || null;
|
|
557
561
|
if (options?.loggerConfig !== void 0) {
|
|
558
562
|
this.logger = new APILogger(options.loggerConfig);
|
|
559
563
|
}
|
|
@@ -582,6 +586,19 @@ var APIClient = class {
|
|
|
582
586
|
}
|
|
583
587
|
return null;
|
|
584
588
|
}
|
|
589
|
+
/**
|
|
590
|
+
* Get the base URL for building streaming/download URLs.
|
|
591
|
+
*/
|
|
592
|
+
getBaseUrl() {
|
|
593
|
+
return this.baseUrl;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Get JWT token for URL authentication (used in streaming endpoints).
|
|
597
|
+
* Returns null if no token getter is configured or no token is available.
|
|
598
|
+
*/
|
|
599
|
+
getToken() {
|
|
600
|
+
return this.tokenGetter ? this.tokenGetter() : null;
|
|
601
|
+
}
|
|
585
602
|
/**
|
|
586
603
|
* Make HTTP request with Django CSRF and session handling.
|
|
587
604
|
* Automatically retries on network errors and 5xx server errors.
|
|
@@ -829,168 +846,174 @@ var CentrifugoTokenSchema = z.object({
|
|
|
829
846
|
channels: z.array(z.string())
|
|
830
847
|
});
|
|
831
848
|
|
|
832
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
849
|
+
// src/generated/cfg_accounts/_utils/schemas/CfgAccountsProfileAvatarCreateRequest.schema.ts
|
|
833
850
|
import { z as z2 } from "zod";
|
|
834
|
-
var
|
|
835
|
-
|
|
836
|
-
source_url: z2.union([z2.url(), z2.literal("")]).optional()
|
|
851
|
+
var CfgAccountsProfileAvatarCreateRequestSchema = z2.object({
|
|
852
|
+
avatar: z2.union([z2.instanceof(File), z2.instanceof(Blob)])
|
|
837
853
|
});
|
|
838
854
|
|
|
839
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
855
|
+
// src/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeRequestRequest.schema.ts
|
|
840
856
|
import { z as z3 } from "zod";
|
|
841
|
-
var
|
|
842
|
-
|
|
843
|
-
|
|
857
|
+
var OAuthAuthorizeRequestRequestSchema = z3.object({
|
|
858
|
+
redirect_uri: z3.union([z3.url(), z3.literal("")]).optional(),
|
|
859
|
+
source_url: z3.union([z3.url(), z3.literal("")]).optional()
|
|
844
860
|
});
|
|
845
861
|
|
|
846
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
862
|
+
// src/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeResponse.schema.ts
|
|
847
863
|
import { z as z4 } from "zod";
|
|
848
|
-
var
|
|
849
|
-
|
|
850
|
-
state: z4.string()
|
|
851
|
-
redirect_uri: z4.union([z4.url(), z4.literal("")]).optional()
|
|
864
|
+
var OAuthAuthorizeResponseSchema = z4.object({
|
|
865
|
+
authorization_url: z4.union([z4.url(), z4.literal("")]),
|
|
866
|
+
state: z4.string()
|
|
852
867
|
});
|
|
853
868
|
|
|
854
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
869
|
+
// src/generated/cfg_accounts/_utils/schemas/OAuthCallbackRequestRequest.schema.ts
|
|
855
870
|
import { z as z5 } from "zod";
|
|
856
|
-
var
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
provider_username: z5.string(),
|
|
861
|
-
provider_email: z5.email(),
|
|
862
|
-
provider_avatar_url: z5.union([z5.url(), z5.literal("")]),
|
|
863
|
-
connected_at: z5.iso.datetime(),
|
|
864
|
-
last_login_at: z5.iso.datetime()
|
|
871
|
+
var OAuthCallbackRequestRequestSchema = z5.object({
|
|
872
|
+
code: z5.string().min(10).max(500),
|
|
873
|
+
state: z5.string().min(20).max(100),
|
|
874
|
+
redirect_uri: z5.union([z5.url(), z5.literal("")]).optional()
|
|
865
875
|
});
|
|
866
876
|
|
|
867
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
877
|
+
// src/generated/cfg_accounts/_utils/schemas/OAuthConnection.schema.ts
|
|
868
878
|
import { z as z6 } from "zod";
|
|
869
|
-
var
|
|
870
|
-
|
|
879
|
+
var OAuthConnectionSchema = z6.object({
|
|
880
|
+
id: z6.int(),
|
|
881
|
+
provider: z6.nativeEnum(OAuthConnectionProvider),
|
|
882
|
+
provider_display: z6.string(),
|
|
883
|
+
provider_username: z6.string(),
|
|
884
|
+
provider_email: z6.email(),
|
|
885
|
+
provider_avatar_url: z6.union([z6.url(), z6.literal("")]),
|
|
886
|
+
connected_at: z6.iso.datetime(),
|
|
887
|
+
last_login_at: z6.iso.datetime()
|
|
871
888
|
});
|
|
872
889
|
|
|
873
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
890
|
+
// src/generated/cfg_accounts/_utils/schemas/OAuthDisconnectRequestRequest.schema.ts
|
|
874
891
|
import { z as z7 } from "zod";
|
|
875
|
-
var
|
|
876
|
-
|
|
877
|
-
error_description: z7.string().optional()
|
|
892
|
+
var OAuthDisconnectRequestRequestSchema = z7.object({
|
|
893
|
+
provider: z7.nativeEnum(OAuthDisconnectRequestRequestProvider)
|
|
878
894
|
});
|
|
879
895
|
|
|
880
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
896
|
+
// src/generated/cfg_accounts/_utils/schemas/OAuthError.schema.ts
|
|
881
897
|
import { z as z8 } from "zod";
|
|
882
|
-
var
|
|
883
|
-
|
|
898
|
+
var OAuthErrorSchema = z8.object({
|
|
899
|
+
error: z8.string(),
|
|
900
|
+
error_description: z8.string().optional()
|
|
884
901
|
});
|
|
885
902
|
|
|
886
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
903
|
+
// src/generated/cfg_accounts/_utils/schemas/OAuthProvidersResponse.schema.ts
|
|
887
904
|
import { z as z9 } from "zod";
|
|
888
|
-
var
|
|
889
|
-
|
|
890
|
-
session_id: z9.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i).nullable().optional(),
|
|
891
|
-
access: z9.string().nullable().optional(),
|
|
892
|
-
refresh: z9.string().nullable().optional(),
|
|
893
|
-
user: z9.record(z9.string(), z9.any()).nullable().optional(),
|
|
894
|
-
is_new_user: z9.boolean(),
|
|
895
|
-
is_new_connection: z9.boolean(),
|
|
896
|
-
should_prompt_2fa: z9.boolean().optional()
|
|
905
|
+
var OAuthProvidersResponseSchema = z9.object({
|
|
906
|
+
providers: z9.array(z9.record(z9.string(), z9.any()))
|
|
897
907
|
});
|
|
898
908
|
|
|
899
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
909
|
+
// src/generated/cfg_accounts/_utils/schemas/OAuthTokenResponse.schema.ts
|
|
900
910
|
import { z as z10 } from "zod";
|
|
901
|
-
var
|
|
902
|
-
|
|
911
|
+
var OAuthTokenResponseSchema = z10.object({
|
|
912
|
+
requires_2fa: z10.boolean().optional(),
|
|
913
|
+
session_id: z10.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(),
|
|
914
|
+
access: z10.string().nullable().optional(),
|
|
915
|
+
refresh: z10.string().nullable().optional(),
|
|
916
|
+
user: z10.record(z10.string(), z10.any()).nullable().optional(),
|
|
917
|
+
is_new_user: z10.boolean(),
|
|
918
|
+
is_new_connection: z10.boolean(),
|
|
919
|
+
should_prompt_2fa: z10.boolean().optional()
|
|
903
920
|
});
|
|
904
921
|
|
|
905
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
922
|
+
// src/generated/cfg_accounts/_utils/schemas/OTPErrorResponse.schema.ts
|
|
906
923
|
import { z as z11 } from "zod";
|
|
907
|
-
var
|
|
908
|
-
|
|
909
|
-
channel: z11.nativeEnum(OTPRequestRequestChannel).optional(),
|
|
910
|
-
source_url: z11.union([z11.url(), z11.literal("")]).optional()
|
|
924
|
+
var OTPErrorResponseSchema = z11.object({
|
|
925
|
+
error: z11.string()
|
|
911
926
|
});
|
|
912
927
|
|
|
913
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
928
|
+
// src/generated/cfg_accounts/_utils/schemas/OTPRequestRequest.schema.ts
|
|
914
929
|
import { z as z12 } from "zod";
|
|
915
|
-
var
|
|
916
|
-
|
|
930
|
+
var OTPRequestRequestSchema = z12.object({
|
|
931
|
+
identifier: z12.string().min(1),
|
|
932
|
+
channel: z12.nativeEnum(OTPRequestRequestChannel).optional(),
|
|
933
|
+
source_url: z12.union([z12.url(), z12.literal("")]).optional()
|
|
917
934
|
});
|
|
918
935
|
|
|
919
|
-
// src/generated/cfg_accounts/_utils/schemas/
|
|
936
|
+
// src/generated/cfg_accounts/_utils/schemas/OTPRequestResponse.schema.ts
|
|
920
937
|
import { z as z13 } from "zod";
|
|
921
|
-
var
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
938
|
+
var OTPRequestResponseSchema = z13.object({
|
|
939
|
+
message: z13.string()
|
|
940
|
+
});
|
|
941
|
+
|
|
942
|
+
// src/generated/cfg_accounts/_utils/schemas/OTPVerifyRequest.schema.ts
|
|
943
|
+
import { z as z14 } from "zod";
|
|
944
|
+
var OTPVerifyRequestSchema = z14.object({
|
|
945
|
+
identifier: z14.string().min(1),
|
|
946
|
+
otp: z14.string().min(6).max(6),
|
|
947
|
+
channel: z14.nativeEnum(OTPVerifyRequestChannel).optional(),
|
|
948
|
+
source_url: z14.union([z14.url(), z14.literal("")]).optional()
|
|
926
949
|
});
|
|
927
950
|
|
|
928
951
|
// src/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts
|
|
929
|
-
import { z as
|
|
952
|
+
import { z as z16 } from "zod";
|
|
930
953
|
|
|
931
954
|
// src/generated/cfg_accounts/_utils/schemas/User.schema.ts
|
|
932
|
-
import { z as
|
|
933
|
-
var UserSchema =
|
|
934
|
-
id:
|
|
935
|
-
email:
|
|
936
|
-
first_name:
|
|
937
|
-
last_name:
|
|
938
|
-
full_name:
|
|
939
|
-
initials:
|
|
940
|
-
display_username:
|
|
941
|
-
company:
|
|
942
|
-
phone:
|
|
943
|
-
position:
|
|
944
|
-
avatar:
|
|
945
|
-
is_staff:
|
|
946
|
-
is_superuser:
|
|
947
|
-
date_joined:
|
|
948
|
-
last_login:
|
|
949
|
-
unanswered_messages_count:
|
|
955
|
+
import { z as z15 } from "zod";
|
|
956
|
+
var UserSchema = z15.object({
|
|
957
|
+
id: z15.int(),
|
|
958
|
+
email: z15.email(),
|
|
959
|
+
first_name: z15.string().max(50).optional(),
|
|
960
|
+
last_name: z15.string().max(50).optional(),
|
|
961
|
+
full_name: z15.string(),
|
|
962
|
+
initials: z15.string(),
|
|
963
|
+
display_username: z15.string(),
|
|
964
|
+
company: z15.string().max(100).optional(),
|
|
965
|
+
phone: z15.string().max(20).optional(),
|
|
966
|
+
position: z15.string().max(100).optional(),
|
|
967
|
+
avatar: z15.union([z15.url(), z15.literal("")]).nullable(),
|
|
968
|
+
is_staff: z15.boolean(),
|
|
969
|
+
is_superuser: z15.boolean(),
|
|
970
|
+
date_joined: z15.iso.datetime(),
|
|
971
|
+
last_login: z15.iso.datetime().nullable(),
|
|
972
|
+
unanswered_messages_count: z15.int(),
|
|
950
973
|
centrifugo: CentrifugoTokenSchema.nullable()
|
|
951
974
|
});
|
|
952
975
|
|
|
953
976
|
// src/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts
|
|
954
|
-
var OTPVerifyResponseSchema =
|
|
955
|
-
requires_2fa:
|
|
956
|
-
session_id:
|
|
957
|
-
refresh:
|
|
958
|
-
access:
|
|
977
|
+
var OTPVerifyResponseSchema = z16.object({
|
|
978
|
+
requires_2fa: z16.boolean().optional(),
|
|
979
|
+
session_id: z16.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(),
|
|
980
|
+
refresh: z16.string().nullable().optional(),
|
|
981
|
+
access: z16.string().nullable().optional(),
|
|
959
982
|
user: UserSchema.nullable().optional(),
|
|
960
|
-
should_prompt_2fa:
|
|
983
|
+
should_prompt_2fa: z16.boolean().optional()
|
|
961
984
|
});
|
|
962
985
|
|
|
963
986
|
// src/generated/cfg_accounts/_utils/schemas/PatchedUserProfileUpdateRequest.schema.ts
|
|
964
|
-
import { z as
|
|
965
|
-
var PatchedUserProfileUpdateRequestSchema =
|
|
966
|
-
first_name:
|
|
967
|
-
last_name:
|
|
968
|
-
company:
|
|
969
|
-
phone:
|
|
970
|
-
position:
|
|
987
|
+
import { z as z17 } from "zod";
|
|
988
|
+
var PatchedUserProfileUpdateRequestSchema = z17.object({
|
|
989
|
+
first_name: z17.string().max(50).optional(),
|
|
990
|
+
last_name: z17.string().max(50).optional(),
|
|
991
|
+
company: z17.string().max(100).optional(),
|
|
992
|
+
phone: z17.string().max(20).optional(),
|
|
993
|
+
position: z17.string().max(100).optional()
|
|
971
994
|
});
|
|
972
995
|
|
|
973
996
|
// src/generated/cfg_accounts/_utils/schemas/TokenRefresh.schema.ts
|
|
974
|
-
import { z as
|
|
975
|
-
var TokenRefreshSchema =
|
|
976
|
-
access:
|
|
977
|
-
refresh:
|
|
997
|
+
import { z as z18 } from "zod";
|
|
998
|
+
var TokenRefreshSchema = z18.object({
|
|
999
|
+
access: z18.string(),
|
|
1000
|
+
refresh: z18.string()
|
|
978
1001
|
});
|
|
979
1002
|
|
|
980
1003
|
// src/generated/cfg_accounts/_utils/schemas/TokenRefreshRequest.schema.ts
|
|
981
|
-
import { z as
|
|
982
|
-
var TokenRefreshRequestSchema =
|
|
983
|
-
refresh:
|
|
1004
|
+
import { z as z19 } from "zod";
|
|
1005
|
+
var TokenRefreshRequestSchema = z19.object({
|
|
1006
|
+
refresh: z19.string().min(1)
|
|
984
1007
|
});
|
|
985
1008
|
|
|
986
1009
|
// src/generated/cfg_accounts/_utils/schemas/UserProfileUpdateRequest.schema.ts
|
|
987
|
-
import { z as
|
|
988
|
-
var UserProfileUpdateRequestSchema =
|
|
989
|
-
first_name:
|
|
990
|
-
last_name:
|
|
991
|
-
company:
|
|
992
|
-
phone:
|
|
993
|
-
position:
|
|
1010
|
+
import { z as z20 } from "zod";
|
|
1011
|
+
var UserProfileUpdateRequestSchema = z20.object({
|
|
1012
|
+
first_name: z20.string().max(50).optional(),
|
|
1013
|
+
last_name: z20.string().max(50).optional(),
|
|
1014
|
+
company: z20.string().max(100).optional(),
|
|
1015
|
+
phone: z20.string().max(20).optional(),
|
|
1016
|
+
position: z20.string().max(100).optional()
|
|
994
1017
|
});
|
|
995
1018
|
|
|
996
1019
|
// src/generated/cfg_accounts/_utils/fetchers/accounts.ts
|
|
@@ -1347,7 +1370,8 @@ var API = class {
|
|
|
1347
1370
|
this._loadTokensFromStorage();
|
|
1348
1371
|
this._client = new APIClient(this.baseUrl, {
|
|
1349
1372
|
retryConfig: this.options?.retryConfig,
|
|
1350
|
-
loggerConfig: this.options?.loggerConfig
|
|
1373
|
+
loggerConfig: this.options?.loggerConfig,
|
|
1374
|
+
tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
|
|
1351
1375
|
});
|
|
1352
1376
|
this._injectAuthHeader();
|
|
1353
1377
|
this.auth = this._client.auth;
|
|
@@ -1365,7 +1389,8 @@ var API = class {
|
|
|
1365
1389
|
_reinitClients() {
|
|
1366
1390
|
this._client = new APIClient(this.baseUrl, {
|
|
1367
1391
|
retryConfig: this.options?.retryConfig,
|
|
1368
|
-
loggerConfig: this.options?.loggerConfig
|
|
1392
|
+
loggerConfig: this.options?.loggerConfig,
|
|
1393
|
+
tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
|
|
1369
1394
|
});
|
|
1370
1395
|
this._injectAuthHeader();
|
|
1371
1396
|
this.auth = this._client.auth;
|
|
@@ -2036,8 +2061,10 @@ var APIClient2 = class {
|
|
|
2036
2061
|
constructor(baseUrl, options) {
|
|
2037
2062
|
this.logger = null;
|
|
2038
2063
|
this.retryConfig = null;
|
|
2064
|
+
this.tokenGetter = null;
|
|
2039
2065
|
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
2040
2066
|
this.httpClient = options?.httpClient || new FetchAdapter2();
|
|
2067
|
+
this.tokenGetter = options?.tokenGetter || null;
|
|
2041
2068
|
if (options?.loggerConfig !== void 0) {
|
|
2042
2069
|
this.logger = new APILogger2(options.loggerConfig);
|
|
2043
2070
|
}
|
|
@@ -2066,6 +2093,19 @@ var APIClient2 = class {
|
|
|
2066
2093
|
}
|
|
2067
2094
|
return null;
|
|
2068
2095
|
}
|
|
2096
|
+
/**
|
|
2097
|
+
* Get the base URL for building streaming/download URLs.
|
|
2098
|
+
*/
|
|
2099
|
+
getBaseUrl() {
|
|
2100
|
+
return this.baseUrl;
|
|
2101
|
+
}
|
|
2102
|
+
/**
|
|
2103
|
+
* Get JWT token for URL authentication (used in streaming endpoints).
|
|
2104
|
+
* Returns null if no token getter is configured or no token is available.
|
|
2105
|
+
*/
|
|
2106
|
+
getToken() {
|
|
2107
|
+
return this.tokenGetter ? this.tokenGetter() : null;
|
|
2108
|
+
}
|
|
2069
2109
|
/**
|
|
2070
2110
|
* Make HTTP request with Django CSRF and session handling.
|
|
2071
2111
|
* Automatically retries on network errors and 5xx server errors.
|
|
@@ -2278,320 +2318,320 @@ var LocalStorageAdapter2 = class {
|
|
|
2278
2318
|
};
|
|
2279
2319
|
|
|
2280
2320
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoChannelInfo.schema.ts
|
|
2281
|
-
import { z as
|
|
2282
|
-
var CentrifugoChannelInfoSchema =
|
|
2283
|
-
num_clients:
|
|
2321
|
+
import { z as z21 } from "zod";
|
|
2322
|
+
var CentrifugoChannelInfoSchema = z21.object({
|
|
2323
|
+
num_clients: z21.int()
|
|
2284
2324
|
});
|
|
2285
2325
|
|
|
2286
2326
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoChannelsRequestRequest.schema.ts
|
|
2287
|
-
import { z as
|
|
2288
|
-
var CentrifugoChannelsRequestRequestSchema =
|
|
2289
|
-
pattern:
|
|
2327
|
+
import { z as z22 } from "zod";
|
|
2328
|
+
var CentrifugoChannelsRequestRequestSchema = z22.object({
|
|
2329
|
+
pattern: z22.string().nullable().optional()
|
|
2290
2330
|
});
|
|
2291
2331
|
|
|
2292
2332
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoChannelsResponse.schema.ts
|
|
2293
|
-
import { z as
|
|
2333
|
+
import { z as z25 } from "zod";
|
|
2294
2334
|
|
|
2295
2335
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoChannelsResult.schema.ts
|
|
2296
|
-
import { z as
|
|
2297
|
-
var CentrifugoChannelsResultSchema =
|
|
2298
|
-
channels:
|
|
2336
|
+
import { z as z23 } from "zod";
|
|
2337
|
+
var CentrifugoChannelsResultSchema = z23.object({
|
|
2338
|
+
channels: z23.record(z23.string(), CentrifugoChannelInfoSchema)
|
|
2299
2339
|
});
|
|
2300
2340
|
|
|
2301
2341
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoError.schema.ts
|
|
2302
|
-
import { z as
|
|
2303
|
-
var CentrifugoErrorSchema =
|
|
2304
|
-
code:
|
|
2305
|
-
message:
|
|
2342
|
+
import { z as z24 } from "zod";
|
|
2343
|
+
var CentrifugoErrorSchema = z24.object({
|
|
2344
|
+
code: z24.int().optional(),
|
|
2345
|
+
message: z24.string().optional()
|
|
2306
2346
|
});
|
|
2307
2347
|
|
|
2308
2348
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoChannelsResponse.schema.ts
|
|
2309
|
-
var CentrifugoChannelsResponseSchema =
|
|
2349
|
+
var CentrifugoChannelsResponseSchema = z25.object({
|
|
2310
2350
|
error: CentrifugoErrorSchema.optional(),
|
|
2311
2351
|
result: CentrifugoChannelsResultSchema.optional()
|
|
2312
2352
|
});
|
|
2313
2353
|
|
|
2314
2354
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoClientInfo.schema.ts
|
|
2315
|
-
import { z as
|
|
2316
|
-
var CentrifugoClientInfoSchema =
|
|
2317
|
-
user:
|
|
2318
|
-
client:
|
|
2319
|
-
conn_info:
|
|
2320
|
-
chan_info:
|
|
2355
|
+
import { z as z26 } from "zod";
|
|
2356
|
+
var CentrifugoClientInfoSchema = z26.object({
|
|
2357
|
+
user: z26.string(),
|
|
2358
|
+
client: z26.string(),
|
|
2359
|
+
conn_info: z26.record(z26.string(), z26.any()).nullable().optional(),
|
|
2360
|
+
chan_info: z26.record(z26.string(), z26.any()).nullable().optional()
|
|
2321
2361
|
});
|
|
2322
2362
|
|
|
2323
2363
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoHealthCheck.schema.ts
|
|
2324
|
-
import { z as
|
|
2325
|
-
var CentrifugoHealthCheckSchema =
|
|
2326
|
-
status:
|
|
2327
|
-
wrapper_url:
|
|
2328
|
-
has_api_key:
|
|
2329
|
-
timestamp:
|
|
2364
|
+
import { z as z27 } from "zod";
|
|
2365
|
+
var CentrifugoHealthCheckSchema = z27.object({
|
|
2366
|
+
status: z27.string(),
|
|
2367
|
+
wrapper_url: z27.string(),
|
|
2368
|
+
has_api_key: z27.boolean(),
|
|
2369
|
+
timestamp: z27.string()
|
|
2330
2370
|
});
|
|
2331
2371
|
|
|
2332
2372
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoHistoryRequestRequest.schema.ts
|
|
2333
|
-
import { z as
|
|
2373
|
+
import { z as z29 } from "zod";
|
|
2334
2374
|
|
|
2335
2375
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoStreamPosition.schema.ts
|
|
2336
|
-
import { z as
|
|
2337
|
-
var CentrifugoStreamPositionSchema =
|
|
2338
|
-
offset:
|
|
2339
|
-
epoch:
|
|
2376
|
+
import { z as z28 } from "zod";
|
|
2377
|
+
var CentrifugoStreamPositionSchema = z28.object({
|
|
2378
|
+
offset: z28.int(),
|
|
2379
|
+
epoch: z28.string()
|
|
2340
2380
|
});
|
|
2341
2381
|
|
|
2342
2382
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoHistoryRequestRequest.schema.ts
|
|
2343
|
-
var CentrifugoHistoryRequestRequestSchema =
|
|
2344
|
-
channel:
|
|
2345
|
-
limit:
|
|
2383
|
+
var CentrifugoHistoryRequestRequestSchema = z29.object({
|
|
2384
|
+
channel: z29.string(),
|
|
2385
|
+
limit: z29.int().nullable().optional(),
|
|
2346
2386
|
since: CentrifugoStreamPositionSchema.optional(),
|
|
2347
|
-
reverse:
|
|
2387
|
+
reverse: z29.boolean().nullable().optional()
|
|
2348
2388
|
});
|
|
2349
2389
|
|
|
2350
2390
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoHistoryResponse.schema.ts
|
|
2351
|
-
import { z as
|
|
2391
|
+
import { z as z32 } from "zod";
|
|
2352
2392
|
|
|
2353
2393
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoHistoryResult.schema.ts
|
|
2354
|
-
import { z as
|
|
2394
|
+
import { z as z31 } from "zod";
|
|
2355
2395
|
|
|
2356
2396
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoPublication.schema.ts
|
|
2357
|
-
import { z as
|
|
2358
|
-
var CentrifugoPublicationSchema =
|
|
2359
|
-
data:
|
|
2397
|
+
import { z as z30 } from "zod";
|
|
2398
|
+
var CentrifugoPublicationSchema = z30.object({
|
|
2399
|
+
data: z30.record(z30.string(), z30.any()),
|
|
2360
2400
|
info: CentrifugoClientInfoSchema.optional(),
|
|
2361
|
-
offset:
|
|
2362
|
-
tags:
|
|
2401
|
+
offset: z30.int(),
|
|
2402
|
+
tags: z30.record(z30.string(), z30.any()).nullable().optional()
|
|
2363
2403
|
});
|
|
2364
2404
|
|
|
2365
2405
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoHistoryResult.schema.ts
|
|
2366
|
-
var CentrifugoHistoryResultSchema =
|
|
2367
|
-
publications:
|
|
2368
|
-
epoch:
|
|
2369
|
-
offset:
|
|
2406
|
+
var CentrifugoHistoryResultSchema = z31.object({
|
|
2407
|
+
publications: z31.array(CentrifugoPublicationSchema),
|
|
2408
|
+
epoch: z31.string(),
|
|
2409
|
+
offset: z31.int()
|
|
2370
2410
|
});
|
|
2371
2411
|
|
|
2372
2412
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoHistoryResponse.schema.ts
|
|
2373
|
-
var CentrifugoHistoryResponseSchema =
|
|
2413
|
+
var CentrifugoHistoryResponseSchema = z32.object({
|
|
2374
2414
|
error: CentrifugoErrorSchema.optional(),
|
|
2375
2415
|
result: CentrifugoHistoryResultSchema.optional()
|
|
2376
2416
|
});
|
|
2377
2417
|
|
|
2378
2418
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoInfoResponse.schema.ts
|
|
2379
|
-
import { z as
|
|
2419
|
+
import { z as z37 } from "zod";
|
|
2380
2420
|
|
|
2381
2421
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoInfoResult.schema.ts
|
|
2382
|
-
import { z as
|
|
2422
|
+
import { z as z36 } from "zod";
|
|
2383
2423
|
|
|
2384
2424
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoNodeInfo.schema.ts
|
|
2385
|
-
import { z as
|
|
2425
|
+
import { z as z35 } from "zod";
|
|
2386
2426
|
|
|
2387
2427
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoMetrics.schema.ts
|
|
2388
|
-
import { z as
|
|
2389
|
-
var CentrifugoMetricsSchema =
|
|
2390
|
-
interval:
|
|
2391
|
-
items:
|
|
2428
|
+
import { z as z33 } from "zod";
|
|
2429
|
+
var CentrifugoMetricsSchema = z33.object({
|
|
2430
|
+
interval: z33.number(),
|
|
2431
|
+
items: z33.record(z33.string(), z33.number())
|
|
2392
2432
|
});
|
|
2393
2433
|
|
|
2394
2434
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoProcess.schema.ts
|
|
2395
|
-
import { z as
|
|
2396
|
-
var CentrifugoProcessSchema =
|
|
2397
|
-
cpu:
|
|
2398
|
-
rss:
|
|
2435
|
+
import { z as z34 } from "zod";
|
|
2436
|
+
var CentrifugoProcessSchema = z34.object({
|
|
2437
|
+
cpu: z34.number(),
|
|
2438
|
+
rss: z34.int()
|
|
2399
2439
|
});
|
|
2400
2440
|
|
|
2401
2441
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoNodeInfo.schema.ts
|
|
2402
|
-
var CentrifugoNodeInfoSchema =
|
|
2403
|
-
uid:
|
|
2404
|
-
name:
|
|
2405
|
-
version:
|
|
2406
|
-
num_clients:
|
|
2407
|
-
num_users:
|
|
2408
|
-
num_channels:
|
|
2409
|
-
uptime:
|
|
2410
|
-
num_subs:
|
|
2442
|
+
var CentrifugoNodeInfoSchema = z35.object({
|
|
2443
|
+
uid: z35.string(),
|
|
2444
|
+
name: z35.string(),
|
|
2445
|
+
version: z35.string(),
|
|
2446
|
+
num_clients: z35.int(),
|
|
2447
|
+
num_users: z35.int(),
|
|
2448
|
+
num_channels: z35.int(),
|
|
2449
|
+
uptime: z35.int(),
|
|
2450
|
+
num_subs: z35.int(),
|
|
2411
2451
|
metrics: CentrifugoMetricsSchema.optional(),
|
|
2412
2452
|
process: CentrifugoProcessSchema.optional()
|
|
2413
2453
|
});
|
|
2414
2454
|
|
|
2415
2455
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoInfoResult.schema.ts
|
|
2416
|
-
var CentrifugoInfoResultSchema =
|
|
2417
|
-
nodes:
|
|
2456
|
+
var CentrifugoInfoResultSchema = z36.object({
|
|
2457
|
+
nodes: z36.array(CentrifugoNodeInfoSchema)
|
|
2418
2458
|
});
|
|
2419
2459
|
|
|
2420
2460
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoInfoResponse.schema.ts
|
|
2421
|
-
var CentrifugoInfoResponseSchema =
|
|
2461
|
+
var CentrifugoInfoResponseSchema = z37.object({
|
|
2422
2462
|
error: CentrifugoErrorSchema.optional(),
|
|
2423
2463
|
result: CentrifugoInfoResultSchema.optional()
|
|
2424
2464
|
});
|
|
2425
2465
|
|
|
2426
2466
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoOverviewStats.schema.ts
|
|
2427
|
-
import { z as
|
|
2428
|
-
var CentrifugoOverviewStatsSchema =
|
|
2429
|
-
total:
|
|
2430
|
-
successful:
|
|
2431
|
-
failed:
|
|
2432
|
-
timeout:
|
|
2433
|
-
success_rate:
|
|
2434
|
-
avg_duration_ms:
|
|
2435
|
-
avg_acks_received:
|
|
2436
|
-
period_hours:
|
|
2467
|
+
import { z as z38 } from "zod";
|
|
2468
|
+
var CentrifugoOverviewStatsSchema = z38.object({
|
|
2469
|
+
total: z38.int(),
|
|
2470
|
+
successful: z38.int(),
|
|
2471
|
+
failed: z38.int(),
|
|
2472
|
+
timeout: z38.int(),
|
|
2473
|
+
success_rate: z38.number(),
|
|
2474
|
+
avg_duration_ms: z38.number(),
|
|
2475
|
+
avg_acks_received: z38.number(),
|
|
2476
|
+
period_hours: z38.int()
|
|
2437
2477
|
});
|
|
2438
2478
|
|
|
2439
2479
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoPresenceRequestRequest.schema.ts
|
|
2440
|
-
import { z as
|
|
2441
|
-
var CentrifugoPresenceRequestRequestSchema =
|
|
2442
|
-
channel:
|
|
2480
|
+
import { z as z39 } from "zod";
|
|
2481
|
+
var CentrifugoPresenceRequestRequestSchema = z39.object({
|
|
2482
|
+
channel: z39.string()
|
|
2443
2483
|
});
|
|
2444
2484
|
|
|
2445
2485
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoPresenceResponse.schema.ts
|
|
2446
|
-
import { z as
|
|
2486
|
+
import { z as z41 } from "zod";
|
|
2447
2487
|
|
|
2448
2488
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoPresenceResult.schema.ts
|
|
2449
|
-
import { z as
|
|
2450
|
-
var CentrifugoPresenceResultSchema =
|
|
2451
|
-
presence:
|
|
2489
|
+
import { z as z40 } from "zod";
|
|
2490
|
+
var CentrifugoPresenceResultSchema = z40.object({
|
|
2491
|
+
presence: z40.record(z40.string(), CentrifugoClientInfoSchema)
|
|
2452
2492
|
});
|
|
2453
2493
|
|
|
2454
2494
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoPresenceResponse.schema.ts
|
|
2455
|
-
var CentrifugoPresenceResponseSchema =
|
|
2495
|
+
var CentrifugoPresenceResponseSchema = z41.object({
|
|
2456
2496
|
error: CentrifugoErrorSchema.optional(),
|
|
2457
2497
|
result: CentrifugoPresenceResultSchema.optional()
|
|
2458
2498
|
});
|
|
2459
2499
|
|
|
2460
2500
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoPresenceStatsRequestRequest.schema.ts
|
|
2461
|
-
import { z as
|
|
2462
|
-
var CentrifugoPresenceStatsRequestRequestSchema =
|
|
2463
|
-
channel:
|
|
2501
|
+
import { z as z42 } from "zod";
|
|
2502
|
+
var CentrifugoPresenceStatsRequestRequestSchema = z42.object({
|
|
2503
|
+
channel: z42.string()
|
|
2464
2504
|
});
|
|
2465
2505
|
|
|
2466
2506
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoPresenceStatsResponse.schema.ts
|
|
2467
|
-
import { z as
|
|
2507
|
+
import { z as z44 } from "zod";
|
|
2468
2508
|
|
|
2469
2509
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoPresenceStatsResult.schema.ts
|
|
2470
|
-
import { z as
|
|
2471
|
-
var CentrifugoPresenceStatsResultSchema =
|
|
2472
|
-
num_clients:
|
|
2473
|
-
num_users:
|
|
2510
|
+
import { z as z43 } from "zod";
|
|
2511
|
+
var CentrifugoPresenceStatsResultSchema = z43.object({
|
|
2512
|
+
num_clients: z43.int(),
|
|
2513
|
+
num_users: z43.int()
|
|
2474
2514
|
});
|
|
2475
2515
|
|
|
2476
2516
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoPresenceStatsResponse.schema.ts
|
|
2477
|
-
var CentrifugoPresenceStatsResponseSchema =
|
|
2517
|
+
var CentrifugoPresenceStatsResponseSchema = z44.object({
|
|
2478
2518
|
error: CentrifugoErrorSchema.optional(),
|
|
2479
2519
|
result: CentrifugoPresenceStatsResultSchema.optional()
|
|
2480
2520
|
});
|
|
2481
2521
|
|
|
2482
2522
|
// src/generated/cfg_centrifugo/_utils/schemas/ChannelList.schema.ts
|
|
2483
|
-
import { z as
|
|
2523
|
+
import { z as z46 } from "zod";
|
|
2484
2524
|
|
|
2485
2525
|
// src/generated/cfg_centrifugo/_utils/schemas/ChannelStats.schema.ts
|
|
2486
|
-
import { z as
|
|
2487
|
-
var ChannelStatsSchema =
|
|
2488
|
-
channel:
|
|
2489
|
-
total:
|
|
2490
|
-
successful:
|
|
2491
|
-
failed:
|
|
2492
|
-
avg_duration_ms:
|
|
2493
|
-
avg_acks:
|
|
2494
|
-
last_activity_at:
|
|
2526
|
+
import { z as z45 } from "zod";
|
|
2527
|
+
var ChannelStatsSchema = z45.object({
|
|
2528
|
+
channel: z45.string(),
|
|
2529
|
+
total: z45.int(),
|
|
2530
|
+
successful: z45.int(),
|
|
2531
|
+
failed: z45.int(),
|
|
2532
|
+
avg_duration_ms: z45.number(),
|
|
2533
|
+
avg_acks: z45.number(),
|
|
2534
|
+
last_activity_at: z45.string().nullable()
|
|
2495
2535
|
});
|
|
2496
2536
|
|
|
2497
2537
|
// src/generated/cfg_centrifugo/_utils/schemas/ChannelList.schema.ts
|
|
2498
|
-
var ChannelListSchema =
|
|
2499
|
-
channels:
|
|
2500
|
-
total_channels:
|
|
2538
|
+
var ChannelListSchema = z46.object({
|
|
2539
|
+
channels: z46.array(ChannelStatsSchema),
|
|
2540
|
+
total_channels: z46.int()
|
|
2501
2541
|
});
|
|
2502
2542
|
|
|
2503
2543
|
// src/generated/cfg_centrifugo/_utils/schemas/ConnectionTokenResponse.schema.ts
|
|
2504
|
-
import { z as
|
|
2505
|
-
var ConnectionTokenResponseSchema =
|
|
2506
|
-
token:
|
|
2507
|
-
centrifugo_url:
|
|
2508
|
-
expires_at:
|
|
2509
|
-
channels:
|
|
2544
|
+
import { z as z47 } from "zod";
|
|
2545
|
+
var ConnectionTokenResponseSchema = z47.object({
|
|
2546
|
+
token: z47.string(),
|
|
2547
|
+
centrifugo_url: z47.string(),
|
|
2548
|
+
expires_at: z47.string(),
|
|
2549
|
+
channels: z47.array(z47.string())
|
|
2510
2550
|
});
|
|
2511
2551
|
|
|
2512
2552
|
// src/generated/cfg_centrifugo/_utils/schemas/ManualAckRequestRequest.schema.ts
|
|
2513
|
-
import { z as
|
|
2514
|
-
var ManualAckRequestRequestSchema =
|
|
2515
|
-
message_id:
|
|
2516
|
-
client_id:
|
|
2553
|
+
import { z as z48 } from "zod";
|
|
2554
|
+
var ManualAckRequestRequestSchema = z48.object({
|
|
2555
|
+
message_id: z48.string(),
|
|
2556
|
+
client_id: z48.string()
|
|
2517
2557
|
});
|
|
2518
2558
|
|
|
2519
2559
|
// src/generated/cfg_centrifugo/_utils/schemas/ManualAckResponse.schema.ts
|
|
2520
|
-
import { z as
|
|
2521
|
-
var ManualAckResponseSchema =
|
|
2522
|
-
success:
|
|
2523
|
-
message_id:
|
|
2524
|
-
error:
|
|
2560
|
+
import { z as z49 } from "zod";
|
|
2561
|
+
var ManualAckResponseSchema = z49.object({
|
|
2562
|
+
success: z49.boolean(),
|
|
2563
|
+
message_id: z49.string(),
|
|
2564
|
+
error: z49.string().nullable().optional()
|
|
2525
2565
|
});
|
|
2526
2566
|
|
|
2527
2567
|
// src/generated/cfg_centrifugo/_utils/schemas/PaginatedPublishList.schema.ts
|
|
2528
|
-
import { z as
|
|
2568
|
+
import { z as z51 } from "zod";
|
|
2529
2569
|
|
|
2530
2570
|
// src/generated/cfg_centrifugo/_utils/schemas/Publish.schema.ts
|
|
2531
|
-
import { z as
|
|
2532
|
-
var PublishSchema =
|
|
2533
|
-
message_id:
|
|
2534
|
-
channel:
|
|
2535
|
-
status:
|
|
2536
|
-
wait_for_ack:
|
|
2537
|
-
acks_received:
|
|
2538
|
-
acks_expected:
|
|
2539
|
-
duration_ms:
|
|
2540
|
-
created_at:
|
|
2541
|
-
completed_at:
|
|
2542
|
-
error_code:
|
|
2543
|
-
error_message:
|
|
2571
|
+
import { z as z50 } from "zod";
|
|
2572
|
+
var PublishSchema = z50.object({
|
|
2573
|
+
message_id: z50.string(),
|
|
2574
|
+
channel: z50.string(),
|
|
2575
|
+
status: z50.string(),
|
|
2576
|
+
wait_for_ack: z50.boolean(),
|
|
2577
|
+
acks_received: z50.int(),
|
|
2578
|
+
acks_expected: z50.int().nullable(),
|
|
2579
|
+
duration_ms: z50.number().nullable(),
|
|
2580
|
+
created_at: z50.iso.datetime(),
|
|
2581
|
+
completed_at: z50.iso.datetime().nullable(),
|
|
2582
|
+
error_code: z50.string().nullable(),
|
|
2583
|
+
error_message: z50.string().nullable()
|
|
2544
2584
|
});
|
|
2545
2585
|
|
|
2546
2586
|
// src/generated/cfg_centrifugo/_utils/schemas/PaginatedPublishList.schema.ts
|
|
2547
|
-
var PaginatedPublishListSchema =
|
|
2548
|
-
count:
|
|
2549
|
-
page:
|
|
2550
|
-
pages:
|
|
2551
|
-
page_size:
|
|
2552
|
-
has_next:
|
|
2553
|
-
has_previous:
|
|
2554
|
-
next_page:
|
|
2555
|
-
previous_page:
|
|
2556
|
-
results:
|
|
2587
|
+
var PaginatedPublishListSchema = z51.object({
|
|
2588
|
+
count: z51.int(),
|
|
2589
|
+
page: z51.int(),
|
|
2590
|
+
pages: z51.int(),
|
|
2591
|
+
page_size: z51.int(),
|
|
2592
|
+
has_next: z51.boolean(),
|
|
2593
|
+
has_previous: z51.boolean(),
|
|
2594
|
+
next_page: z51.int().nullable().optional(),
|
|
2595
|
+
previous_page: z51.int().nullable().optional(),
|
|
2596
|
+
results: z51.array(PublishSchema)
|
|
2557
2597
|
});
|
|
2558
2598
|
|
|
2559
2599
|
// src/generated/cfg_centrifugo/_utils/schemas/PublishTestRequestRequest.schema.ts
|
|
2560
|
-
import { z as
|
|
2561
|
-
var PublishTestRequestRequestSchema =
|
|
2562
|
-
channel:
|
|
2563
|
-
data:
|
|
2564
|
-
wait_for_ack:
|
|
2565
|
-
ack_timeout:
|
|
2600
|
+
import { z as z52 } from "zod";
|
|
2601
|
+
var PublishTestRequestRequestSchema = z52.object({
|
|
2602
|
+
channel: z52.string(),
|
|
2603
|
+
data: z52.record(z52.string(), z52.any()),
|
|
2604
|
+
wait_for_ack: z52.boolean().optional(),
|
|
2605
|
+
ack_timeout: z52.int().min(1).max(60).optional()
|
|
2566
2606
|
});
|
|
2567
2607
|
|
|
2568
2608
|
// src/generated/cfg_centrifugo/_utils/schemas/PublishTestResponse.schema.ts
|
|
2569
|
-
import { z as
|
|
2570
|
-
var PublishTestResponseSchema =
|
|
2571
|
-
success:
|
|
2572
|
-
message_id:
|
|
2573
|
-
channel:
|
|
2574
|
-
acks_received:
|
|
2575
|
-
delivered:
|
|
2576
|
-
error:
|
|
2609
|
+
import { z as z53 } from "zod";
|
|
2610
|
+
var PublishTestResponseSchema = z53.object({
|
|
2611
|
+
success: z53.boolean(),
|
|
2612
|
+
message_id: z53.string(),
|
|
2613
|
+
channel: z53.string(),
|
|
2614
|
+
acks_received: z53.int().optional(),
|
|
2615
|
+
delivered: z53.boolean().optional(),
|
|
2616
|
+
error: z53.string().nullable().optional()
|
|
2577
2617
|
});
|
|
2578
2618
|
|
|
2579
2619
|
// src/generated/cfg_centrifugo/_utils/schemas/TimelineItem.schema.ts
|
|
2580
|
-
import { z as
|
|
2581
|
-
var TimelineItemSchema =
|
|
2582
|
-
timestamp:
|
|
2583
|
-
count:
|
|
2584
|
-
successful:
|
|
2585
|
-
failed:
|
|
2586
|
-
timeout:
|
|
2620
|
+
import { z as z54 } from "zod";
|
|
2621
|
+
var TimelineItemSchema = z54.object({
|
|
2622
|
+
timestamp: z54.string(),
|
|
2623
|
+
count: z54.int(),
|
|
2624
|
+
successful: z54.int(),
|
|
2625
|
+
failed: z54.int(),
|
|
2626
|
+
timeout: z54.int()
|
|
2587
2627
|
});
|
|
2588
2628
|
|
|
2589
2629
|
// src/generated/cfg_centrifugo/_utils/schemas/TimelineResponse.schema.ts
|
|
2590
|
-
import { z as
|
|
2591
|
-
var TimelineResponseSchema =
|
|
2592
|
-
timeline:
|
|
2593
|
-
period_hours:
|
|
2594
|
-
interval:
|
|
2630
|
+
import { z as z55 } from "zod";
|
|
2631
|
+
var TimelineResponseSchema = z55.object({
|
|
2632
|
+
timeline: z55.array(TimelineItemSchema),
|
|
2633
|
+
period_hours: z55.int(),
|
|
2634
|
+
interval: z55.string()
|
|
2595
2635
|
});
|
|
2596
2636
|
|
|
2597
2637
|
// src/generated/cfg_centrifugo/_utils/fetchers/centrifugo__centrifugo_admin_api.ts
|
|
@@ -2620,7 +2660,8 @@ var API2 = class {
|
|
|
2620
2660
|
this._loadTokensFromStorage();
|
|
2621
2661
|
this._client = new APIClient2(this.baseUrl, {
|
|
2622
2662
|
retryConfig: this.options?.retryConfig,
|
|
2623
|
-
loggerConfig: this.options?.loggerConfig
|
|
2663
|
+
loggerConfig: this.options?.loggerConfig,
|
|
2664
|
+
tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
|
|
2624
2665
|
});
|
|
2625
2666
|
this._injectAuthHeader();
|
|
2626
2667
|
this.centrifugo_admin_api = this._client.centrifugo_admin_api;
|
|
@@ -2638,7 +2679,8 @@ var API2 = class {
|
|
|
2638
2679
|
_reinitClients() {
|
|
2639
2680
|
this._client = new APIClient2(this.baseUrl, {
|
|
2640
2681
|
retryConfig: this.options?.retryConfig,
|
|
2641
|
-
loggerConfig: this.options?.loggerConfig
|
|
2682
|
+
loggerConfig: this.options?.loggerConfig,
|
|
2683
|
+
tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
|
|
2642
2684
|
});
|
|
2643
2685
|
this._injectAuthHeader();
|
|
2644
2686
|
this.centrifugo_admin_api = this._client.centrifugo_admin_api;
|
|
@@ -3137,8 +3179,10 @@ var APIClient3 = class {
|
|
|
3137
3179
|
constructor(baseUrl, options) {
|
|
3138
3180
|
this.logger = null;
|
|
3139
3181
|
this.retryConfig = null;
|
|
3182
|
+
this.tokenGetter = null;
|
|
3140
3183
|
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
3141
3184
|
this.httpClient = options?.httpClient || new FetchAdapter3();
|
|
3185
|
+
this.tokenGetter = options?.tokenGetter || null;
|
|
3142
3186
|
if (options?.loggerConfig !== void 0) {
|
|
3143
3187
|
this.logger = new APILogger3(options.loggerConfig);
|
|
3144
3188
|
}
|
|
@@ -3164,6 +3208,19 @@ var APIClient3 = class {
|
|
|
3164
3208
|
}
|
|
3165
3209
|
return null;
|
|
3166
3210
|
}
|
|
3211
|
+
/**
|
|
3212
|
+
* Get the base URL for building streaming/download URLs.
|
|
3213
|
+
*/
|
|
3214
|
+
getBaseUrl() {
|
|
3215
|
+
return this.baseUrl;
|
|
3216
|
+
}
|
|
3217
|
+
/**
|
|
3218
|
+
* Get JWT token for URL authentication (used in streaming endpoints).
|
|
3219
|
+
* Returns null if no token getter is configured or no token is available.
|
|
3220
|
+
*/
|
|
3221
|
+
getToken() {
|
|
3222
|
+
return this.tokenGetter ? this.tokenGetter() : null;
|
|
3223
|
+
}
|
|
3167
3224
|
/**
|
|
3168
3225
|
* Make HTTP request with Django CSRF and session handling.
|
|
3169
3226
|
* Automatically retries on network errors and 5xx server errors.
|
|
@@ -3376,40 +3433,40 @@ var LocalStorageAdapter3 = class {
|
|
|
3376
3433
|
};
|
|
3377
3434
|
|
|
3378
3435
|
// src/generated/cfg_webpush/_utils/schemas/SendPushRequestRequest.schema.ts
|
|
3379
|
-
import { z as
|
|
3380
|
-
var SendPushRequestRequestSchema =
|
|
3381
|
-
title:
|
|
3382
|
-
body:
|
|
3383
|
-
icon:
|
|
3384
|
-
url:
|
|
3436
|
+
import { z as z56 } from "zod";
|
|
3437
|
+
var SendPushRequestRequestSchema = z56.object({
|
|
3438
|
+
title: z56.string().min(1).max(255),
|
|
3439
|
+
body: z56.string().min(1),
|
|
3440
|
+
icon: z56.union([z56.url(), z56.literal("")]).nullable().optional(),
|
|
3441
|
+
url: z56.union([z56.url(), z56.literal("")]).nullable().optional()
|
|
3385
3442
|
});
|
|
3386
3443
|
|
|
3387
3444
|
// src/generated/cfg_webpush/_utils/schemas/SendPushResponse.schema.ts
|
|
3388
|
-
import { z as
|
|
3389
|
-
var SendPushResponseSchema =
|
|
3390
|
-
success:
|
|
3391
|
-
sent_to:
|
|
3445
|
+
import { z as z57 } from "zod";
|
|
3446
|
+
var SendPushResponseSchema = z57.object({
|
|
3447
|
+
success: z57.boolean(),
|
|
3448
|
+
sent_to: z57.int()
|
|
3392
3449
|
});
|
|
3393
3450
|
|
|
3394
3451
|
// src/generated/cfg_webpush/_utils/schemas/SubscribeRequestRequest.schema.ts
|
|
3395
|
-
import { z as
|
|
3396
|
-
var SubscribeRequestRequestSchema =
|
|
3397
|
-
endpoint:
|
|
3398
|
-
keys:
|
|
3452
|
+
import { z as z58 } from "zod";
|
|
3453
|
+
var SubscribeRequestRequestSchema = z58.object({
|
|
3454
|
+
endpoint: z58.union([z58.url(), z58.literal("")]),
|
|
3455
|
+
keys: z58.record(z58.string(), z58.string().min(1))
|
|
3399
3456
|
});
|
|
3400
3457
|
|
|
3401
3458
|
// src/generated/cfg_webpush/_utils/schemas/SubscribeResponse.schema.ts
|
|
3402
|
-
import { z as
|
|
3403
|
-
var SubscribeResponseSchema =
|
|
3404
|
-
success:
|
|
3405
|
-
subscription_id:
|
|
3406
|
-
created:
|
|
3459
|
+
import { z as z59 } from "zod";
|
|
3460
|
+
var SubscribeResponseSchema = z59.object({
|
|
3461
|
+
success: z59.boolean(),
|
|
3462
|
+
subscription_id: z59.int(),
|
|
3463
|
+
created: z59.boolean()
|
|
3407
3464
|
});
|
|
3408
3465
|
|
|
3409
3466
|
// src/generated/cfg_webpush/_utils/schemas/VapidPublicKeyResponse.schema.ts
|
|
3410
|
-
import { z as
|
|
3411
|
-
var VapidPublicKeyResponseSchema =
|
|
3412
|
-
publicKey:
|
|
3467
|
+
import { z as z60 } from "zod";
|
|
3468
|
+
var VapidPublicKeyResponseSchema = z60.object({
|
|
3469
|
+
publicKey: z60.string()
|
|
3413
3470
|
});
|
|
3414
3471
|
|
|
3415
3472
|
// src/generated/cfg_webpush/_utils/fetchers/webpush__web_push.ts
|
|
@@ -3429,7 +3486,8 @@ var API3 = class {
|
|
|
3429
3486
|
this._loadTokensFromStorage();
|
|
3430
3487
|
this._client = new APIClient3(this.baseUrl, {
|
|
3431
3488
|
retryConfig: this.options?.retryConfig,
|
|
3432
|
-
loggerConfig: this.options?.loggerConfig
|
|
3489
|
+
loggerConfig: this.options?.loggerConfig,
|
|
3490
|
+
tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
|
|
3433
3491
|
});
|
|
3434
3492
|
this._injectAuthHeader();
|
|
3435
3493
|
this.web_push = this._client.web_push;
|
|
@@ -3444,7 +3502,8 @@ var API3 = class {
|
|
|
3444
3502
|
_reinitClients() {
|
|
3445
3503
|
this._client = new APIClient3(this.baseUrl, {
|
|
3446
3504
|
retryConfig: this.options?.retryConfig,
|
|
3447
|
-
loggerConfig: this.options?.loggerConfig
|
|
3505
|
+
loggerConfig: this.options?.loggerConfig,
|
|
3506
|
+
tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
|
|
3448
3507
|
});
|
|
3449
3508
|
this._injectAuthHeader();
|
|
3450
3509
|
this.web_push = this._client.web_push;
|
|
@@ -3618,7 +3677,7 @@ __name(useBase64, "useBase64");
|
|
|
3618
3677
|
// src/auth/hooks/useProfileCache.ts
|
|
3619
3678
|
var CACHE_KEY = "user_profile_cache";
|
|
3620
3679
|
var CACHE_VERSION = 1;
|
|
3621
|
-
var DEFAULT_TTL =
|
|
3680
|
+
var DEFAULT_TTL = 144e5;
|
|
3622
3681
|
function getCachedProfile() {
|
|
3623
3682
|
try {
|
|
3624
3683
|
if (typeof window === "undefined") return null;
|
|
@@ -3904,6 +3963,100 @@ var useAuthRedirectManager = /* @__PURE__ */ __name((options = {}) => {
|
|
|
3904
3963
|
};
|
|
3905
3964
|
}, "useAuthRedirectManager");
|
|
3906
3965
|
|
|
3966
|
+
// src/auth/hooks/useTokenRefresh.ts
|
|
3967
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
3968
|
+
var TOKEN_REFRESH_THRESHOLD_MS = 10 * 60 * 1e3;
|
|
3969
|
+
var CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
3970
|
+
function getTokenExpiry(token) {
|
|
3971
|
+
try {
|
|
3972
|
+
const payload = JSON.parse(atob(token.split(".")[1]));
|
|
3973
|
+
return payload.exp * 1e3;
|
|
3974
|
+
} catch {
|
|
3975
|
+
return null;
|
|
3976
|
+
}
|
|
3977
|
+
}
|
|
3978
|
+
__name(getTokenExpiry, "getTokenExpiry");
|
|
3979
|
+
function isTokenExpiringSoon(token, thresholdMs) {
|
|
3980
|
+
const expiry = getTokenExpiry(token);
|
|
3981
|
+
if (!expiry) return false;
|
|
3982
|
+
const timeUntilExpiry = expiry - Date.now();
|
|
3983
|
+
return timeUntilExpiry < thresholdMs;
|
|
3984
|
+
}
|
|
3985
|
+
__name(isTokenExpiringSoon, "isTokenExpiringSoon");
|
|
3986
|
+
function useTokenRefresh(options = {}) {
|
|
3987
|
+
const { enabled = true, onRefresh, onRefreshError } = options;
|
|
3988
|
+
const isRefreshingRef = useRef(false);
|
|
3989
|
+
const refreshToken = useCallback(async () => {
|
|
3990
|
+
if (isRefreshingRef.current) {
|
|
3991
|
+
authLogger.debug("Token refresh already in progress");
|
|
3992
|
+
return false;
|
|
3993
|
+
}
|
|
3994
|
+
const refreshTokenValue = api.getRefreshToken();
|
|
3995
|
+
if (!refreshTokenValue) {
|
|
3996
|
+
authLogger.warn("No refresh token available");
|
|
3997
|
+
return false;
|
|
3998
|
+
}
|
|
3999
|
+
isRefreshingRef.current = true;
|
|
4000
|
+
authLogger.info("Refreshing token...");
|
|
4001
|
+
try {
|
|
4002
|
+
const result = await api.auth.accountsTokenRefreshCreate({
|
|
4003
|
+
refresh: refreshTokenValue
|
|
4004
|
+
});
|
|
4005
|
+
const newAccessToken = result.access;
|
|
4006
|
+
if (!newAccessToken) {
|
|
4007
|
+
throw new Error("No access token in refresh response");
|
|
4008
|
+
}
|
|
4009
|
+
api.setToken(newAccessToken, refreshTokenValue);
|
|
4010
|
+
authLogger.info("Token refreshed successfully");
|
|
4011
|
+
onRefresh?.(newAccessToken);
|
|
4012
|
+
return true;
|
|
4013
|
+
} catch (error) {
|
|
4014
|
+
authLogger.error("Token refresh error:", error);
|
|
4015
|
+
onRefreshError?.(error instanceof Error ? error : new Error(String(error)));
|
|
4016
|
+
return false;
|
|
4017
|
+
} finally {
|
|
4018
|
+
isRefreshingRef.current = false;
|
|
4019
|
+
}
|
|
4020
|
+
}, [onRefresh, onRefreshError]);
|
|
4021
|
+
const checkAndRefresh = useCallback(async () => {
|
|
4022
|
+
const token = api.getToken();
|
|
4023
|
+
if (!token) return;
|
|
4024
|
+
if (isTokenExpiringSoon(token, TOKEN_REFRESH_THRESHOLD_MS)) {
|
|
4025
|
+
authLogger.info("Token expiring soon, refreshing proactively");
|
|
4026
|
+
await refreshToken();
|
|
4027
|
+
}
|
|
4028
|
+
}, [refreshToken]);
|
|
4029
|
+
useEffect(() => {
|
|
4030
|
+
if (!enabled) return;
|
|
4031
|
+
checkAndRefresh();
|
|
4032
|
+
const intervalId = setInterval(checkAndRefresh, CHECK_INTERVAL_MS);
|
|
4033
|
+
return () => clearInterval(intervalId);
|
|
4034
|
+
}, [enabled, checkAndRefresh]);
|
|
4035
|
+
useEffect(() => {
|
|
4036
|
+
if (!enabled) return;
|
|
4037
|
+
const handleFocus = /* @__PURE__ */ __name(() => {
|
|
4038
|
+
authLogger.debug("Window focused, checking token...");
|
|
4039
|
+
checkAndRefresh();
|
|
4040
|
+
}, "handleFocus");
|
|
4041
|
+
window.addEventListener("focus", handleFocus);
|
|
4042
|
+
return () => window.removeEventListener("focus", handleFocus);
|
|
4043
|
+
}, [enabled, checkAndRefresh]);
|
|
4044
|
+
useEffect(() => {
|
|
4045
|
+
if (!enabled) return;
|
|
4046
|
+
const handleOnline = /* @__PURE__ */ __name(() => {
|
|
4047
|
+
authLogger.info("Network reconnected, checking token...");
|
|
4048
|
+
checkAndRefresh();
|
|
4049
|
+
}, "handleOnline");
|
|
4050
|
+
window.addEventListener("online", handleOnline);
|
|
4051
|
+
return () => window.removeEventListener("online", handleOnline);
|
|
4052
|
+
}, [enabled, checkAndRefresh]);
|
|
4053
|
+
return {
|
|
4054
|
+
refreshToken,
|
|
4055
|
+
checkAndRefresh
|
|
4056
|
+
};
|
|
4057
|
+
}
|
|
4058
|
+
__name(useTokenRefresh, "useTokenRefresh");
|
|
4059
|
+
|
|
3907
4060
|
// src/auth/utils/analytics.ts
|
|
3908
4061
|
var AnalyticsEvent = /* @__PURE__ */ ((AnalyticsEvent2) => {
|
|
3909
4062
|
AnalyticsEvent2["AUTH_OTP_REQUEST"] = "auth_otp_request";
|
|
@@ -3943,10 +4096,10 @@ var Analytics = {
|
|
|
3943
4096
|
// src/auth/context/AccountsContext.tsx
|
|
3944
4097
|
import {
|
|
3945
4098
|
createContext,
|
|
3946
|
-
useCallback,
|
|
4099
|
+
useCallback as useCallback2,
|
|
3947
4100
|
useContext,
|
|
3948
|
-
useEffect,
|
|
3949
|
-
useRef,
|
|
4101
|
+
useEffect as useEffect2,
|
|
4102
|
+
useRef as useRef2,
|
|
3950
4103
|
useState as useState2
|
|
3951
4104
|
} from "react";
|
|
3952
4105
|
|
|
@@ -4028,12 +4181,12 @@ function AccountsProvider({ children }) {
|
|
|
4028
4181
|
});
|
|
4029
4182
|
const [isLoadingProfile, setIsLoadingProfile] = useState2(false);
|
|
4030
4183
|
const [profileError, setProfileError] = useState2(null);
|
|
4031
|
-
const profileRef =
|
|
4032
|
-
const isLoadingRef =
|
|
4033
|
-
|
|
4184
|
+
const profileRef = useRef2(profile);
|
|
4185
|
+
const isLoadingRef = useRef2(false);
|
|
4186
|
+
useEffect2(() => {
|
|
4034
4187
|
profileRef.current = profile;
|
|
4035
4188
|
}, [profile]);
|
|
4036
|
-
|
|
4189
|
+
useEffect2(() => {
|
|
4037
4190
|
isLoadingRef.current = isLoadingProfile;
|
|
4038
4191
|
}, [isLoadingProfile]);
|
|
4039
4192
|
const updateMutation = useUpdateAccountsProfileUpdateUpdate();
|
|
@@ -4042,7 +4195,7 @@ function AccountsProvider({ children }) {
|
|
|
4042
4195
|
const otpRequestMutation = useCreateAccountsOtpRequestCreate();
|
|
4043
4196
|
const otpVerifyMutation = useCreateAccountsOtpVerifyCreate();
|
|
4044
4197
|
const tokenRefreshMutation = useCreateAccountsTokenRefreshCreate();
|
|
4045
|
-
const refreshProfile =
|
|
4198
|
+
const refreshProfile = useCallback2(async (callerId) => {
|
|
4046
4199
|
const currentProfile = profileRef.current;
|
|
4047
4200
|
const currentLoading = isLoadingRef.current;
|
|
4048
4201
|
if (currentProfile && !currentLoading) {
|
|
@@ -4080,8 +4233,8 @@ function AccountsProvider({ children }) {
|
|
|
4080
4233
|
await refreshProfile("AccountsContext.partialUpdateProfile");
|
|
4081
4234
|
return result;
|
|
4082
4235
|
}, "partialUpdateProfile");
|
|
4083
|
-
const uploadAvatar = /* @__PURE__ */ __name(async (
|
|
4084
|
-
const result = await avatarMutation(
|
|
4236
|
+
const uploadAvatar = /* @__PURE__ */ __name(async (avatar) => {
|
|
4237
|
+
const result = await avatarMutation({ avatar }, api);
|
|
4085
4238
|
await refreshProfile("AccountsContext.uploadAvatar");
|
|
4086
4239
|
return result;
|
|
4087
4240
|
}, "uploadAvatar");
|
|
@@ -4108,7 +4261,7 @@ function AccountsProvider({ children }) {
|
|
|
4108
4261
|
}
|
|
4109
4262
|
return result;
|
|
4110
4263
|
}, "refreshToken");
|
|
4111
|
-
const logout =
|
|
4264
|
+
const logout = useCallback2(() => {
|
|
4112
4265
|
api.clearTokens();
|
|
4113
4266
|
setProfile(void 0);
|
|
4114
4267
|
setProfileError(null);
|
|
@@ -4172,32 +4325,45 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4172
4325
|
const queryParams = useQueryParams();
|
|
4173
4326
|
const [storedEmail, setStoredEmail, clearStoredEmail] = useLocalStorage(EMAIL_STORAGE_KEY, null);
|
|
4174
4327
|
const [storedPhone, setStoredPhone, clearStoredPhone] = useLocalStorage(PHONE_STORAGE_KEY, null);
|
|
4328
|
+
useTokenRefresh({
|
|
4329
|
+
enabled: true,
|
|
4330
|
+
onRefresh: /* @__PURE__ */ __name((newToken) => {
|
|
4331
|
+
authLogger.info("Token auto-refreshed successfully");
|
|
4332
|
+
}, "onRefresh"),
|
|
4333
|
+
onRefreshError: /* @__PURE__ */ __name((error) => {
|
|
4334
|
+
authLogger.warn("Token auto-refresh failed:", error.message);
|
|
4335
|
+
}, "onRefreshError")
|
|
4336
|
+
});
|
|
4175
4337
|
const user = accounts.profile;
|
|
4176
|
-
const userRef =
|
|
4177
|
-
const configRef =
|
|
4178
|
-
const isLoadingProfileRef =
|
|
4179
|
-
|
|
4338
|
+
const userRef = useRef3(user);
|
|
4339
|
+
const configRef = useRef3(config);
|
|
4340
|
+
const isLoadingProfileRef = useRef3(false);
|
|
4341
|
+
useEffect3(() => {
|
|
4180
4342
|
userRef.current = user;
|
|
4181
4343
|
}, [user]);
|
|
4182
|
-
|
|
4344
|
+
useEffect3(() => {
|
|
4183
4345
|
configRef.current = config;
|
|
4184
4346
|
}, [config]);
|
|
4185
|
-
const clearAuthState =
|
|
4347
|
+
const clearAuthState = useCallback3((caller) => {
|
|
4186
4348
|
authLogger.info("clearAuthState >> caller", caller);
|
|
4187
4349
|
api.clearTokens();
|
|
4188
4350
|
clearProfileCache();
|
|
4189
4351
|
setInitialized(true);
|
|
4190
4352
|
setIsLoading(false);
|
|
4191
4353
|
}, []);
|
|
4192
|
-
const handleGlobalAuthError =
|
|
4193
|
-
|
|
4194
|
-
|
|
4354
|
+
const handleGlobalAuthError = useCallback3((error, context = "API Request") => {
|
|
4355
|
+
const isAuthError = error?.status === 401 || error?.statusCode === 401 || error?.code === "token_not_valid" || error?.code === "authentication_failed";
|
|
4356
|
+
if (isAuthError) {
|
|
4357
|
+
authLogger.warn(`Authentication error in ${context}, clearing tokens`);
|
|
4195
4358
|
clearAuthState(`globalAuthError:${context}`);
|
|
4196
4359
|
return true;
|
|
4197
4360
|
}
|
|
4361
|
+
if (error?.success === false) {
|
|
4362
|
+
authLogger.warn(`Non-auth error in ${context} (not clearing session):`, error?.message || error);
|
|
4363
|
+
}
|
|
4198
4364
|
return false;
|
|
4199
4365
|
}, [clearAuthState]);
|
|
4200
|
-
const loadCurrentProfile =
|
|
4366
|
+
const loadCurrentProfile = useCallback3(async (callerId) => {
|
|
4201
4367
|
const finalCallerId = callerId || "AuthContext.loadCurrentProfile";
|
|
4202
4368
|
if (isLoadingProfileRef.current) {
|
|
4203
4369
|
authLogger.debug(`Profile loading already in progress, skipping duplicate call from: ${finalCallerId}`);
|
|
@@ -4226,14 +4392,19 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4226
4392
|
setInitialized(true);
|
|
4227
4393
|
} catch (error) {
|
|
4228
4394
|
authLogger.error("Failed to load profile:", error);
|
|
4229
|
-
|
|
4230
|
-
|
|
4395
|
+
const isAuthError = error?.status === 401 || error?.statusCode === 401 || error?.code === "token_not_valid" || error?.code === "authentication_failed";
|
|
4396
|
+
if (isAuthError) {
|
|
4397
|
+
authLogger.warn("Authentication error, clearing session");
|
|
4398
|
+
clearAuthState("loadCurrentProfile:authError");
|
|
4399
|
+
} else {
|
|
4400
|
+
authLogger.warn("Profile load failed but keeping session (non-auth error)");
|
|
4401
|
+
setInitialized(true);
|
|
4231
4402
|
}
|
|
4232
4403
|
} finally {
|
|
4233
4404
|
isLoadingProfileRef.current = false;
|
|
4234
4405
|
}
|
|
4235
4406
|
}, [clearAuthState, handleGlobalAuthError, accounts]);
|
|
4236
|
-
|
|
4407
|
+
useEffect3(() => {
|
|
4237
4408
|
if (initialized) return;
|
|
4238
4409
|
const initializeAuth = /* @__PURE__ */ __name(async () => {
|
|
4239
4410
|
authLogger.info("Initializing auth...");
|
|
@@ -4273,7 +4444,13 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4273
4444
|
await loadCurrentProfile("AuthContext.initializeAuth");
|
|
4274
4445
|
} catch (error) {
|
|
4275
4446
|
authLogger.error("Failed to load profile during initialization:", error);
|
|
4276
|
-
|
|
4447
|
+
const isAuthError = error?.status === 401 || error?.statusCode === 401 || error?.code === "token_not_valid" || error?.code === "authentication_failed";
|
|
4448
|
+
if (isAuthError) {
|
|
4449
|
+
clearAuthState("initializeAuth:authError");
|
|
4450
|
+
} else {
|
|
4451
|
+
authLogger.warn("Init profile load failed but keeping session");
|
|
4452
|
+
setInitialized(true);
|
|
4453
|
+
}
|
|
4277
4454
|
}
|
|
4278
4455
|
setIsLoading(false);
|
|
4279
4456
|
} else {
|
|
@@ -4283,7 +4460,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4283
4460
|
}, "initializeAuth");
|
|
4284
4461
|
initializeAuth();
|
|
4285
4462
|
}, [initialized]);
|
|
4286
|
-
|
|
4463
|
+
useEffect3(() => {
|
|
4287
4464
|
if (!initialized) return;
|
|
4288
4465
|
const isAuthenticated = api.isAuthenticated();
|
|
4289
4466
|
const authRoute = config?.routes?.auth || defaultRoutes.auth;
|
|
@@ -4294,15 +4471,15 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4294
4471
|
router.push(callbackUrl);
|
|
4295
4472
|
}
|
|
4296
4473
|
}, [initialized, pathname, queryParams, config?.routes]);
|
|
4297
|
-
const pushToDefaultCallbackUrl =
|
|
4474
|
+
const pushToDefaultCallbackUrl = useCallback3(() => {
|
|
4298
4475
|
const callbackUrl = config?.routes?.defaultCallback || defaultRoutes.defaultCallback;
|
|
4299
4476
|
router.push(callbackUrl);
|
|
4300
4477
|
}, [config?.routes, router]);
|
|
4301
|
-
const pushToDefaultAuthCallbackUrl =
|
|
4478
|
+
const pushToDefaultAuthCallbackUrl = useCallback3(() => {
|
|
4302
4479
|
const authCallbackUrl = config?.routes?.defaultAuthCallback || defaultRoutes.defaultAuthCallback;
|
|
4303
4480
|
router.push(authCallbackUrl);
|
|
4304
4481
|
}, [config?.routes, router]);
|
|
4305
|
-
const checkAuthAndRedirect =
|
|
4482
|
+
const checkAuthAndRedirect = useCallback3(async () => {
|
|
4306
4483
|
try {
|
|
4307
4484
|
setIsLoading(true);
|
|
4308
4485
|
const isAuthenticated = api.isAuthenticated();
|
|
@@ -4324,7 +4501,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4324
4501
|
setIsLoading(false);
|
|
4325
4502
|
}
|
|
4326
4503
|
}, [loadCurrentProfile, clearAuthState, pushToDefaultCallbackUrl, pushToDefaultAuthCallbackUrl, handleGlobalAuthError]);
|
|
4327
|
-
const requestOTP =
|
|
4504
|
+
const requestOTP = useCallback3(
|
|
4328
4505
|
async (identifier, channel, sourceUrl) => {
|
|
4329
4506
|
api.clearTokens();
|
|
4330
4507
|
try {
|
|
@@ -4352,7 +4529,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4352
4529
|
},
|
|
4353
4530
|
[accounts]
|
|
4354
4531
|
);
|
|
4355
|
-
const verifyOTP =
|
|
4532
|
+
const verifyOTP = useCallback3(
|
|
4356
4533
|
async (identifier, otpCode, channel, sourceUrl, redirectUrl, skipRedirect) => {
|
|
4357
4534
|
try {
|
|
4358
4535
|
const channelValue = channel === "phone" ? enums_exports.OTPVerifyRequestChannel.PHONE : enums_exports.OTPVerifyRequestChannel.EMAIL;
|
|
@@ -4419,7 +4596,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4419
4596
|
},
|
|
4420
4597
|
[setStoredEmail, setStoredPhone, clearStoredEmail, clearStoredPhone, config?.routes?.defaultCallback, accounts, router]
|
|
4421
4598
|
);
|
|
4422
|
-
const refreshToken =
|
|
4599
|
+
const refreshToken = useCallback3(async () => {
|
|
4423
4600
|
try {
|
|
4424
4601
|
const refreshTokenValue = api.getRefreshToken();
|
|
4425
4602
|
if (!refreshTokenValue) {
|
|
@@ -4452,7 +4629,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4452
4629
|
};
|
|
4453
4630
|
}
|
|
4454
4631
|
}, [clearAuthState, accounts]);
|
|
4455
|
-
const logout =
|
|
4632
|
+
const logout = useCallback3(async () => {
|
|
4456
4633
|
const performLogout = /* @__PURE__ */ __name(() => {
|
|
4457
4634
|
Analytics.event("auth_logout" /* AUTH_LOGOUT */, {
|
|
4458
4635
|
category: "auth" /* AUTH */
|
|
@@ -4544,7 +4721,7 @@ var useAuth = /* @__PURE__ */ __name(() => {
|
|
|
4544
4721
|
}, "useAuth");
|
|
4545
4722
|
|
|
4546
4723
|
// src/auth/hooks/useAuthFormState.ts
|
|
4547
|
-
import { useCallback as
|
|
4724
|
+
import { useCallback as useCallback4, useState as useState4 } from "react";
|
|
4548
4725
|
var useAuthFormState = /* @__PURE__ */ __name((initialIdentifier = "", initialChannel = "email") => {
|
|
4549
4726
|
const [identifier, setIdentifier] = useState4(initialIdentifier);
|
|
4550
4727
|
const [channel, setChannel] = useState4(initialChannel);
|
|
@@ -4557,7 +4734,7 @@ var useAuthFormState = /* @__PURE__ */ __name((initialIdentifier = "", initialCh
|
|
|
4557
4734
|
const [shouldPrompt2FA, setShouldPrompt2FA] = useState4(false);
|
|
4558
4735
|
const [twoFactorCode, setTwoFactorCode] = useState4("");
|
|
4559
4736
|
const [useBackupCode, setUseBackupCode] = useState4(false);
|
|
4560
|
-
const clearError =
|
|
4737
|
+
const clearError = useCallback4(() => setError(""), []);
|
|
4561
4738
|
return {
|
|
4562
4739
|
// State
|
|
4563
4740
|
identifier,
|
|
@@ -4588,11 +4765,11 @@ var useAuthFormState = /* @__PURE__ */ __name((initialIdentifier = "", initialCh
|
|
|
4588
4765
|
}, "useAuthFormState");
|
|
4589
4766
|
|
|
4590
4767
|
// src/auth/hooks/useAuthValidation.ts
|
|
4591
|
-
import { useCallback as
|
|
4768
|
+
import { useCallback as useCallback5 } from "react";
|
|
4592
4769
|
var EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
4593
4770
|
var PHONE_REGEX = /^\+[1-9]\d{6,14}$/;
|
|
4594
4771
|
var useAuthValidation = /* @__PURE__ */ __name(() => {
|
|
4595
|
-
const detectChannelFromIdentifier2 =
|
|
4772
|
+
const detectChannelFromIdentifier2 = useCallback5((id) => {
|
|
4596
4773
|
if (!id) return null;
|
|
4597
4774
|
if (id.includes("@")) {
|
|
4598
4775
|
return "email";
|
|
@@ -4602,7 +4779,7 @@ var useAuthValidation = /* @__PURE__ */ __name(() => {
|
|
|
4602
4779
|
}
|
|
4603
4780
|
return null;
|
|
4604
4781
|
}, []);
|
|
4605
|
-
const validateIdentifier2 =
|
|
4782
|
+
const validateIdentifier2 = useCallback5((id, channelType) => {
|
|
4606
4783
|
if (!id) return false;
|
|
4607
4784
|
const channel = channelType || detectChannelFromIdentifier2(id);
|
|
4608
4785
|
if (channel === "email") {
|
|
@@ -4633,11 +4810,11 @@ var validateIdentifier = /* @__PURE__ */ __name((id, channelType) => {
|
|
|
4633
4810
|
}, "validateIdentifier");
|
|
4634
4811
|
|
|
4635
4812
|
// src/auth/hooks/useAuthForm.ts
|
|
4636
|
-
import { useCallback as
|
|
4813
|
+
import { useCallback as useCallback7, useEffect as useEffect5, useRef as useRef4 } from "react";
|
|
4637
4814
|
|
|
4638
4815
|
// src/auth/hooks/useAutoAuth.ts
|
|
4639
4816
|
import { usePathname as usePathname2 } from "next/navigation";
|
|
4640
|
-
import { useEffect as
|
|
4817
|
+
import { useEffect as useEffect4 } from "react";
|
|
4641
4818
|
import { useCfgRouter as useCfgRouter2, useQueryParams as useQueryParams2 } from "@djangocfg/ui-nextjs/hooks";
|
|
4642
4819
|
var useAutoAuth = /* @__PURE__ */ __name((options = {}) => {
|
|
4643
4820
|
const { onOTPDetected, cleanupUrl = true, allowedPaths = ["/auth"] } = options;
|
|
@@ -4647,7 +4824,7 @@ var useAutoAuth = /* @__PURE__ */ __name((options = {}) => {
|
|
|
4647
4824
|
const isAllowedPath = allowedPaths.some((path) => pathname === path || pathname?.startsWith(path + "/"));
|
|
4648
4825
|
const hasOTP = !!queryParams.get("otp");
|
|
4649
4826
|
const isReady = !!pathname && hasOTP && isAllowedPath;
|
|
4650
|
-
|
|
4827
|
+
useEffect4(() => {
|
|
4651
4828
|
if (!isReady) return;
|
|
4652
4829
|
const queryOtp = queryParams.get("otp");
|
|
4653
4830
|
if (queryOtp && typeof queryOtp === "string" && queryOtp.length === 6) {
|
|
@@ -4669,7 +4846,7 @@ var useAutoAuth = /* @__PURE__ */ __name((options = {}) => {
|
|
|
4669
4846
|
}, "useAutoAuth");
|
|
4670
4847
|
|
|
4671
4848
|
// src/auth/hooks/useTwoFactor.ts
|
|
4672
|
-
import { useCallback as
|
|
4849
|
+
import { useCallback as useCallback6, useState as useState5 } from "react";
|
|
4673
4850
|
import { useCfgRouter as useCfgRouter3 } from "@djangocfg/ui-nextjs/hooks";
|
|
4674
4851
|
|
|
4675
4852
|
// src/generated/cfg_totp/totp__backup_codes/client.ts
|
|
@@ -5164,8 +5341,10 @@ var APIClient4 = class {
|
|
|
5164
5341
|
constructor(baseUrl, options) {
|
|
5165
5342
|
this.logger = null;
|
|
5166
5343
|
this.retryConfig = null;
|
|
5344
|
+
this.tokenGetter = null;
|
|
5167
5345
|
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
5168
5346
|
this.httpClient = options?.httpClient || new FetchAdapter4();
|
|
5347
|
+
this.tokenGetter = options?.tokenGetter || null;
|
|
5169
5348
|
if (options?.loggerConfig !== void 0) {
|
|
5170
5349
|
this.logger = new APILogger4(options.loggerConfig);
|
|
5171
5350
|
}
|
|
@@ -5195,6 +5374,19 @@ var APIClient4 = class {
|
|
|
5195
5374
|
}
|
|
5196
5375
|
return null;
|
|
5197
5376
|
}
|
|
5377
|
+
/**
|
|
5378
|
+
* Get the base URL for building streaming/download URLs.
|
|
5379
|
+
*/
|
|
5380
|
+
getBaseUrl() {
|
|
5381
|
+
return this.baseUrl;
|
|
5382
|
+
}
|
|
5383
|
+
/**
|
|
5384
|
+
* Get JWT token for URL authentication (used in streaming endpoints).
|
|
5385
|
+
* Returns null if no token getter is configured or no token is available.
|
|
5386
|
+
*/
|
|
5387
|
+
getToken() {
|
|
5388
|
+
return this.tokenGetter ? this.tokenGetter() : null;
|
|
5389
|
+
}
|
|
5198
5390
|
/**
|
|
5199
5391
|
* Make HTTP request with Django CSRF and session handling.
|
|
5200
5392
|
* Automatically retries on network errors and 5xx server errors.
|
|
@@ -5415,112 +5607,112 @@ var DeviceListStatus = /* @__PURE__ */ ((DeviceListStatus2) => {
|
|
|
5415
5607
|
})(DeviceListStatus || {});
|
|
5416
5608
|
|
|
5417
5609
|
// src/generated/cfg_totp/_utils/schemas/BackupCodesRegenerateRequest.schema.ts
|
|
5418
|
-
import { z as
|
|
5419
|
-
var BackupCodesRegenerateRequestSchema =
|
|
5420
|
-
code:
|
|
5610
|
+
import { z as z61 } from "zod";
|
|
5611
|
+
var BackupCodesRegenerateRequestSchema = z61.object({
|
|
5612
|
+
code: z61.string().min(6).max(6)
|
|
5421
5613
|
});
|
|
5422
5614
|
|
|
5423
5615
|
// src/generated/cfg_totp/_utils/schemas/BackupCodesRegenerateResponse.schema.ts
|
|
5424
|
-
import { z as
|
|
5425
|
-
var BackupCodesRegenerateResponseSchema =
|
|
5426
|
-
backup_codes:
|
|
5427
|
-
warning:
|
|
5616
|
+
import { z as z62 } from "zod";
|
|
5617
|
+
var BackupCodesRegenerateResponseSchema = z62.object({
|
|
5618
|
+
backup_codes: z62.array(z62.string()),
|
|
5619
|
+
warning: z62.string()
|
|
5428
5620
|
});
|
|
5429
5621
|
|
|
5430
5622
|
// src/generated/cfg_totp/_utils/schemas/BackupCodesStatus.schema.ts
|
|
5431
|
-
import { z as
|
|
5432
|
-
var BackupCodesStatusSchema =
|
|
5433
|
-
remaining_count:
|
|
5434
|
-
total_generated:
|
|
5435
|
-
warning:
|
|
5623
|
+
import { z as z63 } from "zod";
|
|
5624
|
+
var BackupCodesStatusSchema = z63.object({
|
|
5625
|
+
remaining_count: z63.int(),
|
|
5626
|
+
total_generated: z63.int(),
|
|
5627
|
+
warning: z63.string().nullable().optional()
|
|
5436
5628
|
});
|
|
5437
5629
|
|
|
5438
5630
|
// src/generated/cfg_totp/_utils/schemas/ConfirmSetupRequest.schema.ts
|
|
5439
|
-
import { z as
|
|
5440
|
-
var ConfirmSetupRequestSchema =
|
|
5441
|
-
device_id:
|
|
5442
|
-
code:
|
|
5631
|
+
import { z as z64 } from "zod";
|
|
5632
|
+
var ConfirmSetupRequestSchema = z64.object({
|
|
5633
|
+
device_id: z64.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
5634
|
+
code: z64.string().min(6).max(6)
|
|
5443
5635
|
});
|
|
5444
5636
|
|
|
5445
5637
|
// src/generated/cfg_totp/_utils/schemas/ConfirmSetupResponse.schema.ts
|
|
5446
|
-
import { z as
|
|
5447
|
-
var ConfirmSetupResponseSchema =
|
|
5448
|
-
message:
|
|
5449
|
-
backup_codes:
|
|
5450
|
-
backup_codes_warning:
|
|
5638
|
+
import { z as z65 } from "zod";
|
|
5639
|
+
var ConfirmSetupResponseSchema = z65.object({
|
|
5640
|
+
message: z65.string(),
|
|
5641
|
+
backup_codes: z65.array(z65.string()),
|
|
5642
|
+
backup_codes_warning: z65.string()
|
|
5451
5643
|
});
|
|
5452
5644
|
|
|
5453
5645
|
// src/generated/cfg_totp/_utils/schemas/DeviceList.schema.ts
|
|
5454
|
-
import { z as
|
|
5455
|
-
var DeviceListSchema =
|
|
5456
|
-
id:
|
|
5457
|
-
name:
|
|
5458
|
-
is_primary:
|
|
5459
|
-
status:
|
|
5460
|
-
created_at:
|
|
5461
|
-
confirmed_at:
|
|
5462
|
-
last_used_at:
|
|
5646
|
+
import { z as z66 } from "zod";
|
|
5647
|
+
var DeviceListSchema = z66.object({
|
|
5648
|
+
id: z66.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
5649
|
+
name: z66.string(),
|
|
5650
|
+
is_primary: z66.boolean(),
|
|
5651
|
+
status: z66.nativeEnum(DeviceListStatus),
|
|
5652
|
+
created_at: z66.iso.datetime(),
|
|
5653
|
+
confirmed_at: z66.iso.datetime().nullable(),
|
|
5654
|
+
last_used_at: z66.iso.datetime().nullable()
|
|
5463
5655
|
});
|
|
5464
5656
|
|
|
5465
5657
|
// src/generated/cfg_totp/_utils/schemas/DisableRequest.schema.ts
|
|
5466
|
-
import { z as
|
|
5467
|
-
var DisableRequestSchema =
|
|
5468
|
-
code:
|
|
5658
|
+
import { z as z67 } from "zod";
|
|
5659
|
+
var DisableRequestSchema = z67.object({
|
|
5660
|
+
code: z67.string().min(6).max(6)
|
|
5469
5661
|
});
|
|
5470
5662
|
|
|
5471
5663
|
// src/generated/cfg_totp/_utils/schemas/PaginatedDeviceListList.schema.ts
|
|
5472
|
-
import { z as
|
|
5473
|
-
var PaginatedDeviceListListSchema =
|
|
5474
|
-
count:
|
|
5475
|
-
page:
|
|
5476
|
-
pages:
|
|
5477
|
-
page_size:
|
|
5478
|
-
has_next:
|
|
5479
|
-
has_previous:
|
|
5480
|
-
next_page:
|
|
5481
|
-
previous_page:
|
|
5482
|
-
results:
|
|
5664
|
+
import { z as z68 } from "zod";
|
|
5665
|
+
var PaginatedDeviceListListSchema = z68.object({
|
|
5666
|
+
count: z68.int(),
|
|
5667
|
+
page: z68.int(),
|
|
5668
|
+
pages: z68.int(),
|
|
5669
|
+
page_size: z68.int(),
|
|
5670
|
+
has_next: z68.boolean(),
|
|
5671
|
+
has_previous: z68.boolean(),
|
|
5672
|
+
next_page: z68.int().nullable().optional(),
|
|
5673
|
+
previous_page: z68.int().nullable().optional(),
|
|
5674
|
+
results: z68.array(DeviceListSchema)
|
|
5483
5675
|
});
|
|
5484
5676
|
|
|
5485
5677
|
// src/generated/cfg_totp/_utils/schemas/SetupRequest.schema.ts
|
|
5486
|
-
import { z as
|
|
5487
|
-
var SetupRequestSchema =
|
|
5488
|
-
device_name:
|
|
5678
|
+
import { z as z69 } from "zod";
|
|
5679
|
+
var SetupRequestSchema = z69.object({
|
|
5680
|
+
device_name: z69.string().min(1).max(100).optional()
|
|
5489
5681
|
});
|
|
5490
5682
|
|
|
5491
5683
|
// src/generated/cfg_totp/_utils/schemas/SetupResponse.schema.ts
|
|
5492
|
-
import { z as
|
|
5493
|
-
var SetupResponseSchema =
|
|
5494
|
-
device_id:
|
|
5495
|
-
secret:
|
|
5496
|
-
provisioning_uri:
|
|
5497
|
-
qr_code_base64:
|
|
5498
|
-
expires_in:
|
|
5684
|
+
import { z as z70 } from "zod";
|
|
5685
|
+
var SetupResponseSchema = z70.object({
|
|
5686
|
+
device_id: z70.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
5687
|
+
secret: z70.string(),
|
|
5688
|
+
provisioning_uri: z70.string(),
|
|
5689
|
+
qr_code_base64: z70.string(),
|
|
5690
|
+
expires_in: z70.int()
|
|
5499
5691
|
});
|
|
5500
5692
|
|
|
5501
5693
|
// src/generated/cfg_totp/_utils/schemas/VerifyBackupRequest.schema.ts
|
|
5502
|
-
import { z as
|
|
5503
|
-
var VerifyBackupRequestSchema =
|
|
5504
|
-
session_id:
|
|
5505
|
-
backup_code:
|
|
5694
|
+
import { z as z71 } from "zod";
|
|
5695
|
+
var VerifyBackupRequestSchema = z71.object({
|
|
5696
|
+
session_id: z71.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
5697
|
+
backup_code: z71.string().min(8).max(8)
|
|
5506
5698
|
});
|
|
5507
5699
|
|
|
5508
5700
|
// src/generated/cfg_totp/_utils/schemas/VerifyRequest.schema.ts
|
|
5509
|
-
import { z as
|
|
5510
|
-
var VerifyRequestSchema =
|
|
5511
|
-
session_id:
|
|
5512
|
-
code:
|
|
5701
|
+
import { z as z72 } from "zod";
|
|
5702
|
+
var VerifyRequestSchema = z72.object({
|
|
5703
|
+
session_id: z72.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
5704
|
+
code: z72.string().min(6).max(6)
|
|
5513
5705
|
});
|
|
5514
5706
|
|
|
5515
5707
|
// src/generated/cfg_totp/_utils/schemas/VerifyResponse.schema.ts
|
|
5516
|
-
import { z as
|
|
5517
|
-
var VerifyResponseSchema =
|
|
5518
|
-
message:
|
|
5519
|
-
access_token:
|
|
5520
|
-
refresh_token:
|
|
5521
|
-
user:
|
|
5522
|
-
remaining_backup_codes:
|
|
5523
|
-
warning:
|
|
5708
|
+
import { z as z73 } from "zod";
|
|
5709
|
+
var VerifyResponseSchema = z73.object({
|
|
5710
|
+
message: z73.string(),
|
|
5711
|
+
access_token: z73.string(),
|
|
5712
|
+
refresh_token: z73.string(),
|
|
5713
|
+
user: z73.record(z73.string(), z73.any()),
|
|
5714
|
+
remaining_backup_codes: z73.int().optional(),
|
|
5715
|
+
warning: z73.string().optional()
|
|
5524
5716
|
});
|
|
5525
5717
|
|
|
5526
5718
|
// src/generated/cfg_totp/_utils/fetchers/totp__backup_codes.ts
|
|
@@ -5549,7 +5741,8 @@ var API4 = class {
|
|
|
5549
5741
|
this._loadTokensFromStorage();
|
|
5550
5742
|
this._client = new APIClient4(this.baseUrl, {
|
|
5551
5743
|
retryConfig: this.options?.retryConfig,
|
|
5552
|
-
loggerConfig: this.options?.loggerConfig
|
|
5744
|
+
loggerConfig: this.options?.loggerConfig,
|
|
5745
|
+
tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
|
|
5553
5746
|
});
|
|
5554
5747
|
this._injectAuthHeader();
|
|
5555
5748
|
this.backup_codes = this._client.backup_codes;
|
|
@@ -5568,7 +5761,8 @@ var API4 = class {
|
|
|
5568
5761
|
_reinitClients() {
|
|
5569
5762
|
this._client = new APIClient4(this.baseUrl, {
|
|
5570
5763
|
retryConfig: this.options?.retryConfig,
|
|
5571
|
-
loggerConfig: this.options?.loggerConfig
|
|
5764
|
+
loggerConfig: this.options?.loggerConfig,
|
|
5765
|
+
tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
|
|
5572
5766
|
});
|
|
5573
5767
|
this._injectAuthHeader();
|
|
5574
5768
|
this.backup_codes = this._client.backup_codes;
|
|
@@ -5714,10 +5908,10 @@ var useTwoFactor = /* @__PURE__ */ __name((options = {}) => {
|
|
|
5714
5908
|
const [error, setError] = useState5(null);
|
|
5715
5909
|
const [warning, setWarning] = useState5(null);
|
|
5716
5910
|
const [remainingBackupCodes, setRemainingBackupCodes] = useState5(null);
|
|
5717
|
-
const clearError =
|
|
5911
|
+
const clearError = useCallback6(() => {
|
|
5718
5912
|
setError(null);
|
|
5719
5913
|
}, []);
|
|
5720
|
-
const handleSuccess =
|
|
5914
|
+
const handleSuccess = useCallback6((response) => {
|
|
5721
5915
|
apiAccounts.setToken(response.access_token, response.refresh_token);
|
|
5722
5916
|
if (response.warning) {
|
|
5723
5917
|
setWarning(response.warning);
|
|
@@ -5739,7 +5933,7 @@ var useTwoFactor = /* @__PURE__ */ __name((options = {}) => {
|
|
|
5739
5933
|
router.hardPush(finalRedirectUrl);
|
|
5740
5934
|
}
|
|
5741
5935
|
}, [onSuccess, redirectUrl, router, skipRedirect]);
|
|
5742
|
-
const verifyTOTP =
|
|
5936
|
+
const verifyTOTP = useCallback6(async (sessionId, code) => {
|
|
5743
5937
|
if (!sessionId) {
|
|
5744
5938
|
const msg = "Missing 2FA session ID";
|
|
5745
5939
|
setError(msg);
|
|
@@ -5779,7 +5973,7 @@ var useTwoFactor = /* @__PURE__ */ __name((options = {}) => {
|
|
|
5779
5973
|
setIsLoading(false);
|
|
5780
5974
|
}
|
|
5781
5975
|
}, [handleSuccess, onError]);
|
|
5782
|
-
const verifyBackupCode =
|
|
5976
|
+
const verifyBackupCode = useCallback6(async (sessionId, backupCode) => {
|
|
5783
5977
|
if (!sessionId) {
|
|
5784
5978
|
const msg = "Missing 2FA session ID";
|
|
5785
5979
|
setError(msg);
|
|
@@ -5845,7 +6039,7 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
5845
6039
|
} = options;
|
|
5846
6040
|
const formState = useAuthFormState();
|
|
5847
6041
|
const validation = useAuthValidation();
|
|
5848
|
-
const isAutoSubmitFromUrlRef =
|
|
6042
|
+
const isAutoSubmitFromUrlRef = useRef4(false);
|
|
5849
6043
|
const {
|
|
5850
6044
|
requestOTP,
|
|
5851
6045
|
verifyOTP,
|
|
@@ -5892,7 +6086,7 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
5892
6086
|
// We handle navigation via success step
|
|
5893
6087
|
});
|
|
5894
6088
|
const { detectChannelFromIdentifier: detectChannelFromIdentifier2, validateIdentifier: validateIdentifier2 } = validation;
|
|
5895
|
-
const saveIdentifierToStorage =
|
|
6089
|
+
const saveIdentifierToStorage = useCallback7((id, ch) => {
|
|
5896
6090
|
if (ch === "email") {
|
|
5897
6091
|
saveEmail(id);
|
|
5898
6092
|
clearSavedPhone();
|
|
@@ -5901,7 +6095,7 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
5901
6095
|
clearSavedEmail();
|
|
5902
6096
|
}
|
|
5903
6097
|
}, [saveEmail, savePhone, clearSavedEmail, clearSavedPhone]);
|
|
5904
|
-
|
|
6098
|
+
useEffect5(() => {
|
|
5905
6099
|
const savedPhone = getSavedPhone();
|
|
5906
6100
|
const savedEmail = getSavedEmail();
|
|
5907
6101
|
if (savedPhone) {
|
|
@@ -5912,7 +6106,7 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
5912
6106
|
setChannel("email");
|
|
5913
6107
|
}
|
|
5914
6108
|
}, [getSavedEmail, getSavedPhone, setIdentifier, setChannel]);
|
|
5915
|
-
|
|
6109
|
+
useEffect5(() => {
|
|
5916
6110
|
if (identifier) {
|
|
5917
6111
|
const detected = detectChannelFromIdentifier2(identifier);
|
|
5918
6112
|
if (detected && detected !== channel) {
|
|
@@ -5920,7 +6114,7 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
5920
6114
|
}
|
|
5921
6115
|
}
|
|
5922
6116
|
}, [identifier, channel, detectChannelFromIdentifier2, setChannel]);
|
|
5923
|
-
const handleIdentifierSubmit =
|
|
6117
|
+
const handleIdentifierSubmit = useCallback7(async (e) => {
|
|
5924
6118
|
e.preventDefault();
|
|
5925
6119
|
if (!identifier) {
|
|
5926
6120
|
const msg = channel === "phone" ? "Please enter your phone number" : "Please enter your email address";
|
|
@@ -5975,7 +6169,7 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
5975
6169
|
onError,
|
|
5976
6170
|
sourceUrl
|
|
5977
6171
|
]);
|
|
5978
|
-
const submitOTP =
|
|
6172
|
+
const submitOTP = useCallback7(async (submitIdentifier, submitOtp, submitChannel) => {
|
|
5979
6173
|
if (!submitOtp || submitOtp.length < 6) {
|
|
5980
6174
|
const msg = "Please enter the 6-digit verification code";
|
|
5981
6175
|
setError(msg);
|
|
@@ -6025,11 +6219,11 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
6025
6219
|
setIsLoading(false);
|
|
6026
6220
|
}
|
|
6027
6221
|
}, [verifyOTP, saveIdentifierToStorage, setError, setIsLoading, clearError, onOTPSuccess, onError, sourceUrl, redirectUrl, setTwoFactorSessionId, setShouldPrompt2FA, setStep, enable2FASetup]);
|
|
6028
|
-
const handleOTPSubmit =
|
|
6222
|
+
const handleOTPSubmit = useCallback7(async (e) => {
|
|
6029
6223
|
e.preventDefault();
|
|
6030
6224
|
await submitOTP(identifier, otp, channel);
|
|
6031
6225
|
}, [identifier, otp, channel, submitOTP]);
|
|
6032
|
-
const handleResendOTP =
|
|
6226
|
+
const handleResendOTP = useCallback7(async () => {
|
|
6033
6227
|
setIsLoading(true);
|
|
6034
6228
|
clearError();
|
|
6035
6229
|
try {
|
|
@@ -6049,15 +6243,15 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
6049
6243
|
setIsLoading(false);
|
|
6050
6244
|
}
|
|
6051
6245
|
}, [identifier, channel, requestOTP, saveIdentifierToStorage, setOtp, setError, setIsLoading, clearError, onError, sourceUrl]);
|
|
6052
|
-
const handleBackToIdentifier =
|
|
6246
|
+
const handleBackToIdentifier = useCallback7(() => {
|
|
6053
6247
|
setStep("identifier");
|
|
6054
6248
|
clearError();
|
|
6055
6249
|
}, [setStep, clearError]);
|
|
6056
|
-
const forceOTPStep =
|
|
6250
|
+
const forceOTPStep = useCallback7(() => {
|
|
6057
6251
|
setStep("otp");
|
|
6058
6252
|
clearError();
|
|
6059
6253
|
}, [setStep, clearError]);
|
|
6060
|
-
const handle2FASubmit =
|
|
6254
|
+
const handle2FASubmit = useCallback7(async (e) => {
|
|
6061
6255
|
e.preventDefault();
|
|
6062
6256
|
if (!twoFactorSessionId) {
|
|
6063
6257
|
const msg = "Missing 2FA session";
|
|
@@ -6071,12 +6265,12 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
6071
6265
|
await twoFactor.verifyTOTP(twoFactorSessionId, twoFactorCode);
|
|
6072
6266
|
}
|
|
6073
6267
|
}, [twoFactorSessionId, twoFactorCode, useBackupCode, twoFactor, setError, onError]);
|
|
6074
|
-
const handleUseBackupCode =
|
|
6268
|
+
const handleUseBackupCode = useCallback7(() => {
|
|
6075
6269
|
setUseBackupCode(true);
|
|
6076
6270
|
setTwoFactorCode("");
|
|
6077
6271
|
clearError();
|
|
6078
6272
|
}, [setUseBackupCode, setTwoFactorCode, clearError]);
|
|
6079
|
-
const handleUseTOTP =
|
|
6273
|
+
const handleUseTOTP = useCallback7(() => {
|
|
6080
6274
|
setUseBackupCode(false);
|
|
6081
6275
|
setTwoFactorCode("");
|
|
6082
6276
|
clearError();
|
|
@@ -6141,14 +6335,14 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
6141
6335
|
}, "useAuthForm");
|
|
6142
6336
|
|
|
6143
6337
|
// src/auth/hooks/useGithubAuth.ts
|
|
6144
|
-
import { useCallback as
|
|
6338
|
+
import { useCallback as useCallback8, useState as useState6 } from "react";
|
|
6145
6339
|
import { useCfgRouter as useCfgRouter4 } from "@djangocfg/ui-nextjs/hooks";
|
|
6146
6340
|
var useGithubAuth = /* @__PURE__ */ __name((options = {}) => {
|
|
6147
6341
|
const { sourceUrl, onSuccess, onError, onRequires2FA, redirectUrl, skipRedirect = false } = options;
|
|
6148
6342
|
const router = useCfgRouter4();
|
|
6149
6343
|
const [isLoading, setIsLoading] = useState6(false);
|
|
6150
6344
|
const [error, setError] = useState6(null);
|
|
6151
|
-
const startGithubAuth =
|
|
6345
|
+
const startGithubAuth = useCallback8(async () => {
|
|
6152
6346
|
setIsLoading(true);
|
|
6153
6347
|
setError(null);
|
|
6154
6348
|
try {
|
|
@@ -6182,7 +6376,7 @@ var useGithubAuth = /* @__PURE__ */ __name((options = {}) => {
|
|
|
6182
6376
|
setIsLoading(false);
|
|
6183
6377
|
}
|
|
6184
6378
|
}, [sourceUrl, onError]);
|
|
6185
|
-
const handleGithubCallback =
|
|
6379
|
+
const handleGithubCallback = useCallback8(async (code, state) => {
|
|
6186
6380
|
setIsLoading(true);
|
|
6187
6381
|
setError(null);
|
|
6188
6382
|
try {
|
|
@@ -6247,7 +6441,7 @@ var useGithubAuth = /* @__PURE__ */ __name((options = {}) => {
|
|
|
6247
6441
|
}, "useGithubAuth");
|
|
6248
6442
|
|
|
6249
6443
|
// src/auth/hooks/useTwoFactorSetup.ts
|
|
6250
|
-
import { useCallback as
|
|
6444
|
+
import { useCallback as useCallback9, useState as useState7 } from "react";
|
|
6251
6445
|
var useTwoFactorSetup = /* @__PURE__ */ __name((options = {}) => {
|
|
6252
6446
|
const { onComplete, onError } = options;
|
|
6253
6447
|
const [isLoading, setIsLoading] = useState7(false);
|
|
@@ -6256,17 +6450,17 @@ var useTwoFactorSetup = /* @__PURE__ */ __name((options = {}) => {
|
|
|
6256
6450
|
const [backupCodes, setBackupCodes] = useState7(null);
|
|
6257
6451
|
const [backupCodesWarning, setBackupCodesWarning] = useState7(null);
|
|
6258
6452
|
const [setupStep, setSetupStep] = useState7("idle");
|
|
6259
|
-
const clearError =
|
|
6453
|
+
const clearError = useCallback9(() => {
|
|
6260
6454
|
setError(null);
|
|
6261
6455
|
}, []);
|
|
6262
|
-
const resetSetup =
|
|
6456
|
+
const resetSetup = useCallback9(() => {
|
|
6263
6457
|
setSetupData(null);
|
|
6264
6458
|
setBackupCodes(null);
|
|
6265
6459
|
setBackupCodesWarning(null);
|
|
6266
6460
|
setSetupStep("idle");
|
|
6267
6461
|
setError(null);
|
|
6268
6462
|
}, []);
|
|
6269
|
-
const startSetup =
|
|
6463
|
+
const startSetup = useCallback9(async (deviceName) => {
|
|
6270
6464
|
setIsLoading(true);
|
|
6271
6465
|
setError(null);
|
|
6272
6466
|
setSetupStep("scanning");
|
|
@@ -6296,7 +6490,7 @@ var useTwoFactorSetup = /* @__PURE__ */ __name((options = {}) => {
|
|
|
6296
6490
|
setIsLoading(false);
|
|
6297
6491
|
}
|
|
6298
6492
|
}, [onError]);
|
|
6299
|
-
const confirmSetup =
|
|
6493
|
+
const confirmSetup = useCallback9(async (code) => {
|
|
6300
6494
|
if (!setupData) {
|
|
6301
6495
|
const msg = "Setup not started. Call startSetup() first.";
|
|
6302
6496
|
setError(msg);
|
|
@@ -6351,16 +6545,16 @@ var useTwoFactorSetup = /* @__PURE__ */ __name((options = {}) => {
|
|
|
6351
6545
|
}, "useTwoFactorSetup");
|
|
6352
6546
|
|
|
6353
6547
|
// src/auth/hooks/useTwoFactorStatus.ts
|
|
6354
|
-
import { useCallback as
|
|
6548
|
+
import { useCallback as useCallback10, useState as useState8 } from "react";
|
|
6355
6549
|
var useTwoFactorStatus = /* @__PURE__ */ __name(() => {
|
|
6356
6550
|
const [isLoading, setIsLoading] = useState8(false);
|
|
6357
6551
|
const [error, setError] = useState8(null);
|
|
6358
6552
|
const [has2FAEnabled, setHas2FAEnabled] = useState8(null);
|
|
6359
6553
|
const [devices, setDevices] = useState8([]);
|
|
6360
|
-
const clearError =
|
|
6554
|
+
const clearError = useCallback10(() => {
|
|
6361
6555
|
setError(null);
|
|
6362
6556
|
}, []);
|
|
6363
|
-
const fetchStatus =
|
|
6557
|
+
const fetchStatus = useCallback10(async () => {
|
|
6364
6558
|
setIsLoading(true);
|
|
6365
6559
|
setError(null);
|
|
6366
6560
|
try {
|
|
@@ -6385,7 +6579,7 @@ var useTwoFactorStatus = /* @__PURE__ */ __name(() => {
|
|
|
6385
6579
|
setIsLoading(false);
|
|
6386
6580
|
}
|
|
6387
6581
|
}, []);
|
|
6388
|
-
const disable2FA =
|
|
6582
|
+
const disable2FA = useCallback10(async (code) => {
|
|
6389
6583
|
if (!code || code.length !== 6) {
|
|
6390
6584
|
setError("Please enter a 6-digit code");
|
|
6391
6585
|
return false;
|
|
@@ -6420,14 +6614,14 @@ var useTwoFactorStatus = /* @__PURE__ */ __name(() => {
|
|
|
6420
6614
|
}, "useTwoFactorStatus");
|
|
6421
6615
|
|
|
6422
6616
|
// src/auth/hooks/useAuthGuard.ts
|
|
6423
|
-
import { useEffect as
|
|
6617
|
+
import { useEffect as useEffect6, useState as useState9 } from "react";
|
|
6424
6618
|
import { useCfgRouter as useCfgRouter5 } from "@djangocfg/ui-nextjs/hooks";
|
|
6425
6619
|
var useAuthGuard = /* @__PURE__ */ __name((options = {}) => {
|
|
6426
6620
|
const { redirectTo = "/auth", requireAuth = true, saveRedirectUrl: shouldSaveUrl = true } = options;
|
|
6427
6621
|
const { isAuthenticated, isLoading, saveRedirectUrl } = useAuth();
|
|
6428
6622
|
const router = useCfgRouter5();
|
|
6429
6623
|
const [isRedirecting, setIsRedirecting] = useState9(false);
|
|
6430
|
-
|
|
6624
|
+
useEffect6(() => {
|
|
6431
6625
|
if (!isLoading && requireAuth && !isAuthenticated && !isRedirecting) {
|
|
6432
6626
|
if (shouldSaveUrl && typeof window !== "undefined") {
|
|
6433
6627
|
const currentUrl = window.location.pathname + window.location.search;
|
|
@@ -6652,6 +6846,7 @@ export {
|
|
|
6652
6846
|
useGithubAuth,
|
|
6653
6847
|
useLocalStorage2 as useLocalStorage,
|
|
6654
6848
|
useSessionStorage,
|
|
6849
|
+
useTokenRefresh,
|
|
6655
6850
|
useTwoFactor,
|
|
6656
6851
|
useTwoFactorSetup,
|
|
6657
6852
|
useTwoFactorStatus,
|