@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.mjs
CHANGED
|
@@ -158,8 +158,12 @@ var cookieBackend = {
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
};
|
|
161
|
-
|
|
161
|
+
function backendFor(mode) {
|
|
162
|
+
return mode === "cookie" ? cookieBackend : mode === "sessionStorage" ? sessionStorageBackend : localStorageBackend;
|
|
163
|
+
}
|
|
164
|
+
__name(backendFor, "backendFor");
|
|
162
165
|
var _storageMode = "localStorage";
|
|
166
|
+
var _storage = backendFor(_storageMode);
|
|
163
167
|
function detectLocale() {
|
|
164
168
|
try {
|
|
165
169
|
if (typeof document !== "undefined") {
|
|
@@ -313,9 +317,12 @@ var auth = {
|
|
|
313
317
|
getStorageMode() {
|
|
314
318
|
return _storageMode;
|
|
315
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. */
|
|
316
323
|
setStorageMode(mode) {
|
|
317
324
|
_storageMode = mode;
|
|
318
|
-
_storage = mode
|
|
325
|
+
_storage = backendFor(mode);
|
|
319
326
|
notifySessionChanged();
|
|
320
327
|
},
|
|
321
328
|
// ── Bearer token ──────────────────────────────────────────────────
|
|
@@ -334,8 +341,10 @@ var auth = {
|
|
|
334
341
|
notifySessionChanged();
|
|
335
342
|
},
|
|
336
343
|
clearTokens() {
|
|
337
|
-
|
|
338
|
-
|
|
344
|
+
for (const backend of [localStorageBackend, sessionStorageBackend, cookieBackend]) {
|
|
345
|
+
backend.set(ACCESS_KEY, null);
|
|
346
|
+
backend.set(REFRESH_KEY, null);
|
|
347
|
+
}
|
|
339
348
|
notifySessionChanged();
|
|
340
349
|
},
|
|
341
350
|
/** Session-aware: token PRESENT and not past its `exp` (or a live refresh
|
|
@@ -2707,7 +2716,6 @@ var useTwoFactorVerify = /* @__PURE__ */ __name((options = {}) => {
|
|
|
2707
2716
|
setError(null);
|
|
2708
2717
|
}, []);
|
|
2709
2718
|
const handleSuccess = useCallback4((response) => {
|
|
2710
|
-
auth.setStorageMode(response.persistent_session ? "localStorage" : "sessionStorage");
|
|
2711
2719
|
auth.setSession({ access: response.access_token, refresh: response.refresh_token });
|
|
2712
2720
|
if (response.warning) {
|
|
2713
2721
|
setWarning(response.warning);
|
|
@@ -3199,7 +3207,6 @@ var useGithubAuth = /* @__PURE__ */ __name((options = {}) => {
|
|
|
3199
3207
|
throw new Error("Invalid response from OAuth callback");
|
|
3200
3208
|
}
|
|
3201
3209
|
authLogger.info("GitHub OAuth successful, user:", response.user);
|
|
3202
|
-
auth.setStorageMode(response.persistent_session ? "localStorage" : "sessionStorage");
|
|
3203
3210
|
auth.setSession({ access: response.access, refresh: response.refresh });
|
|
3204
3211
|
Analytics.event("auth_login_success" /* AUTH_LOGIN_SUCCESS */, {
|
|
3205
3212
|
category: "auth" /* AUTH */,
|
|
@@ -4442,7 +4449,6 @@ function AccountsProvider({ children }) {
|
|
|
4442
4449
|
return result;
|
|
4443
4450
|
}
|
|
4444
4451
|
if (result.access && result.refresh) {
|
|
4445
|
-
auth.setStorageMode(result.persistent_session ? "localStorage" : "sessionStorage");
|
|
4446
4452
|
auth.setSession({ access: result.access, refresh: result.refresh });
|
|
4447
4453
|
try {
|
|
4448
4454
|
await refreshProfile({ callerId: "verifyOTP", force: true });
|