@djangocfg/api 2.1.486 → 2.1.488
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 +4 -29
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.mjs +4 -29
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +4 -26
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.mjs +4 -26
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +4 -26
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.mjs +4 -26
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +4 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +4 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/_api/generated/helpers/auth.ts +18 -36
- package/src/auth/context/AccountsContext.tsx +5 -1
- package/src/auth/hooks/useGithubAuth.ts +3 -2
- package/src/auth/hooks/useTwoFactorVerify.ts +2 -1
package/dist/auth.cjs
CHANGED
|
@@ -232,18 +232,7 @@ function backendFor(mode) {
|
|
|
232
232
|
return mode === "cookie" ? cookieBackend : mode === "sessionStorage" ? sessionStorageBackend : localStorageBackend;
|
|
233
233
|
}
|
|
234
234
|
__name(backendFor, "backendFor");
|
|
235
|
-
var
|
|
236
|
-
function readPersistedMode() {
|
|
237
|
-
if (!isBrowser) return "localStorage";
|
|
238
|
-
try {
|
|
239
|
-
const raw = window.localStorage.getItem(STORAGE_MODE_KEY);
|
|
240
|
-
return raw === "sessionStorage" || raw === "cookie" || raw === "localStorage" ? raw : "localStorage";
|
|
241
|
-
} catch {
|
|
242
|
-
return "localStorage";
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
__name(readPersistedMode, "readPersistedMode");
|
|
246
|
-
var _storageMode = readPersistedMode();
|
|
235
|
+
var _storageMode = "localStorage";
|
|
247
236
|
var _storage = backendFor(_storageMode);
|
|
248
237
|
function detectLocale() {
|
|
249
238
|
try {
|
|
@@ -398,15 +387,12 @@ var auth = {
|
|
|
398
387
|
getStorageMode() {
|
|
399
388
|
return _storageMode;
|
|
400
389
|
},
|
|
390
|
+
/** Relocate the session backend. Call once at bootstrap, before any sign-in:
|
|
391
|
+
* the mode is module state and resets on reload, so a later switch strands
|
|
392
|
+
* whatever was written after it. */
|
|
401
393
|
setStorageMode(mode) {
|
|
402
394
|
_storageMode = mode;
|
|
403
395
|
_storage = backendFor(mode);
|
|
404
|
-
if (isBrowser) {
|
|
405
|
-
try {
|
|
406
|
-
window.localStorage.setItem(STORAGE_MODE_KEY, mode);
|
|
407
|
-
} catch {
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
396
|
notifySessionChanged();
|
|
411
397
|
},
|
|
412
398
|
// ── Bearer token ──────────────────────────────────────────────────
|
|
@@ -429,14 +415,6 @@ var auth = {
|
|
|
429
415
|
backend.set(ACCESS_KEY, null);
|
|
430
416
|
backend.set(REFRESH_KEY, null);
|
|
431
417
|
}
|
|
432
|
-
_storageMode = "localStorage";
|
|
433
|
-
_storage = localStorageBackend;
|
|
434
|
-
if (isBrowser) {
|
|
435
|
-
try {
|
|
436
|
-
window.localStorage.removeItem(STORAGE_MODE_KEY);
|
|
437
|
-
} catch {
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
418
|
notifySessionChanged();
|
|
441
419
|
},
|
|
442
420
|
/** Session-aware: token PRESENT and not past its `exp` (or a live refresh
|
|
@@ -2808,7 +2786,6 @@ var useTwoFactorVerify = /* @__PURE__ */ __name((options = {}) => {
|
|
|
2808
2786
|
setError(null);
|
|
2809
2787
|
}, []);
|
|
2810
2788
|
const handleSuccess = (0, import_react8.useCallback)((response) => {
|
|
2811
|
-
auth.setStorageMode(response.persistent_session ? "localStorage" : "sessionStorage");
|
|
2812
2789
|
auth.setSession({ access: response.access_token, refresh: response.refresh_token });
|
|
2813
2790
|
if (response.warning) {
|
|
2814
2791
|
setWarning(response.warning);
|
|
@@ -3300,7 +3277,6 @@ var useGithubAuth = /* @__PURE__ */ __name((options = {}) => {
|
|
|
3300
3277
|
throw new Error("Invalid response from OAuth callback");
|
|
3301
3278
|
}
|
|
3302
3279
|
authLogger.info("GitHub OAuth successful, user:", response.user);
|
|
3303
|
-
auth.setStorageMode(response.persistent_session ? "localStorage" : "sessionStorage");
|
|
3304
3280
|
auth.setSession({ access: response.access, refresh: response.refresh });
|
|
3305
3281
|
Analytics.event("auth_login_success" /* AUTH_LOGIN_SUCCESS */, {
|
|
3306
3282
|
category: "auth" /* AUTH */,
|
|
@@ -4535,7 +4511,6 @@ function AccountsProvider({ children }) {
|
|
|
4535
4511
|
return result;
|
|
4536
4512
|
}
|
|
4537
4513
|
if (result.access && result.refresh) {
|
|
4538
|
-
auth.setStorageMode(result.persistent_session ? "localStorage" : "sessionStorage");
|
|
4539
4514
|
auth.setSession({ access: result.access, refresh: result.refresh });
|
|
4540
4515
|
try {
|
|
4541
4516
|
await refreshProfile({ callerId: "verifyOTP", force: true });
|