@djangocfg/api 2.1.486 → 2.1.487
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.mjs
CHANGED
|
@@ -162,18 +162,7 @@ function backendFor(mode) {
|
|
|
162
162
|
return mode === "cookie" ? cookieBackend : mode === "sessionStorage" ? sessionStorageBackend : localStorageBackend;
|
|
163
163
|
}
|
|
164
164
|
__name(backendFor, "backendFor");
|
|
165
|
-
var
|
|
166
|
-
function readPersistedMode() {
|
|
167
|
-
if (!isBrowser) return "localStorage";
|
|
168
|
-
try {
|
|
169
|
-
const raw = window.localStorage.getItem(STORAGE_MODE_KEY);
|
|
170
|
-
return raw === "sessionStorage" || raw === "cookie" || raw === "localStorage" ? raw : "localStorage";
|
|
171
|
-
} catch {
|
|
172
|
-
return "localStorage";
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
__name(readPersistedMode, "readPersistedMode");
|
|
176
|
-
var _storageMode = readPersistedMode();
|
|
165
|
+
var _storageMode = "localStorage";
|
|
177
166
|
var _storage = backendFor(_storageMode);
|
|
178
167
|
function detectLocale() {
|
|
179
168
|
try {
|
|
@@ -328,15 +317,12 @@ var auth = {
|
|
|
328
317
|
getStorageMode() {
|
|
329
318
|
return _storageMode;
|
|
330
319
|
},
|
|
320
|
+
/** Relocate the session backend. Call once at bootstrap, before any sign-in:
|
|
321
|
+
* the mode is module state and resets on reload, so a later switch strands
|
|
322
|
+
* whatever was written after it. */
|
|
331
323
|
setStorageMode(mode) {
|
|
332
324
|
_storageMode = mode;
|
|
333
325
|
_storage = backendFor(mode);
|
|
334
|
-
if (isBrowser) {
|
|
335
|
-
try {
|
|
336
|
-
window.localStorage.setItem(STORAGE_MODE_KEY, mode);
|
|
337
|
-
} catch {
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
326
|
notifySessionChanged();
|
|
341
327
|
},
|
|
342
328
|
// ── Bearer token ──────────────────────────────────────────────────
|
|
@@ -359,14 +345,6 @@ var auth = {
|
|
|
359
345
|
backend.set(ACCESS_KEY, null);
|
|
360
346
|
backend.set(REFRESH_KEY, null);
|
|
361
347
|
}
|
|
362
|
-
_storageMode = "localStorage";
|
|
363
|
-
_storage = localStorageBackend;
|
|
364
|
-
if (isBrowser) {
|
|
365
|
-
try {
|
|
366
|
-
window.localStorage.removeItem(STORAGE_MODE_KEY);
|
|
367
|
-
} catch {
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
348
|
notifySessionChanged();
|
|
371
349
|
},
|
|
372
350
|
/** Session-aware: token PRESENT and not past its `exp` (or a live refresh
|
|
@@ -2738,7 +2716,6 @@ var useTwoFactorVerify = /* @__PURE__ */ __name((options = {}) => {
|
|
|
2738
2716
|
setError(null);
|
|
2739
2717
|
}, []);
|
|
2740
2718
|
const handleSuccess = useCallback4((response) => {
|
|
2741
|
-
auth.setStorageMode(response.persistent_session ? "localStorage" : "sessionStorage");
|
|
2742
2719
|
auth.setSession({ access: response.access_token, refresh: response.refresh_token });
|
|
2743
2720
|
if (response.warning) {
|
|
2744
2721
|
setWarning(response.warning);
|
|
@@ -3230,7 +3207,6 @@ var useGithubAuth = /* @__PURE__ */ __name((options = {}) => {
|
|
|
3230
3207
|
throw new Error("Invalid response from OAuth callback");
|
|
3231
3208
|
}
|
|
3232
3209
|
authLogger.info("GitHub OAuth successful, user:", response.user);
|
|
3233
|
-
auth.setStorageMode(response.persistent_session ? "localStorage" : "sessionStorage");
|
|
3234
3210
|
auth.setSession({ access: response.access, refresh: response.refresh });
|
|
3235
3211
|
Analytics.event("auth_login_success" /* AUTH_LOGIN_SUCCESS */, {
|
|
3236
3212
|
category: "auth" /* AUTH */,
|
|
@@ -4473,7 +4449,6 @@ function AccountsProvider({ children }) {
|
|
|
4473
4449
|
return result;
|
|
4474
4450
|
}
|
|
4475
4451
|
if (result.access && result.refresh) {
|
|
4476
|
-
auth.setStorageMode(result.persistent_session ? "localStorage" : "sessionStorage");
|
|
4477
4452
|
auth.setSession({ access: result.access, refresh: result.refresh });
|
|
4478
4453
|
try {
|
|
4479
4454
|
await refreshProfile({ callerId: "verifyOTP", force: true });
|