@djangocfg/api 2.1.484 → 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 +13 -7
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.mjs +13 -7
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +13 -4
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.mjs +13 -4
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +13 -4
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.mjs +13 -4
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +13 -4
- 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 +13 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/_api/generated/helpers/auth.ts +34 -8
- 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
|
@@ -228,8 +228,12 @@ var cookieBackend = {
|
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
};
|
|
231
|
-
|
|
231
|
+
function backendFor(mode) {
|
|
232
|
+
return mode === "cookie" ? cookieBackend : mode === "sessionStorage" ? sessionStorageBackend : localStorageBackend;
|
|
233
|
+
}
|
|
234
|
+
__name(backendFor, "backendFor");
|
|
232
235
|
var _storageMode = "localStorage";
|
|
236
|
+
var _storage = backendFor(_storageMode);
|
|
233
237
|
function detectLocale() {
|
|
234
238
|
try {
|
|
235
239
|
if (typeof document !== "undefined") {
|
|
@@ -383,9 +387,12 @@ var auth = {
|
|
|
383
387
|
getStorageMode() {
|
|
384
388
|
return _storageMode;
|
|
385
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. */
|
|
386
393
|
setStorageMode(mode) {
|
|
387
394
|
_storageMode = mode;
|
|
388
|
-
_storage = mode
|
|
395
|
+
_storage = backendFor(mode);
|
|
389
396
|
notifySessionChanged();
|
|
390
397
|
},
|
|
391
398
|
// ── Bearer token ──────────────────────────────────────────────────
|
|
@@ -404,8 +411,10 @@ var auth = {
|
|
|
404
411
|
notifySessionChanged();
|
|
405
412
|
},
|
|
406
413
|
clearTokens() {
|
|
407
|
-
|
|
408
|
-
|
|
414
|
+
for (const backend of [localStorageBackend, sessionStorageBackend, cookieBackend]) {
|
|
415
|
+
backend.set(ACCESS_KEY, null);
|
|
416
|
+
backend.set(REFRESH_KEY, null);
|
|
417
|
+
}
|
|
409
418
|
notifySessionChanged();
|
|
410
419
|
},
|
|
411
420
|
/** Session-aware: token PRESENT and not past its `exp` (or a live refresh
|
|
@@ -2777,7 +2786,6 @@ var useTwoFactorVerify = /* @__PURE__ */ __name((options = {}) => {
|
|
|
2777
2786
|
setError(null);
|
|
2778
2787
|
}, []);
|
|
2779
2788
|
const handleSuccess = (0, import_react8.useCallback)((response) => {
|
|
2780
|
-
auth.setStorageMode(response.persistent_session ? "localStorage" : "sessionStorage");
|
|
2781
2789
|
auth.setSession({ access: response.access_token, refresh: response.refresh_token });
|
|
2782
2790
|
if (response.warning) {
|
|
2783
2791
|
setWarning(response.warning);
|
|
@@ -3269,7 +3277,6 @@ var useGithubAuth = /* @__PURE__ */ __name((options = {}) => {
|
|
|
3269
3277
|
throw new Error("Invalid response from OAuth callback");
|
|
3270
3278
|
}
|
|
3271
3279
|
authLogger.info("GitHub OAuth successful, user:", response.user);
|
|
3272
|
-
auth.setStorageMode(response.persistent_session ? "localStorage" : "sessionStorage");
|
|
3273
3280
|
auth.setSession({ access: response.access, refresh: response.refresh });
|
|
3274
3281
|
Analytics.event("auth_login_success" /* AUTH_LOGIN_SUCCESS */, {
|
|
3275
3282
|
category: "auth" /* AUTH */,
|
|
@@ -4504,7 +4511,6 @@ function AccountsProvider({ children }) {
|
|
|
4504
4511
|
return result;
|
|
4505
4512
|
}
|
|
4506
4513
|
if (result.access && result.refresh) {
|
|
4507
|
-
auth.setStorageMode(result.persistent_session ? "localStorage" : "sessionStorage");
|
|
4508
4514
|
auth.setSession({ access: result.access, refresh: result.refresh });
|
|
4509
4515
|
try {
|
|
4510
4516
|
await refreshProfile({ callerId: "verifyOTP", force: true });
|