@djangocfg/api 2.1.583 → 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/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 +12 -28
- 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 +12 -26
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +0 -1
- 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 +0 -1
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +0 -1
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.mjs +0 -1
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +0 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -64
- package/dist/index.d.ts +7 -64
- package/dist/index.mjs +0 -1
- package/dist/index.mjs.map +1 -1
- package/dist/storage.cjs +0 -1
- package/dist/storage.cjs.map +1 -1
- package/dist/storage.d.cts +0 -1
- package/dist/storage.d.ts +0 -1
- package/dist/storage.mjs +0 -1
- package/dist/storage.mjs.map +1 -1
- package/package.json +2 -2
- 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 +1 -1
- package/src/_api/generated/helpers/keys.ts +0 -1
- package/src/_api/generated/openapi.json +1 -33
- package/src/_api/generated/types.gen.ts +4 -59
- package/src/auth/__tests__/passwordLogin.test.tsx +1 -3
- package/src/auth/context/AccountsContext.tsx +6 -8
- package/src/auth/context/AuthContext.tsx +1 -4
- 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/useGithubAuth.ts +5 -12
- package/src/auth/hooks/useTwoFactorVerify.ts +2 -2
- package/src/auth/types/form.ts +0 -5
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
|
package/dist/auth.mjs
CHANGED
|
@@ -105,7 +105,6 @@ var CFG_KEYS = {
|
|
|
105
105
|
redirectUrlTs: k("cfg.auth.redirect_url_ts", "session", true),
|
|
106
106
|
oauthState: k("cfg.auth.oauth_state", "session", true),
|
|
107
107
|
oauthProvider: k("cfg.auth.oauth_provider", "session", true),
|
|
108
|
-
oauthRememberMe: k("cfg.auth.oauth_remember_me", "session", true),
|
|
109
108
|
profileCache: k("cfg.profile.cache", "local", true),
|
|
110
109
|
monitorSessionId: k("cfg.monitor.session_id", "local", false),
|
|
111
110
|
monitorSessionCookie: k("cfg.monitor.session_id", "cookie", false),
|
|
@@ -1198,7 +1197,6 @@ var useAuthFormState = /* @__PURE__ */ __name((initialIdentifier = "") => {
|
|
|
1198
1197
|
const [isLoading, setIsLoading] = useState2(false);
|
|
1199
1198
|
const [acceptedTerms, setAcceptedTerms] = useState2(true);
|
|
1200
1199
|
const [marketingConsent, setMarketingConsent] = useState2(null);
|
|
1201
|
-
const [rememberMe, setRememberMe] = useState2(true);
|
|
1202
1200
|
const [step, setStep] = useState2("identifier");
|
|
1203
1201
|
const [error, setError] = useState2("");
|
|
1204
1202
|
const [webmail, setWebmail] = useState2(null);
|
|
@@ -1213,7 +1211,6 @@ var useAuthFormState = /* @__PURE__ */ __name((initialIdentifier = "") => {
|
|
|
1213
1211
|
isLoading,
|
|
1214
1212
|
acceptedTerms,
|
|
1215
1213
|
marketingConsent,
|
|
1216
|
-
rememberMe,
|
|
1217
1214
|
step,
|
|
1218
1215
|
error,
|
|
1219
1216
|
rateLimitSeconds: rateLimit.seconds,
|
|
@@ -1228,7 +1225,6 @@ var useAuthFormState = /* @__PURE__ */ __name((initialIdentifier = "") => {
|
|
|
1228
1225
|
setPassword,
|
|
1229
1226
|
setAcceptedTerms,
|
|
1230
1227
|
setMarketingConsent,
|
|
1231
|
-
setRememberMe,
|
|
1232
1228
|
setError,
|
|
1233
1229
|
clearError,
|
|
1234
1230
|
setStep,
|
|
@@ -1363,7 +1359,6 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
1363
1359
|
password,
|
|
1364
1360
|
acceptedTerms,
|
|
1365
1361
|
marketingConsent,
|
|
1366
|
-
rememberMe,
|
|
1367
1362
|
setIdentifier,
|
|
1368
1363
|
setOtp,
|
|
1369
1364
|
setStep,
|
|
@@ -1460,7 +1455,7 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
1460
1455
|
setIsLoading(true);
|
|
1461
1456
|
clearError();
|
|
1462
1457
|
try {
|
|
1463
|
-
const result = await verifyOTP(submitIdentifier, submitOtp, sourceUrl, redirectUrl, true
|
|
1458
|
+
const result = await verifyOTP(submitIdentifier, submitOtp, sourceUrl, redirectUrl, true);
|
|
1464
1459
|
if (result.requires_2fa && result.session_id) {
|
|
1465
1460
|
authLogger.info("2FA required after OTP verification");
|
|
1466
1461
|
beginTwoFactorChallenge({ sessionId: result.session_id });
|
|
@@ -1486,7 +1481,7 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
1486
1481
|
} finally {
|
|
1487
1482
|
setIsLoading(false);
|
|
1488
1483
|
}
|
|
1489
|
-
}, [verifyOTP, saveIdentifierToStorage, setError, setIsLoading, clearError, onOTPSuccess, onError, sourceUrl, redirectUrl,
|
|
1484
|
+
}, [verifyOTP, saveIdentifierToStorage, setError, setIsLoading, clearError, onOTPSuccess, onError, sourceUrl, redirectUrl, setStep]);
|
|
1490
1485
|
const handleOTPSubmit = useCallback4(async (e) => {
|
|
1491
1486
|
e.preventDefault();
|
|
1492
1487
|
await submitOTP(identifier, otp);
|
|
@@ -1509,8 +1504,7 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
1509
1504
|
try {
|
|
1510
1505
|
const result = await login(submitIdentifier, submitPassword_, {
|
|
1511
1506
|
redirectUrl,
|
|
1512
|
-
skipRedirect: true
|
|
1513
|
-
rememberMe
|
|
1507
|
+
skipRedirect: true
|
|
1514
1508
|
});
|
|
1515
1509
|
if (result.requires_2fa && result.session_id) {
|
|
1516
1510
|
authLogger.info("2FA required after password login");
|
|
@@ -1552,7 +1546,6 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
1552
1546
|
onOTPSuccess,
|
|
1553
1547
|
onError,
|
|
1554
1548
|
redirectUrl,
|
|
1555
|
-
rememberMe,
|
|
1556
1549
|
setStep
|
|
1557
1550
|
]);
|
|
1558
1551
|
const handlePasswordSubmit = useCallback4(async (e) => {
|
|
@@ -3072,9 +3065,8 @@ var logAuthFailure = /* @__PURE__ */ __name((log, message, error) => {
|
|
|
3072
3065
|
// src/auth/hooks/useGithubAuth.ts
|
|
3073
3066
|
var OAUTH_STATE_KEY = CFG_KEYS.oauthState.key;
|
|
3074
3067
|
var OAUTH_PROVIDER_KEY = CFG_KEYS.oauthProvider.key;
|
|
3075
|
-
var OAUTH_REMEMBER_KEY = CFG_KEYS.oauthRememberMe.key;
|
|
3076
3068
|
var useGithubAuth = /* @__PURE__ */ __name((options = {}) => {
|
|
3077
|
-
const { sourceUrl,
|
|
3069
|
+
const { sourceUrl, onSuccess, onError, onRequires2FA, redirectUrl, skipRedirect = false } = options;
|
|
3078
3070
|
const router = useCfgRouter();
|
|
3079
3071
|
const [isLoading, setIsLoading] = useState3(false);
|
|
3080
3072
|
const [error, setError] = useState3(null);
|
|
@@ -3102,7 +3094,6 @@ var useGithubAuth = /* @__PURE__ */ __name((options = {}) => {
|
|
|
3102
3094
|
if (typeof window !== "undefined") {
|
|
3103
3095
|
sessionStorage.setItem(OAUTH_STATE_KEY, response.state);
|
|
3104
3096
|
sessionStorage.setItem(OAUTH_PROVIDER_KEY, "github");
|
|
3105
|
-
sessionStorage.setItem(OAUTH_REMEMBER_KEY, String(rememberMe));
|
|
3106
3097
|
}
|
|
3107
3098
|
window.location.href = response.authorization_url;
|
|
3108
3099
|
} catch (err) {
|
|
@@ -3117,25 +3108,22 @@ var useGithubAuth = /* @__PURE__ */ __name((options = {}) => {
|
|
|
3117
3108
|
} finally {
|
|
3118
3109
|
setIsLoading(false);
|
|
3119
3110
|
}
|
|
3120
|
-
}, [sourceUrl,
|
|
3111
|
+
}, [sourceUrl, onError]);
|
|
3121
3112
|
const handleGithubCallback = useCallback5(async (code, state) => {
|
|
3122
3113
|
setIsLoading(true);
|
|
3123
3114
|
setError(null);
|
|
3124
3115
|
try {
|
|
3125
3116
|
authLogger.info("Processing GitHub OAuth callback...");
|
|
3126
|
-
let rememberMeForSession = false;
|
|
3127
3117
|
if (typeof window !== "undefined") {
|
|
3128
3118
|
const storedState = sessionStorage.getItem(OAUTH_STATE_KEY);
|
|
3129
3119
|
if (storedState && storedState !== state) {
|
|
3130
3120
|
throw new Error("Invalid OAuth state - possible CSRF attack");
|
|
3131
3121
|
}
|
|
3132
|
-
rememberMeForSession = sessionStorage.getItem(OAUTH_REMEMBER_KEY) === "true";
|
|
3133
3122
|
sessionStorage.removeItem(OAUTH_STATE_KEY);
|
|
3134
3123
|
sessionStorage.removeItem(OAUTH_PROVIDER_KEY);
|
|
3135
|
-
sessionStorage.removeItem(OAUTH_REMEMBER_KEY);
|
|
3136
3124
|
}
|
|
3137
3125
|
const result = await CfgAccountsOauth.cfgAccountsOauthGithubCallbackCreate({
|
|
3138
|
-
body: { code, state
|
|
3126
|
+
body: { code, state },
|
|
3139
3127
|
throwOnError: true
|
|
3140
3128
|
});
|
|
3141
3129
|
const response = result.data;
|
|
@@ -4163,7 +4151,7 @@ function useCfgAccountsOtpVerifyCreate(config) {
|
|
|
4163
4151
|
async (_key, { arg }) => {
|
|
4164
4152
|
const res = await CfgAccountsOtp.cfgAccountsOtpVerifyCreate({ ...arg, throwOnError: true });
|
|
4165
4153
|
const data = res.data;
|
|
4166
|
-
void import("./OTPVerifyResponse-
|
|
4154
|
+
void import("./OTPVerifyResponse-P5LDNM7H.mjs").then(({ OTPVerifyResponseSchema }) => {
|
|
4167
4155
|
const parsed = OTPVerifyResponseSchema.safeParse(data);
|
|
4168
4156
|
if (parsed.success) return;
|
|
4169
4157
|
console.warn(
|
|
@@ -4374,7 +4362,7 @@ function useCfgAccountsTokenCreate(config) {
|
|
|
4374
4362
|
async (_key, { arg }) => {
|
|
4375
4363
|
const res = await CfgAccountsAuth.cfgAccountsTokenCreate({ ...arg, throwOnError: true });
|
|
4376
4364
|
const data = res.data;
|
|
4377
|
-
void import("./PasswordLoginResponse-
|
|
4365
|
+
void import("./PasswordLoginResponse-33B576NG.mjs").then(({ PasswordLoginResponseSchema }) => {
|
|
4378
4366
|
const parsed = PasswordLoginResponseSchema.safeParse(data);
|
|
4379
4367
|
if (parsed.success) return;
|
|
4380
4368
|
console.warn(
|
|
@@ -4739,14 +4727,13 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4739
4727
|
[]
|
|
4740
4728
|
);
|
|
4741
4729
|
const verifyOTP = useCallback11(
|
|
4742
|
-
async (identifier, otpCode, sourceUrl, redirectUrl, skipRedirect
|
|
4730
|
+
async (identifier, otpCode, sourceUrl, redirectUrl, skipRedirect) => {
|
|
4743
4731
|
try {
|
|
4744
4732
|
pendingManualNavRef.current = Boolean(skipRedirect);
|
|
4745
4733
|
const result = await accountsRef.current.verifyOTP({
|
|
4746
4734
|
identifier,
|
|
4747
4735
|
otp: otpCode,
|
|
4748
|
-
source_url: sourceUrl
|
|
4749
|
-
remember_me: rememberMe
|
|
4736
|
+
source_url: sourceUrl
|
|
4750
4737
|
});
|
|
4751
4738
|
if (result.requires_2fa && result.session_id) {
|
|
4752
4739
|
authLogger.info("2FA required, session:", result.session_id);
|
|
@@ -4801,13 +4788,12 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4801
4788
|
);
|
|
4802
4789
|
const login = useCallback11(
|
|
4803
4790
|
async (email, password, options) => {
|
|
4804
|
-
const { redirectUrl, skipRedirect
|
|
4791
|
+
const { redirectUrl, skipRedirect } = options || {};
|
|
4805
4792
|
try {
|
|
4806
4793
|
pendingManualNavRef.current = Boolean(skipRedirect);
|
|
4807
4794
|
const result = await accountsRef.current.loginWithPassword({
|
|
4808
4795
|
email,
|
|
4809
|
-
password
|
|
4810
|
-
remember_me: rememberMe
|
|
4796
|
+
password
|
|
4811
4797
|
});
|
|
4812
4798
|
if (result.requires_2fa && result.session_id) {
|
|
4813
4799
|
authLogger.info("2FA required, session:", result.session_id);
|