varminer-app-header 2.2.5 → 2.2.6
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/AppHeader.d.ts.map +1 -1
- package/dist/index.esm.js +7 -37
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +7 -37
- package/dist/index.js.map +1 -1
- package/dist/utils/localStorage.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/AppHeader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppHeader.d.ts","sourceRoot":"","sources":["../src/AppHeader.tsx"],"names":[],"mappings":"AA4BA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAe,MAAM,SAAS,CAAC;AAKtD,OAAO,sBAAsB,CAAC;AAQ9B,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,
|
|
1
|
+
{"version":3,"file":"AppHeader.d.ts","sourceRoot":"","sources":["../src/AppHeader.tsx"],"names":[],"mappings":"AA4BA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAe,MAAM,SAAS,CAAC;AAKtD,OAAO,sBAAsB,CAAC;AAQ9B,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAszBvC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -379,7 +379,7 @@ const getProfilePictureUrl = (baseUrl = "http://objectstore.impact0mics.local:90
|
|
|
379
379
|
const userId = allData.decodedToken?.user_id ?? allData.auth?.user_id ?? getStoredUserDetails()?.userId ?? null;
|
|
380
380
|
if (userId == null)
|
|
381
381
|
return null;
|
|
382
|
-
return `${baseUrl.replace(/\/$/, "")}/v1/objectStore/profilePicture/path
|
|
382
|
+
return `${baseUrl.replace(/\/$/, "")}/v1/objectStore/profilePicture/path/4590`;
|
|
383
383
|
}
|
|
384
384
|
catch (err) {
|
|
385
385
|
console.error("Error getting profile picture URL:", err);
|
|
@@ -452,37 +452,30 @@ function parseNestedValue(val) {
|
|
|
452
452
|
return parsePersistValue(val);
|
|
453
453
|
return val;
|
|
454
454
|
}
|
|
455
|
-
const AUTH_DEBUG = true; // set to false to disable access-token debug logs
|
|
456
455
|
/**
|
|
457
456
|
* Extract access token from persist:userdb shape: authDetails (string) → parse → auth.accessToken.
|
|
458
457
|
* Structure: { authDetails: "{\"auth\":{\"accessToken\":\"...\"}}", profileInformation: "...", _persist: "..." }
|
|
459
458
|
*/
|
|
460
459
|
function getTokenFromUserDbPersist(parsed) {
|
|
461
|
-
console.log("[header-auth] getTokenFromUserDbPersist: parsed keys", Object.keys(parsed));
|
|
462
460
|
const authDetails = parsed.authDetails;
|
|
463
461
|
const inner = parseNestedValue(authDetails);
|
|
464
462
|
const obj = typeof inner === "object" && inner !== null ? inner : null;
|
|
465
|
-
console.log("[header-auth] getTokenFromUserDbPersist: inner type", typeof inner, "obj keys", obj ? Object.keys(obj) : null);
|
|
466
463
|
if (!obj)
|
|
467
464
|
return undefined;
|
|
468
465
|
const auth = obj.auth;
|
|
469
466
|
const authObj = typeof auth === "object" && auth !== null ? auth : null;
|
|
470
|
-
console.log("[header-auth] getTokenFromUserDbPersist: authObj keys", authObj ? Object.keys(authObj) : null);
|
|
471
467
|
if (!authObj)
|
|
472
468
|
return undefined;
|
|
473
469
|
const token = authObj.accessToken ??
|
|
474
470
|
authObj.access_token ??
|
|
475
471
|
authObj.token;
|
|
476
|
-
|
|
477
|
-
console.log("[header-auth] getTokenFromUserDbPersist: token found", !!ok, "length", typeof token === "string" ? token.length : 0);
|
|
478
|
-
return ok ? token : undefined;
|
|
472
|
+
return typeof token === "string" && looksLikeToken(token) ? token : undefined;
|
|
479
473
|
}
|
|
480
474
|
/**
|
|
481
475
|
* Get access token from all known storage keys (header, IAM, userdb, and plain keys).
|
|
482
476
|
* persist:userdb shape: authDetails (stringified) contains auth.accessToken.
|
|
483
477
|
*/
|
|
484
478
|
function getAccessTokenForRequest() {
|
|
485
|
-
console.log("[header-auth] getAccessTokenForRequest: start");
|
|
486
479
|
const keysToTry = [
|
|
487
480
|
PERSIST_HEADER_KEY,
|
|
488
481
|
"persist:linn-i-am",
|
|
@@ -493,7 +486,6 @@ function getAccessTokenForRequest() {
|
|
|
493
486
|
];
|
|
494
487
|
for (const key of keysToTry) {
|
|
495
488
|
const raw = localStorage.getItem(key);
|
|
496
|
-
console.log("[header-auth] getAccessTokenForRequest: key", key, "raw present", !!raw, "raw length", raw?.length ?? 0);
|
|
497
489
|
if (!raw)
|
|
498
490
|
continue;
|
|
499
491
|
const parsed = key.startsWith("persist:") ? parsePersistValue(raw) : (() => { try {
|
|
@@ -503,59 +495,39 @@ function getAccessTokenForRequest() {
|
|
|
503
495
|
return raw;
|
|
504
496
|
} })();
|
|
505
497
|
const token = findTokenInObject(parsed);
|
|
506
|
-
if (token)
|
|
507
|
-
console.log("[header-auth] getAccessTokenForRequest: token from findTokenInObject(parsed), key", key);
|
|
498
|
+
if (token)
|
|
508
499
|
return token;
|
|
509
|
-
}
|
|
510
500
|
if (key.startsWith("persist:")) {
|
|
511
501
|
const outer = typeof parsed === "object" && parsed !== null ? parsed : null;
|
|
512
502
|
if (outer) {
|
|
513
503
|
if (key === "persist:userdb") {
|
|
514
504
|
const fromUserDb = getTokenFromUserDbPersist(outer);
|
|
515
|
-
if (fromUserDb)
|
|
516
|
-
console.log("[header-auth] getAccessTokenForRequest: token from getTokenFromUserDbPersist");
|
|
505
|
+
if (fromUserDb)
|
|
517
506
|
return fromUserDb;
|
|
518
|
-
}
|
|
519
507
|
}
|
|
520
508
|
for (const k of Object.keys(outer)) {
|
|
521
509
|
const inner = parseNestedValue(outer[k]);
|
|
522
510
|
const t = findTokenInObject(inner);
|
|
523
|
-
if (t)
|
|
524
|
-
console.log("[header-auth] getAccessTokenForRequest: token from inner key", k);
|
|
511
|
+
if (t)
|
|
525
512
|
return t;
|
|
526
|
-
}
|
|
527
513
|
}
|
|
528
514
|
}
|
|
529
515
|
}
|
|
530
516
|
}
|
|
531
|
-
|
|
532
|
-
const fallback = getAccessTokenFromAuth(allData.auth);
|
|
533
|
-
console.log("[header-auth] getAccessTokenForRequest: fallback getAllDataFromStorage().auth, token present", !!fallback);
|
|
534
|
-
return fallback;
|
|
517
|
+
return getAccessTokenFromAuth(getAllDataFromStorage().auth);
|
|
535
518
|
}
|
|
536
519
|
const fetchProfilePictureAsBlobUrl = async (baseUrl = "http://objectstore.impact0mics.local:9012", accessTokenOverride) => {
|
|
537
520
|
try {
|
|
538
|
-
if (AUTH_DEBUG)
|
|
539
|
-
console.log("[header-auth] fetchProfilePictureAsBlobUrl: start, accessTokenOverride present", typeof accessTokenOverride === "string" && accessTokenOverride.length > 0);
|
|
540
521
|
const profilePictureUrl = getProfilePictureUrl(baseUrl);
|
|
541
|
-
if (!profilePictureUrl)
|
|
542
|
-
if (AUTH_DEBUG)
|
|
543
|
-
console.log("[header-auth] fetchProfilePictureAsBlobUrl: no profilePictureUrl, abort");
|
|
522
|
+
if (!profilePictureUrl)
|
|
544
523
|
return null;
|
|
545
|
-
}
|
|
546
|
-
if (AUTH_DEBUG)
|
|
547
|
-
console.log("[header-auth] fetchProfilePictureAsBlobUrl: profilePictureUrl", profilePictureUrl);
|
|
548
524
|
const accessToken = (typeof accessTokenOverride === "string" && accessTokenOverride.length > 0
|
|
549
525
|
? accessTokenOverride
|
|
550
526
|
: null) ?? getAccessTokenForRequest();
|
|
551
|
-
if (AUTH_DEBUG)
|
|
552
|
-
console.log("[header-auth] fetchProfilePictureAsBlobUrl: accessToken present", !!accessToken, "length", accessToken?.length ?? 0);
|
|
553
527
|
const headers = {};
|
|
554
528
|
if (accessToken) {
|
|
555
529
|
headers["Authorization"] = `Bearer ${accessToken}`;
|
|
556
530
|
}
|
|
557
|
-
if (AUTH_DEBUG)
|
|
558
|
-
console.log("[header-auth] fetchProfilePictureAsBlobUrl: request headers", { ...headers, Authorization: headers["Authorization"] ? "Bearer ***" : "(none)" });
|
|
559
531
|
const response = await fetch(profilePictureUrl, { method: "GET", headers });
|
|
560
532
|
if (!response.ok) {
|
|
561
533
|
console.warn(`Failed to fetch profile picture: ${response.status} ${response.statusText}`);
|
|
@@ -810,9 +782,7 @@ const AppHeader = ({ language: languageProp, accessToken: accessTokenProp }) =>
|
|
|
810
782
|
// Fetch profile picture from API when component mounts or user data changes
|
|
811
783
|
React__default.useEffect(() => {
|
|
812
784
|
const fetchProfilePicture = async () => {
|
|
813
|
-
console.log("[header-auth] AppHeader: profile picture effect, accessTokenProp present", !!accessTokenProp);
|
|
814
785
|
const token = accessTokenProp ?? getAccessTokenForRequest();
|
|
815
|
-
console.log("[header-auth] AppHeader: token for request present", !!token, "from prop", !!accessTokenProp);
|
|
816
786
|
const blobUrl = await fetchProfilePictureAsBlobUrl(undefined, token ?? undefined);
|
|
817
787
|
if (blobUrl) {
|
|
818
788
|
// Clean up previous blob URL if it exists
|