@djangocfg/api 2.1.56 → 2.1.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +125 -9
- package/dist/auth.cjs +1865 -402
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +352 -76
- package/dist/auth.d.ts +352 -76
- package/dist/auth.mjs +1867 -404
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +1637 -137
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +1394 -282
- package/dist/clients.d.ts +1394 -282
- package/dist/clients.mjs +1637 -137
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +24 -11
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +88 -21
- package/dist/hooks.d.ts +88 -21
- package/dist/hooks.mjs +24 -11
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +38 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +94 -21
- package/dist/index.d.ts +94 -21
- package/dist/index.mjs +38 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/auth/context/AccountsContext.tsx +8 -1
- package/src/auth/context/AuthContext.tsx +31 -8
- package/src/auth/context/types.ts +8 -1
- package/src/auth/hooks/index.ts +29 -5
- package/src/auth/hooks/useAuthForm.ts +292 -226
- package/src/auth/hooks/useAuthFormState.ts +60 -0
- package/src/auth/hooks/useAuthValidation.ts +77 -0
- package/src/auth/hooks/useGithubAuth.ts +26 -5
- package/src/auth/hooks/useTwoFactor.ts +239 -0
- package/src/auth/hooks/useTwoFactorSetup.ts +213 -0
- package/src/auth/index.ts +3 -0
- package/src/auth/types/form.ts +194 -0
- package/src/auth/types/index.ts +28 -0
- package/src/clients.ts +10 -0
- package/src/generated/cfg_accounts/_utils/schemas/OAuthTokenResponse.schema.ts +26 -3
- package/src/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts +26 -3
- package/src/generated/cfg_accounts/accounts/client.ts +4 -1
- package/src/generated/cfg_accounts/accounts/models.ts +15 -6
- package/src/generated/cfg_accounts/accounts__oauth/models.ts +16 -7
- package/src/generated/cfg_accounts/client.ts +5 -2
- package/src/generated/cfg_accounts/http.ts +8 -2
- package/src/generated/cfg_accounts/schema.json +47 -19
- package/src/generated/cfg_centrifugo/client.ts +5 -2
- package/src/generated/cfg_centrifugo/http.ts +8 -2
- package/src/generated/cfg_totp/CLAUDE.md +12 -12
- package/src/generated/cfg_totp/_utils/fetchers/index.ts +3 -3
- package/src/generated/cfg_totp/_utils/fetchers/{totp__2fa_management.ts → totp__totp_management.ts} +3 -3
- package/src/generated/cfg_totp/_utils/fetchers/{totp__2fa_setup.ts → totp__totp_setup.ts} +3 -3
- package/src/generated/cfg_totp/_utils/fetchers/{totp__2fa_verification.ts → totp__totp_verification.ts} +3 -3
- package/src/generated/cfg_totp/_utils/hooks/index.ts +3 -3
- package/src/generated/cfg_totp/_utils/hooks/{totp__2fa_management.ts → totp__totp_management.ts} +2 -2
- package/src/generated/cfg_totp/_utils/hooks/{totp__2fa_setup.ts → totp__totp_setup.ts} +2 -2
- package/src/generated/cfg_totp/_utils/hooks/{totp__2fa_verification.ts → totp__totp_verification.ts} +2 -2
- package/src/generated/cfg_totp/_utils/schemas/DeviceList.schema.ts +1 -1
- package/src/generated/cfg_totp/client.ts +14 -11
- package/src/generated/cfg_totp/http.ts +8 -2
- package/src/generated/cfg_totp/index.ts +16 -16
- package/src/generated/cfg_totp/schema.json +8 -7
- package/src/generated/cfg_totp/{totp__2fa_management → totp__totp_management}/client.ts +2 -2
- package/src/generated/cfg_totp/{totp__2fa_management → totp__totp_management}/models.ts +1 -1
- package/src/generated/cfg_totp/{totp__2fa_setup → totp__totp_setup}/client.ts +4 -4
- package/src/generated/cfg_totp/{totp__2fa_verification → totp__totp_verification}/client.ts +2 -2
- package/src/generated/cfg_webpush/client.ts +5 -2
- package/src/generated/cfg_webpush/http.ts +8 -2
- /package/src/generated/cfg_totp/{totp__2fa_management → totp__totp_management}/index.ts +0 -0
- /package/src/generated/cfg_totp/{totp__2fa_setup → totp__totp_setup}/index.ts +0 -0
- /package/src/generated/cfg_totp/{totp__2fa_setup → totp__totp_setup}/models.ts +0 -0
- /package/src/generated/cfg_totp/{totp__2fa_verification → totp__totp_verification}/index.ts +0 -0
- /package/src/generated/cfg_totp/{totp__2fa_verification → totp__totp_verification}/models.ts +0 -0
package/dist/hooks.cjs
CHANGED
|
@@ -218,7 +218,10 @@ var Accounts = class {
|
|
|
218
218
|
return response;
|
|
219
219
|
}
|
|
220
220
|
/**
|
|
221
|
-
* Verify OTP code and return JWT tokens.
|
|
221
|
+
* Verify OTP code and return JWT tokens or 2FA session. If user has 2FA
|
|
222
|
+
* enabled: - Returns requires_2fa=True with session_id - Client must
|
|
223
|
+
* complete 2FA verification at /cfg/totp/verify/ If user has no 2FA: -
|
|
224
|
+
* Returns JWT tokens and user data directly
|
|
222
225
|
*/
|
|
223
226
|
async otpVerifyCreate(data) {
|
|
224
227
|
const response = await this.client.request("POST", "/cfg/accounts/otp/verify/", { body: data });
|
|
@@ -232,7 +235,7 @@ var FetchAdapter = class {
|
|
|
232
235
|
__name(this, "FetchAdapter");
|
|
233
236
|
}
|
|
234
237
|
async request(request) {
|
|
235
|
-
const { method, url, headers, body, params, formData } = request;
|
|
238
|
+
const { method, url, headers, body, params, formData, binaryBody } = request;
|
|
236
239
|
let finalUrl = url;
|
|
237
240
|
if (params) {
|
|
238
241
|
const searchParams = new URLSearchParams();
|
|
@@ -250,6 +253,9 @@ var FetchAdapter = class {
|
|
|
250
253
|
let requestBody;
|
|
251
254
|
if (formData) {
|
|
252
255
|
requestBody = formData;
|
|
256
|
+
} else if (binaryBody) {
|
|
257
|
+
finalHeaders["Content-Type"] = "application/octet-stream";
|
|
258
|
+
requestBody = binaryBody;
|
|
253
259
|
} else if (body) {
|
|
254
260
|
finalHeaders["Content-Type"] = "application/json";
|
|
255
261
|
requestBody = JSON.stringify(body);
|
|
@@ -649,7 +655,7 @@ var APIClient = class {
|
|
|
649
655
|
const headers = {
|
|
650
656
|
...options?.headers || {}
|
|
651
657
|
};
|
|
652
|
-
if (!options?.formData && !headers["Content-Type"]) {
|
|
658
|
+
if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
|
|
653
659
|
headers["Content-Type"] = "application/json";
|
|
654
660
|
}
|
|
655
661
|
if (this.logger) {
|
|
@@ -668,7 +674,8 @@ var APIClient = class {
|
|
|
668
674
|
headers,
|
|
669
675
|
params: options?.params,
|
|
670
676
|
body: options?.body,
|
|
671
|
-
formData: options?.formData
|
|
677
|
+
formData: options?.formData,
|
|
678
|
+
binaryBody: options?.binaryBody
|
|
672
679
|
});
|
|
673
680
|
const duration = Date.now() - startTime;
|
|
674
681
|
if (response.status >= 400) {
|
|
@@ -915,11 +922,14 @@ var OAuthProvidersResponseSchema = import_zod9.z.object({
|
|
|
915
922
|
// src/generated/cfg_accounts/_utils/schemas/OAuthTokenResponse.schema.ts
|
|
916
923
|
var import_zod10 = require("zod");
|
|
917
924
|
var OAuthTokenResponseSchema = import_zod10.z.object({
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
925
|
+
requires_2fa: import_zod10.z.boolean().optional(),
|
|
926
|
+
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(),
|
|
927
|
+
access: import_zod10.z.string().nullable().optional(),
|
|
928
|
+
refresh: import_zod10.z.string().nullable().optional(),
|
|
929
|
+
user: import_zod10.z.record(import_zod10.z.string(), import_zod10.z.any()).nullable().optional(),
|
|
921
930
|
is_new_user: import_zod10.z.boolean(),
|
|
922
|
-
is_new_connection: import_zod10.z.boolean()
|
|
931
|
+
is_new_connection: import_zod10.z.boolean(),
|
|
932
|
+
should_prompt_2fa: import_zod10.z.boolean().optional()
|
|
923
933
|
});
|
|
924
934
|
|
|
925
935
|
// src/generated/cfg_accounts/_utils/schemas/OTPErrorResponse.schema.ts
|
|
@@ -978,9 +988,12 @@ var UserSchema = import_zod15.z.object({
|
|
|
978
988
|
|
|
979
989
|
// src/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts
|
|
980
990
|
var OTPVerifyResponseSchema = import_zod16.z.object({
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
991
|
+
requires_2fa: import_zod16.z.boolean().optional(),
|
|
992
|
+
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(),
|
|
993
|
+
refresh: import_zod16.z.string().nullable().optional(),
|
|
994
|
+
access: import_zod16.z.string().nullable().optional(),
|
|
995
|
+
user: UserSchema.nullable().optional(),
|
|
996
|
+
should_prompt_2fa: import_zod16.z.boolean().optional()
|
|
984
997
|
});
|
|
985
998
|
|
|
986
999
|
// src/generated/cfg_accounts/_utils/schemas/PatchedUserProfileUpdateRequest.schema.ts
|