@djangocfg/api 2.1.227 → 2.1.228
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 +8 -9
- package/dist/auth-server.cjs +4 -9
- package/dist/auth-server.cjs.map +1 -1
- package/dist/auth-server.mjs +4 -9
- package/dist/auth-server.mjs.map +1 -1
- package/dist/auth.cjs +120 -158
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +120 -177
- package/dist/auth.d.ts +120 -177
- package/dist/auth.mjs +149 -191
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +5 -11
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +218 -219
- package/dist/clients.d.ts +218 -219
- package/dist/clients.mjs +5 -11
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +4 -9
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +70 -91
- package/dist/hooks.d.ts +70 -91
- package/dist/hooks.mjs +4 -9
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +5 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +116 -106
- package/dist/index.d.ts +116 -106
- package/dist/index.mjs +5 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/_api/generated/cfg_accounts/_utils/schemas/OTPErrorResponse.schema.ts +24 -2
- package/src/_api/generated/cfg_accounts/_utils/schemas/OTPRequestRequest.schema.ts +0 -2
- package/src/_api/generated/cfg_accounts/_utils/schemas/OTPVerifyRequest.schema.ts +0 -2
- package/src/_api/generated/cfg_accounts/accounts/client.ts +1 -1
- package/src/_api/generated/cfg_accounts/accounts/models.ts +25 -26
- package/src/_api/generated/cfg_accounts/accounts__auth/models.ts +5 -5
- package/src/_api/generated/cfg_accounts/accounts__oauth/models.ts +42 -42
- package/src/_api/generated/cfg_accounts/accounts__user_profile/models.ts +23 -23
- package/src/_api/generated/cfg_accounts/enums.ts +0 -10
- package/src/_api/generated/cfg_accounts/schema.json +31 -25
- package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_admin_api/models.ts +57 -57
- package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_monitoring/models.ts +24 -24
- package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_testing/models.ts +14 -14
- package/src/_api/generated/cfg_totp/totp__backup_codes/models.ts +14 -14
- package/src/_api/generated/cfg_totp/totp__totp_setup/models.ts +10 -10
- package/src/_api/generated/cfg_totp/totp__totp_verification/models.ts +8 -8
- package/src/auth/context/AccountsContext.tsx +6 -2
- package/src/auth/context/AuthContext.tsx +32 -39
- package/src/auth/context/types.ts +5 -9
- package/src/auth/hooks/index.ts +1 -1
- package/src/auth/hooks/useAuthForm.ts +42 -75
- package/src/auth/hooks/useAuthFormState.ts +35 -6
- package/src/auth/hooks/useAuthValidation.ts +5 -65
- package/src/auth/hooks/useTwoFactor.ts +17 -2
- package/src/auth/types/form.ts +25 -70
- package/src/auth/types/index.ts +2 -6
package/README.md
CHANGED
|
@@ -98,7 +98,7 @@ Complete authentication system with OTP, OAuth, and Two-Factor Authentication (2
|
|
|
98
98
|
### Authentication Flow
|
|
99
99
|
|
|
100
100
|
```
|
|
101
|
-
1. User enters email
|
|
101
|
+
1. User enters email → OTP sent
|
|
102
102
|
2. User enters OTP code → Verify
|
|
103
103
|
├── If 2FA enabled → Show TOTP verification
|
|
104
104
|
│ └── User enters 6-digit TOTP → Verify
|
|
@@ -164,9 +164,9 @@ export function UserProfile() {
|
|
|
164
164
|
user, // UserProfile | null
|
|
165
165
|
isAuthenticated, // boolean
|
|
166
166
|
isLoading, // boolean
|
|
167
|
-
requestOTP, // (identifier,
|
|
168
|
-
verifyOTP, // (identifier, otp,
|
|
169
|
-
logout, // () =>
|
|
167
|
+
requestOTP, // (identifier, sourceUrl?) => Promise<{ success, message }>
|
|
168
|
+
verifyOTP, // (identifier, otp, sourceUrl?, redirectUrl?) => Promise<{ success, message, user? }>
|
|
169
|
+
logout, // () => void
|
|
170
170
|
} = useAuth();
|
|
171
171
|
|
|
172
172
|
if (isLoading) return <div>Loading...</div>;
|
|
@@ -215,17 +215,17 @@ import { useAuthForm } from '@djangocfg/api/auth';
|
|
|
215
215
|
export function OTPLoginForm() {
|
|
216
216
|
const {
|
|
217
217
|
// State
|
|
218
|
-
identifier, // Email
|
|
219
|
-
channel, // 'email' | 'phone'
|
|
218
|
+
identifier, // Email address
|
|
220
219
|
otp, // 6-digit OTP code
|
|
221
220
|
step, // 'identifier' | 'otp' | '2fa' | '2fa-setup' | 'success'
|
|
222
221
|
isLoading,
|
|
223
222
|
error,
|
|
224
223
|
acceptedTerms,
|
|
224
|
+
isRateLimited, // boolean - true when rate limited
|
|
225
|
+
rateLimitLabel, // string - formatted countdown e.g. "1:30" or "45s"
|
|
225
226
|
|
|
226
227
|
// Setters
|
|
227
228
|
setIdentifier,
|
|
228
|
-
setChannel,
|
|
229
229
|
setOtp,
|
|
230
230
|
setAcceptedTerms,
|
|
231
231
|
|
|
@@ -236,12 +236,11 @@ export function OTPLoginForm() {
|
|
|
236
236
|
handleBackToIdentifier, // Go back to step 1
|
|
237
237
|
|
|
238
238
|
// Utilities
|
|
239
|
-
detectChannelFromIdentifier,
|
|
240
239
|
validateIdentifier,
|
|
241
240
|
} = useAuthForm({
|
|
242
241
|
sourceUrl: window.location.origin,
|
|
243
242
|
requireTermsAcceptance: false, // Set true if terms/privacy links provided
|
|
244
|
-
onIdentifierSuccess: (identifier
|
|
243
|
+
onIdentifierSuccess: (identifier) => {
|
|
245
244
|
console.log('OTP sent to', identifier);
|
|
246
245
|
},
|
|
247
246
|
onOTPSuccess: () => {
|
package/dist/auth-server.cjs
CHANGED
|
@@ -225,7 +225,7 @@ var Accounts = class {
|
|
|
225
225
|
this.client = client;
|
|
226
226
|
}
|
|
227
227
|
/**
|
|
228
|
-
* Request OTP code to email
|
|
228
|
+
* Request OTP code to email.
|
|
229
229
|
*/
|
|
230
230
|
async otpRequestCreate(data) {
|
|
231
231
|
const response = await this.client.request("POST", "/cfg/accounts/otp/request/", { body: data });
|
|
@@ -870,11 +870,6 @@ var OAuthConnectionProvider = /* @__PURE__ */ ((OAuthConnectionProvider2) => {
|
|
|
870
870
|
OAuthConnectionProvider2["GITHUB"] = "github";
|
|
871
871
|
return OAuthConnectionProvider2;
|
|
872
872
|
})(OAuthConnectionProvider || {});
|
|
873
|
-
var OTPRequestRequestChannel = /* @__PURE__ */ ((OTPRequestRequestChannel2) => {
|
|
874
|
-
OTPRequestRequestChannel2["EMAIL"] = "email";
|
|
875
|
-
OTPRequestRequestChannel2["PHONE"] = "phone";
|
|
876
|
-
return OTPRequestRequestChannel2;
|
|
877
|
-
})(OTPRequestRequestChannel || {});
|
|
878
873
|
|
|
879
874
|
// src/_api/generated/cfg_accounts/_utils/schemas/AccountDeleteResponse.schema.ts
|
|
880
875
|
var import_zod = require("zod");
|
|
@@ -968,14 +963,15 @@ var OAuthTokenResponseSchema = import_zod11.z.object({
|
|
|
968
963
|
// src/_api/generated/cfg_accounts/_utils/schemas/OTPErrorResponse.schema.ts
|
|
969
964
|
var import_zod12 = require("zod");
|
|
970
965
|
var OTPErrorResponseSchema = import_zod12.z.object({
|
|
971
|
-
error: import_zod12.z.string()
|
|
966
|
+
error: import_zod12.z.string(),
|
|
967
|
+
error_code: import_zod12.z.string().nullable().optional(),
|
|
968
|
+
retry_after: import_zod12.z.number().int().nullable().optional()
|
|
972
969
|
});
|
|
973
970
|
|
|
974
971
|
// src/_api/generated/cfg_accounts/_utils/schemas/OTPRequestRequest.schema.ts
|
|
975
972
|
var import_zod13 = require("zod");
|
|
976
973
|
var OTPRequestRequestSchema = import_zod13.z.object({
|
|
977
974
|
identifier: import_zod13.z.string().min(1),
|
|
978
|
-
channel: import_zod13.z.nativeEnum(OTPRequestRequestChannel).optional(),
|
|
979
975
|
source_url: import_zod13.z.string().optional()
|
|
980
976
|
});
|
|
981
977
|
|
|
@@ -990,7 +986,6 @@ var import_zod15 = require("zod");
|
|
|
990
986
|
var OTPVerifyRequestSchema = import_zod15.z.object({
|
|
991
987
|
identifier: import_zod15.z.string().min(1),
|
|
992
988
|
otp: import_zod15.z.string().min(6).max(6),
|
|
993
|
-
channel: import_zod15.z.nativeEnum(OTPRequestRequestChannel).optional(),
|
|
994
989
|
source_url: import_zod15.z.string().optional()
|
|
995
990
|
});
|
|
996
991
|
|