@djangocfg/api 2.1.582 → 2.1.584
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 +18 -0
- package/dist/OAuthTokenResponse-WEDM6IP5.mjs +19 -0
- package/dist/OAuthTokenResponse-WEDM6IP5.mjs.map +1 -0
- package/dist/OTPVerifyResponse-P5LDNM7H.mjs +20 -0
- package/dist/OTPVerifyResponse-P5LDNM7H.mjs.map +1 -0
- package/dist/PasswordLoginResponse-33B576NG.mjs +20 -0
- package/dist/PasswordLoginResponse-33B576NG.mjs.map +1 -0
- package/dist/auth.cjs +279 -103
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +14 -41
- package/dist/auth.d.ts +14 -41
- package/dist/auth.mjs +279 -101
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +242 -54
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +13 -41
- package/dist/clients.d.ts +13 -41
- package/dist/clients.mjs +242 -54
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +242 -54
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.mjs +242 -54
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +247 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +90 -63
- package/dist/index.d.ts +90 -63
- package/dist/index.mjs +247 -54
- package/dist/index.mjs.map +1 -1
- package/dist/storage.cjs +268 -0
- package/dist/storage.cjs.map +1 -0
- package/dist/storage.d.cts +84 -0
- package/dist/storage.d.ts +84 -0
- package/dist/storage.mjs +247 -0
- package/dist/storage.mjs.map +1 -0
- package/package.json +8 -2
- package/src/__tests__/noStorageLiterals.test.ts +27 -0
- package/src/__tests__/storage.test.ts +134 -0
- package/src/__tests__/storageSsr.test.ts +14 -0
- package/src/_api/generated/_cfg_accounts/openapi.json +1 -28
- package/src/_api/generated/_cfg_accounts/schemas/OAuthCallbackRequestRequest.ts +0 -1
- package/src/_api/generated/_cfg_accounts/schemas/OAuthTokenResponse.ts +0 -1
- package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyRequest.ts +0 -1
- package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts +0 -1
- package/src/_api/generated/_cfg_accounts/schemas/PasswordLoginRequest.ts +0 -1
- package/src/_api/generated/_cfg_accounts/schemas/PasswordLoginResponse.ts +0 -1
- package/src/_api/generated/_cfg_totp/openapi.json +0 -5
- package/src/_api/generated/_cfg_totp/schemas/VerifyResponse.ts +0 -1
- package/src/_api/generated/helpers/auth.ts +28 -65
- package/src/_api/generated/helpers/index.ts +12 -0
- package/src/_api/generated/helpers/keys.ts +327 -0
- package/src/_api/generated/openapi.json +1 -33
- package/src/_api/generated/types.gen.ts +4 -59
- package/src/auth/__tests__/authRedirect.test.ts +1 -1
- package/src/auth/__tests__/passwordLogin.test.tsx +1 -3
- package/src/auth/__tests__/profileCache.test.ts +1 -1
- package/src/auth/context/AccountsContext.tsx +6 -8
- package/src/auth/context/AuthContext.tsx +3 -5
- package/src/auth/context/types.ts +1 -1
- package/src/auth/hooks/useAuthForm.ts +3 -5
- package/src/auth/hooks/useAuthFormState.ts +0 -4
- package/src/auth/hooks/useAuthRedirect.ts +3 -2
- package/src/auth/hooks/useGithubAuth.ts +14 -16
- package/src/auth/hooks/useLocalStorage.ts +7 -7
- package/src/auth/hooks/useProfileCache.ts +2 -1
- package/src/auth/hooks/useSessionStorage.ts +7 -7
- package/src/auth/hooks/useTwoFactorVerify.ts +2 -2
- package/src/auth/types/form.ts +0 -5
- package/src/storage.ts +21 -0
package/dist/auth.d.cts
CHANGED
|
@@ -88,10 +88,6 @@ type OAuthTokenResponse = {
|
|
|
88
88
|
* True if user should be prompted to enable 2FA
|
|
89
89
|
*/
|
|
90
90
|
should_prompt_2fa?: boolean;
|
|
91
|
-
/**
|
|
92
|
-
* Whether this login should persist across browser restarts
|
|
93
|
-
*/
|
|
94
|
-
persistent_session?: boolean;
|
|
95
91
|
};
|
|
96
92
|
/**
|
|
97
93
|
* Serializer for OTP request.
|
|
@@ -148,10 +144,6 @@ type OtpVerifyRequest = {
|
|
|
148
144
|
* Source URL for tracking login (e.g., https://my.djangocfg.com)
|
|
149
145
|
*/
|
|
150
146
|
source_url?: string;
|
|
151
|
-
/**
|
|
152
|
-
* Keep this browser signed in for 30 days
|
|
153
|
-
*/
|
|
154
|
-
remember_me?: boolean;
|
|
155
147
|
};
|
|
156
148
|
/**
|
|
157
149
|
* OTP verification response.
|
|
@@ -191,10 +183,18 @@ type OtpVerifyResponse = {
|
|
|
191
183
|
* Whether user should be prompted to enable 2FA
|
|
192
184
|
*/
|
|
193
185
|
should_prompt_2fa?: boolean;
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Validate email+password against live accounts only.
|
|
189
|
+
*
|
|
190
|
+
* Subclasses SimpleJWT so the field/validation contract stays theirs, but
|
|
191
|
+
* replaces ``validate()`` — the token pair itself is minted by the view via
|
|
192
|
+
* ``mint_tokens_for_request`` so the DPoP binding and token
|
|
193
|
+
* lifetime match OTP, OAuth and TOTP exactly.
|
|
194
|
+
*/
|
|
195
|
+
type PasswordLoginRequest = {
|
|
196
|
+
email: string;
|
|
197
|
+
password: string;
|
|
198
198
|
};
|
|
199
199
|
/**
|
|
200
200
|
* Password-login response.
|
|
@@ -227,10 +227,6 @@ type PasswordLoginResponse = {
|
|
|
227
227
|
* Whether user should be prompted to enable 2FA
|
|
228
228
|
*/
|
|
229
229
|
should_prompt_2fa?: boolean;
|
|
230
|
-
/**
|
|
231
|
-
* Whether this login should persist across browser restarts
|
|
232
|
-
*/
|
|
233
|
-
persistent_session?: boolean;
|
|
234
230
|
};
|
|
235
231
|
/**
|
|
236
232
|
* Serializer for updating user profile.
|
|
@@ -456,22 +452,6 @@ declare enum WebmailLinkProviderEnum {
|
|
|
456
452
|
FREE_FR = "free_fr",
|
|
457
453
|
SFR = "sfr"
|
|
458
454
|
}
|
|
459
|
-
/**
|
|
460
|
-
* Validate email+password against live accounts only.
|
|
461
|
-
*
|
|
462
|
-
* Subclasses SimpleJWT so the field/validation contract stays theirs, but
|
|
463
|
-
* replaces ``validate()`` — the token pair itself is minted by the view via
|
|
464
|
-
* ``mint_tokens_for_request`` so the DPoP binding and remembered-session
|
|
465
|
-
* lifetime match OTP, OAuth and TOTP exactly.
|
|
466
|
-
*/
|
|
467
|
-
type PasswordLoginRequestWritable = {
|
|
468
|
-
/**
|
|
469
|
-
* Keep this browser signed in for 30 days
|
|
470
|
-
*/
|
|
471
|
-
remember_me?: boolean;
|
|
472
|
-
email: string;
|
|
473
|
-
password: string;
|
|
474
|
-
};
|
|
475
455
|
|
|
476
456
|
/**
|
|
477
457
|
* Auth Form Types
|
|
@@ -506,8 +486,6 @@ interface PasswordLoginOptions {
|
|
|
506
486
|
redirectUrl?: string;
|
|
507
487
|
/** Caller owns ALL navigation for this login, including the 2FA continuation. */
|
|
508
488
|
skipRedirect?: boolean;
|
|
509
|
-
/** Ask the server for a 30-day session instead of the default lifetime. */
|
|
510
|
-
rememberMe?: boolean;
|
|
511
489
|
}
|
|
512
490
|
/**
|
|
513
491
|
* Result of a password login.
|
|
@@ -547,8 +525,6 @@ interface AuthFormState {
|
|
|
547
525
|
* jurisdiction-aware default on mount.
|
|
548
526
|
*/
|
|
549
527
|
marketingConsent: boolean | null;
|
|
550
|
-
/** Keep this browser signed in for 30 days after successful verification. */
|
|
551
|
-
rememberMe: boolean;
|
|
552
528
|
/** Current form step */
|
|
553
529
|
step: AuthStep;
|
|
554
530
|
/** Error message */
|
|
@@ -572,7 +548,6 @@ interface AuthFormStateHandlers {
|
|
|
572
548
|
setPassword: (password: string) => void;
|
|
573
549
|
setAcceptedTerms: (accepted: boolean) => void;
|
|
574
550
|
setMarketingConsent: (consent: boolean | null) => void;
|
|
575
|
-
setRememberMe: (rememberMe: boolean) => void;
|
|
576
551
|
setError: (error: string) => void;
|
|
577
552
|
clearError: () => void;
|
|
578
553
|
setStep: (step: AuthStep) => void;
|
|
@@ -664,7 +639,7 @@ interface AuthContextType {
|
|
|
664
639
|
saveEmail: (email: string) => void;
|
|
665
640
|
clearSavedEmail: () => void;
|
|
666
641
|
requestOTP: (identifier: string, sourceUrl?: string, consent?: OTPRequestConsent) => Promise<OTPRequestResult>;
|
|
667
|
-
verifyOTP: (identifier: string, otpCode: string, sourceUrl?: string, redirectUrl?: string, skipRedirect?: boolean
|
|
642
|
+
verifyOTP: (identifier: string, otpCode: string, sourceUrl?: string, redirectUrl?: string, skipRedirect?: boolean) => Promise<{
|
|
668
643
|
success: boolean;
|
|
669
644
|
message: string;
|
|
670
645
|
user?: UserProfile;
|
|
@@ -725,7 +700,7 @@ interface AccountsContextValue {
|
|
|
725
700
|
}) => Promise<User | undefined>;
|
|
726
701
|
requestOTP: (data: OtpRequestRequest) => Promise<OtpRequestResponse>;
|
|
727
702
|
verifyOTP: (data: OtpVerifyRequest) => Promise<OtpVerifyResponse>;
|
|
728
|
-
loginWithPassword: (data:
|
|
703
|
+
loginWithPassword: (data: PasswordLoginRequest) => Promise<PasswordLoginResponse>;
|
|
729
704
|
logout: () => void;
|
|
730
705
|
}
|
|
731
706
|
interface AccountsProviderProps {
|
|
@@ -859,8 +834,6 @@ declare const useAutoAuth: (options?: UseAutoAuthOptions) => {
|
|
|
859
834
|
type OAuthUser = NonNullable<OAuthTokenResponse['user']>;
|
|
860
835
|
interface UseGithubAuthOptions {
|
|
861
836
|
sourceUrl?: string;
|
|
862
|
-
/** Keep the completed browser session for 30 days. */
|
|
863
|
-
rememberMe?: boolean;
|
|
864
837
|
/**
|
|
865
838
|
* The OAuth endpoint's OpenAPI schema types `user` as a free-form object, so
|
|
866
839
|
* this is what the server actually promises — not a `User`. Narrow it at the
|
package/dist/auth.d.ts
CHANGED
|
@@ -88,10 +88,6 @@ type OAuthTokenResponse = {
|
|
|
88
88
|
* True if user should be prompted to enable 2FA
|
|
89
89
|
*/
|
|
90
90
|
should_prompt_2fa?: boolean;
|
|
91
|
-
/**
|
|
92
|
-
* Whether this login should persist across browser restarts
|
|
93
|
-
*/
|
|
94
|
-
persistent_session?: boolean;
|
|
95
91
|
};
|
|
96
92
|
/**
|
|
97
93
|
* Serializer for OTP request.
|
|
@@ -148,10 +144,6 @@ type OtpVerifyRequest = {
|
|
|
148
144
|
* Source URL for tracking login (e.g., https://my.djangocfg.com)
|
|
149
145
|
*/
|
|
150
146
|
source_url?: string;
|
|
151
|
-
/**
|
|
152
|
-
* Keep this browser signed in for 30 days
|
|
153
|
-
*/
|
|
154
|
-
remember_me?: boolean;
|
|
155
147
|
};
|
|
156
148
|
/**
|
|
157
149
|
* OTP verification response.
|
|
@@ -191,10 +183,18 @@ type OtpVerifyResponse = {
|
|
|
191
183
|
* Whether user should be prompted to enable 2FA
|
|
192
184
|
*/
|
|
193
185
|
should_prompt_2fa?: boolean;
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Validate email+password against live accounts only.
|
|
189
|
+
*
|
|
190
|
+
* Subclasses SimpleJWT so the field/validation contract stays theirs, but
|
|
191
|
+
* replaces ``validate()`` — the token pair itself is minted by the view via
|
|
192
|
+
* ``mint_tokens_for_request`` so the DPoP binding and token
|
|
193
|
+
* lifetime match OTP, OAuth and TOTP exactly.
|
|
194
|
+
*/
|
|
195
|
+
type PasswordLoginRequest = {
|
|
196
|
+
email: string;
|
|
197
|
+
password: string;
|
|
198
198
|
};
|
|
199
199
|
/**
|
|
200
200
|
* Password-login response.
|
|
@@ -227,10 +227,6 @@ type PasswordLoginResponse = {
|
|
|
227
227
|
* Whether user should be prompted to enable 2FA
|
|
228
228
|
*/
|
|
229
229
|
should_prompt_2fa?: boolean;
|
|
230
|
-
/**
|
|
231
|
-
* Whether this login should persist across browser restarts
|
|
232
|
-
*/
|
|
233
|
-
persistent_session?: boolean;
|
|
234
230
|
};
|
|
235
231
|
/**
|
|
236
232
|
* Serializer for updating user profile.
|
|
@@ -456,22 +452,6 @@ declare enum WebmailLinkProviderEnum {
|
|
|
456
452
|
FREE_FR = "free_fr",
|
|
457
453
|
SFR = "sfr"
|
|
458
454
|
}
|
|
459
|
-
/**
|
|
460
|
-
* Validate email+password against live accounts only.
|
|
461
|
-
*
|
|
462
|
-
* Subclasses SimpleJWT so the field/validation contract stays theirs, but
|
|
463
|
-
* replaces ``validate()`` — the token pair itself is minted by the view via
|
|
464
|
-
* ``mint_tokens_for_request`` so the DPoP binding and remembered-session
|
|
465
|
-
* lifetime match OTP, OAuth and TOTP exactly.
|
|
466
|
-
*/
|
|
467
|
-
type PasswordLoginRequestWritable = {
|
|
468
|
-
/**
|
|
469
|
-
* Keep this browser signed in for 30 days
|
|
470
|
-
*/
|
|
471
|
-
remember_me?: boolean;
|
|
472
|
-
email: string;
|
|
473
|
-
password: string;
|
|
474
|
-
};
|
|
475
455
|
|
|
476
456
|
/**
|
|
477
457
|
* Auth Form Types
|
|
@@ -506,8 +486,6 @@ interface PasswordLoginOptions {
|
|
|
506
486
|
redirectUrl?: string;
|
|
507
487
|
/** Caller owns ALL navigation for this login, including the 2FA continuation. */
|
|
508
488
|
skipRedirect?: boolean;
|
|
509
|
-
/** Ask the server for a 30-day session instead of the default lifetime. */
|
|
510
|
-
rememberMe?: boolean;
|
|
511
489
|
}
|
|
512
490
|
/**
|
|
513
491
|
* Result of a password login.
|
|
@@ -547,8 +525,6 @@ interface AuthFormState {
|
|
|
547
525
|
* jurisdiction-aware default on mount.
|
|
548
526
|
*/
|
|
549
527
|
marketingConsent: boolean | null;
|
|
550
|
-
/** Keep this browser signed in for 30 days after successful verification. */
|
|
551
|
-
rememberMe: boolean;
|
|
552
528
|
/** Current form step */
|
|
553
529
|
step: AuthStep;
|
|
554
530
|
/** Error message */
|
|
@@ -572,7 +548,6 @@ interface AuthFormStateHandlers {
|
|
|
572
548
|
setPassword: (password: string) => void;
|
|
573
549
|
setAcceptedTerms: (accepted: boolean) => void;
|
|
574
550
|
setMarketingConsent: (consent: boolean | null) => void;
|
|
575
|
-
setRememberMe: (rememberMe: boolean) => void;
|
|
576
551
|
setError: (error: string) => void;
|
|
577
552
|
clearError: () => void;
|
|
578
553
|
setStep: (step: AuthStep) => void;
|
|
@@ -664,7 +639,7 @@ interface AuthContextType {
|
|
|
664
639
|
saveEmail: (email: string) => void;
|
|
665
640
|
clearSavedEmail: () => void;
|
|
666
641
|
requestOTP: (identifier: string, sourceUrl?: string, consent?: OTPRequestConsent) => Promise<OTPRequestResult>;
|
|
667
|
-
verifyOTP: (identifier: string, otpCode: string, sourceUrl?: string, redirectUrl?: string, skipRedirect?: boolean
|
|
642
|
+
verifyOTP: (identifier: string, otpCode: string, sourceUrl?: string, redirectUrl?: string, skipRedirect?: boolean) => Promise<{
|
|
668
643
|
success: boolean;
|
|
669
644
|
message: string;
|
|
670
645
|
user?: UserProfile;
|
|
@@ -725,7 +700,7 @@ interface AccountsContextValue {
|
|
|
725
700
|
}) => Promise<User | undefined>;
|
|
726
701
|
requestOTP: (data: OtpRequestRequest) => Promise<OtpRequestResponse>;
|
|
727
702
|
verifyOTP: (data: OtpVerifyRequest) => Promise<OtpVerifyResponse>;
|
|
728
|
-
loginWithPassword: (data:
|
|
703
|
+
loginWithPassword: (data: PasswordLoginRequest) => Promise<PasswordLoginResponse>;
|
|
729
704
|
logout: () => void;
|
|
730
705
|
}
|
|
731
706
|
interface AccountsProviderProps {
|
|
@@ -859,8 +834,6 @@ declare const useAutoAuth: (options?: UseAutoAuthOptions) => {
|
|
|
859
834
|
type OAuthUser = NonNullable<OAuthTokenResponse['user']>;
|
|
860
835
|
interface UseGithubAuthOptions {
|
|
861
836
|
sourceUrl?: string;
|
|
862
|
-
/** Keep the completed browser session for 30 days. */
|
|
863
|
-
rememberMe?: boolean;
|
|
864
837
|
/**
|
|
865
838
|
* The OAuth endpoint's OpenAPI schema types `user` as a free-form object, so
|
|
866
839
|
* this is what the server actually promises — not a `User`. Narrow it at the
|