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