@djangocfg/api 2.1.546 → 2.1.547
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.cjs +331 -73
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +90 -1
- package/dist/auth.d.ts +90 -1
- package/dist/auth.mjs +331 -73
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +18 -0
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +96 -0
- package/dist/clients.d.ts +96 -0
- package/dist/clients.mjs +18 -0
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +18 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +171 -3
- package/dist/index.d.ts +171 -3
- package/dist/index.mjs +18 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/_api/generated/_cfg_accounts/hooks/index.ts +1 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsTokenCreate.ts +64 -0
- package/src/_api/generated/_cfg_accounts/openapi.json +157 -0
- package/src/_api/generated/_cfg_accounts/schemas/PasswordLoginError.ts +13 -0
- package/src/_api/generated/_cfg_accounts/schemas/PasswordLoginRequest.ts +13 -0
- package/src/_api/generated/_cfg_accounts/schemas/PasswordLoginResponse.ts +18 -0
- package/src/_api/generated/_cfg_accounts/schemas/index.ts +3 -0
- package/src/_api/generated/openapi.json +157 -0
- package/src/_api/generated/sdk.gen.ts +20 -1
- package/src/_api/generated/types.gen.ts +149 -0
- package/src/auth/__tests__/passwordLogin.test.tsx +239 -0
- package/src/auth/context/AccountsContext.tsx +32 -7
- package/src/auth/context/AuthContext.tsx +104 -1
- package/src/auth/context/types.ts +10 -1
- package/src/auth/hooks/useAuthForm.ts +84 -0
- package/src/auth/hooks/useAuthFormState.ts +3 -0
- package/src/auth/types/form.ts +41 -1
- package/src/auth/types/index.ts +2 -0
- package/src/auth/utils/analytics.ts +1 -0
package/dist/clients.d.cts
CHANGED
|
@@ -925,6 +925,64 @@ type OtpVerifyResponse = {
|
|
|
925
925
|
*/
|
|
926
926
|
persistent_session?: boolean;
|
|
927
927
|
};
|
|
928
|
+
/**
|
|
929
|
+
* Typed error response for password login.
|
|
930
|
+
*
|
|
931
|
+
* error_code values:
|
|
932
|
+
* - invalid_credentials — wrong email/password, inactive or deleted account
|
|
933
|
+
* - rate_limited — IP rate limit hit
|
|
934
|
+
* - locked_out — too many failed attempts for this email
|
|
935
|
+
*/
|
|
936
|
+
type PasswordLoginError = {
|
|
937
|
+
/**
|
|
938
|
+
* Human-readable error message
|
|
939
|
+
*/
|
|
940
|
+
error: string;
|
|
941
|
+
/**
|
|
942
|
+
* Machine-readable error code
|
|
943
|
+
*/
|
|
944
|
+
error_code: string;
|
|
945
|
+
/**
|
|
946
|
+
* Seconds until the caller may retry (throttled responses only)
|
|
947
|
+
*/
|
|
948
|
+
retry_after?: number | null;
|
|
949
|
+
};
|
|
950
|
+
/**
|
|
951
|
+
* Password-login response.
|
|
952
|
+
*
|
|
953
|
+
* Mirrors the OTP verify response so a client can treat every login flow
|
|
954
|
+
* identically. ``requires_2fa=True`` carries a session id instead of tokens.
|
|
955
|
+
*/
|
|
956
|
+
type PasswordLoginResponse = {
|
|
957
|
+
/**
|
|
958
|
+
* Whether 2FA verification is required
|
|
959
|
+
*/
|
|
960
|
+
requires_2fa?: boolean;
|
|
961
|
+
/**
|
|
962
|
+
* 2FA session ID (if requires_2fa is True)
|
|
963
|
+
*/
|
|
964
|
+
session_id?: string | null;
|
|
965
|
+
/**
|
|
966
|
+
* JWT refresh token (if requires_2fa is False)
|
|
967
|
+
*/
|
|
968
|
+
refresh?: string | null;
|
|
969
|
+
/**
|
|
970
|
+
* JWT access token (if requires_2fa is False)
|
|
971
|
+
*/
|
|
972
|
+
access?: string | null;
|
|
973
|
+
/**
|
|
974
|
+
* User information (if requires_2fa is False)
|
|
975
|
+
*/
|
|
976
|
+
user?: User | null;
|
|
977
|
+
/**
|
|
978
|
+
* Whether user should be prompted to enable 2FA
|
|
979
|
+
*/
|
|
980
|
+
should_prompt_2fa?: boolean;
|
|
981
|
+
/**
|
|
982
|
+
* Whether this login should persist across browser restarts
|
|
983
|
+
*/
|
|
984
|
+
persistent_session?: boolean;
|
|
985
|
+
};
|
|
928
986
|
/**
|
|
929
987
|
* Serializer for updating user profile.
|
|
930
988
|
*/
|
|
@@ -1257,6 +1315,22 @@ type CfgAccountsOauthDisconnectResponse200AutoRef = {
|
|
|
1257
1315
|
* 2FA disabled successfully
|
|
1258
1316
|
*/
|
|
1259
1317
|
type CfgTotpDisableResponse200AutoRef = unknown;
|
|
1318
|
+
/**
|
|
1319
|
+
* Validate email+password against live accounts only.
|
|
1320
|
+
*
|
|
1321
|
+
* Subclasses SimpleJWT so the field/validation contract stays theirs, but
|
|
1322
|
+
* replaces ``validate()`` — the token pair itself is minted by the view via
|
|
1323
|
+
* ``mint_tokens_for_request`` so the DPoP binding and remembered-session
|
|
1324
|
+
* lifetime match OTP, OAuth and TOTP exactly.
|
|
1325
|
+
*/
|
|
1326
|
+
type PasswordLoginRequestWritable = {
|
|
1327
|
+
/**
|
|
1328
|
+
* Keep this browser signed in for 30 days
|
|
1329
|
+
*/
|
|
1330
|
+
remember_me?: boolean;
|
|
1331
|
+
email: string;
|
|
1332
|
+
password: string;
|
|
1333
|
+
};
|
|
1260
1334
|
type CfgAccountsApiKeyRetrieveData = {
|
|
1261
1335
|
body?: never;
|
|
1262
1336
|
path?: never;
|
|
@@ -1536,6 +1610,19 @@ type CfgAccountsProfileUpdateUpdateErrors = {
|
|
|
1536
1610
|
type CfgAccountsProfileUpdateUpdateResponses = {
|
|
1537
1611
|
200: User;
|
|
1538
1612
|
};
|
|
1613
|
+
type CfgAccountsTokenCreateData = {
|
|
1614
|
+
body: PasswordLoginRequestWritable;
|
|
1615
|
+
path?: never;
|
|
1616
|
+
query?: never;
|
|
1617
|
+
url: '/cfg/accounts/token/';
|
|
1618
|
+
};
|
|
1619
|
+
type CfgAccountsTokenCreateErrors = {
|
|
1620
|
+
401: PasswordLoginError;
|
|
1621
|
+
429: PasswordLoginError;
|
|
1622
|
+
};
|
|
1623
|
+
type CfgAccountsTokenCreateResponses = {
|
|
1624
|
+
200: PasswordLoginResponse;
|
|
1625
|
+
};
|
|
1539
1626
|
type CfgAccountsTokenBlacklistCreateData = {
|
|
1540
1627
|
body: TokenBlacklistRequest;
|
|
1541
1628
|
path?: never;
|
|
@@ -1835,6 +1922,15 @@ declare class CfgAccountsProfile {
|
|
|
1835
1922
|
static cfgAccountsProfileUpdateUpdate<ThrowOnError extends boolean = false>(options?: Options<CfgAccountsProfileUpdateUpdateData, ThrowOnError>): RequestResult<CfgAccountsProfileUpdateUpdateResponses, CfgAccountsProfileUpdateUpdateErrors, ThrowOnError>;
|
|
1836
1923
|
}
|
|
1837
1924
|
declare class CfgAccountsAuth {
|
|
1925
|
+
/**
|
|
1926
|
+
* Obtain a JWT pair with email + password.
|
|
1927
|
+
*
|
|
1928
|
+
* Returns the same envelope as OTP verify: either ``requires_2fa=True`` with
|
|
1929
|
+
* a session id, or the token pair plus the user object. Failures are uniform
|
|
1930
|
+
* (401 ``invalid_credentials``) whether the email is unknown, the password is
|
|
1931
|
+
* wrong, or the account is inactive/soft-deleted — no enumeration.
|
|
1932
|
+
*/
|
|
1933
|
+
static cfgAccountsTokenCreate<ThrowOnError extends boolean = false>(options: Options<CfgAccountsTokenCreateData, ThrowOnError>): RequestResult<CfgAccountsTokenCreateResponses, CfgAccountsTokenCreateErrors, ThrowOnError>;
|
|
1838
1934
|
/**
|
|
1839
1935
|
* Revoke a refresh token (logout).
|
|
1840
1936
|
*
|
package/dist/clients.d.ts
CHANGED
|
@@ -925,6 +925,64 @@ type OtpVerifyResponse = {
|
|
|
925
925
|
*/
|
|
926
926
|
persistent_session?: boolean;
|
|
927
927
|
};
|
|
928
|
+
/**
|
|
929
|
+
* Typed error response for password login.
|
|
930
|
+
*
|
|
931
|
+
* error_code values:
|
|
932
|
+
* - invalid_credentials — wrong email/password, inactive or deleted account
|
|
933
|
+
* - rate_limited — IP rate limit hit
|
|
934
|
+
* - locked_out — too many failed attempts for this email
|
|
935
|
+
*/
|
|
936
|
+
type PasswordLoginError = {
|
|
937
|
+
/**
|
|
938
|
+
* Human-readable error message
|
|
939
|
+
*/
|
|
940
|
+
error: string;
|
|
941
|
+
/**
|
|
942
|
+
* Machine-readable error code
|
|
943
|
+
*/
|
|
944
|
+
error_code: string;
|
|
945
|
+
/**
|
|
946
|
+
* Seconds until the caller may retry (throttled responses only)
|
|
947
|
+
*/
|
|
948
|
+
retry_after?: number | null;
|
|
949
|
+
};
|
|
950
|
+
/**
|
|
951
|
+
* Password-login response.
|
|
952
|
+
*
|
|
953
|
+
* Mirrors the OTP verify response so a client can treat every login flow
|
|
954
|
+
* identically. ``requires_2fa=True`` carries a session id instead of tokens.
|
|
955
|
+
*/
|
|
956
|
+
type PasswordLoginResponse = {
|
|
957
|
+
/**
|
|
958
|
+
* Whether 2FA verification is required
|
|
959
|
+
*/
|
|
960
|
+
requires_2fa?: boolean;
|
|
961
|
+
/**
|
|
962
|
+
* 2FA session ID (if requires_2fa is True)
|
|
963
|
+
*/
|
|
964
|
+
session_id?: string | null;
|
|
965
|
+
/**
|
|
966
|
+
* JWT refresh token (if requires_2fa is False)
|
|
967
|
+
*/
|
|
968
|
+
refresh?: string | null;
|
|
969
|
+
/**
|
|
970
|
+
* JWT access token (if requires_2fa is False)
|
|
971
|
+
*/
|
|
972
|
+
access?: string | null;
|
|
973
|
+
/**
|
|
974
|
+
* User information (if requires_2fa is False)
|
|
975
|
+
*/
|
|
976
|
+
user?: User | null;
|
|
977
|
+
/**
|
|
978
|
+
* Whether user should be prompted to enable 2FA
|
|
979
|
+
*/
|
|
980
|
+
should_prompt_2fa?: boolean;
|
|
981
|
+
/**
|
|
982
|
+
* Whether this login should persist across browser restarts
|
|
983
|
+
*/
|
|
984
|
+
persistent_session?: boolean;
|
|
985
|
+
};
|
|
928
986
|
/**
|
|
929
987
|
* Serializer for updating user profile.
|
|
930
988
|
*/
|
|
@@ -1257,6 +1315,22 @@ type CfgAccountsOauthDisconnectResponse200AutoRef = {
|
|
|
1257
1315
|
* 2FA disabled successfully
|
|
1258
1316
|
*/
|
|
1259
1317
|
type CfgTotpDisableResponse200AutoRef = unknown;
|
|
1318
|
+
/**
|
|
1319
|
+
* Validate email+password against live accounts only.
|
|
1320
|
+
*
|
|
1321
|
+
* Subclasses SimpleJWT so the field/validation contract stays theirs, but
|
|
1322
|
+
* replaces ``validate()`` — the token pair itself is minted by the view via
|
|
1323
|
+
* ``mint_tokens_for_request`` so the DPoP binding and remembered-session
|
|
1324
|
+
* lifetime match OTP, OAuth and TOTP exactly.
|
|
1325
|
+
*/
|
|
1326
|
+
type PasswordLoginRequestWritable = {
|
|
1327
|
+
/**
|
|
1328
|
+
* Keep this browser signed in for 30 days
|
|
1329
|
+
*/
|
|
1330
|
+
remember_me?: boolean;
|
|
1331
|
+
email: string;
|
|
1332
|
+
password: string;
|
|
1333
|
+
};
|
|
1260
1334
|
type CfgAccountsApiKeyRetrieveData = {
|
|
1261
1335
|
body?: never;
|
|
1262
1336
|
path?: never;
|
|
@@ -1536,6 +1610,19 @@ type CfgAccountsProfileUpdateUpdateErrors = {
|
|
|
1536
1610
|
type CfgAccountsProfileUpdateUpdateResponses = {
|
|
1537
1611
|
200: User;
|
|
1538
1612
|
};
|
|
1613
|
+
type CfgAccountsTokenCreateData = {
|
|
1614
|
+
body: PasswordLoginRequestWritable;
|
|
1615
|
+
path?: never;
|
|
1616
|
+
query?: never;
|
|
1617
|
+
url: '/cfg/accounts/token/';
|
|
1618
|
+
};
|
|
1619
|
+
type CfgAccountsTokenCreateErrors = {
|
|
1620
|
+
401: PasswordLoginError;
|
|
1621
|
+
429: PasswordLoginError;
|
|
1622
|
+
};
|
|
1623
|
+
type CfgAccountsTokenCreateResponses = {
|
|
1624
|
+
200: PasswordLoginResponse;
|
|
1625
|
+
};
|
|
1539
1626
|
type CfgAccountsTokenBlacklistCreateData = {
|
|
1540
1627
|
body: TokenBlacklistRequest;
|
|
1541
1628
|
path?: never;
|
|
@@ -1835,6 +1922,15 @@ declare class CfgAccountsProfile {
|
|
|
1835
1922
|
static cfgAccountsProfileUpdateUpdate<ThrowOnError extends boolean = false>(options?: Options<CfgAccountsProfileUpdateUpdateData, ThrowOnError>): RequestResult<CfgAccountsProfileUpdateUpdateResponses, CfgAccountsProfileUpdateUpdateErrors, ThrowOnError>;
|
|
1836
1923
|
}
|
|
1837
1924
|
declare class CfgAccountsAuth {
|
|
1925
|
+
/**
|
|
1926
|
+
* Obtain a JWT pair with email + password.
|
|
1927
|
+
*
|
|
1928
|
+
* Returns the same envelope as OTP verify: either ``requires_2fa=True`` with
|
|
1929
|
+
* a session id, or the token pair plus the user object. Failures are uniform
|
|
1930
|
+
* (401 ``invalid_credentials``) whether the email is unknown, the password is
|
|
1931
|
+
* wrong, or the account is inactive/soft-deleted — no enumeration.
|
|
1932
|
+
*/
|
|
1933
|
+
static cfgAccountsTokenCreate<ThrowOnError extends boolean = false>(options: Options<CfgAccountsTokenCreateData, ThrowOnError>): RequestResult<CfgAccountsTokenCreateResponses, CfgAccountsTokenCreateErrors, ThrowOnError>;
|
|
1838
1934
|
/**
|
|
1839
1935
|
* Revoke a refresh token (logout).
|
|
1840
1936
|
*
|
package/dist/clients.mjs
CHANGED
|
@@ -1992,6 +1992,24 @@ var CfgAccountsAuth = class {
|
|
|
1992
1992
|
static {
|
|
1993
1993
|
__name(this, "CfgAccountsAuth");
|
|
1994
1994
|
}
|
|
1995
|
+
/**
|
|
1996
|
+
* Obtain a JWT pair with email + password.
|
|
1997
|
+
*
|
|
1998
|
+
* Returns the same envelope as OTP verify: either ``requires_2fa=True`` with
|
|
1999
|
+
* a session id, or the token pair plus the user object. Failures are uniform
|
|
2000
|
+
* (401 ``invalid_credentials``) whether the email is unknown, the password is
|
|
2001
|
+
* wrong, or the account is inactive/soft-deleted — no enumeration.
|
|
2002
|
+
*/
|
|
2003
|
+
static cfgAccountsTokenCreate(options) {
|
|
2004
|
+
return (options.client ?? client).post({
|
|
2005
|
+
url: "/cfg/accounts/token/",
|
|
2006
|
+
...options,
|
|
2007
|
+
headers: {
|
|
2008
|
+
"Content-Type": "application/json",
|
|
2009
|
+
...options.headers
|
|
2010
|
+
}
|
|
2011
|
+
});
|
|
2012
|
+
}
|
|
1995
2013
|
/**
|
|
1996
2014
|
* Revoke a refresh token (logout).
|
|
1997
2015
|
*
|