varminer-app-header 2.2.8 → 2.3.0
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/README.md +93 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.esm.js +39 -18
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +39 -18
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/localStorage.d.ts +2 -2
- package/dist/utils/localStorage.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# varminer-app-header-npm-fe
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Getting started
|
|
6
|
+
|
|
7
|
+
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
|
8
|
+
|
|
9
|
+
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
|
10
|
+
|
|
11
|
+
## Add your files
|
|
12
|
+
|
|
13
|
+
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
|
14
|
+
- [ ] [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
cd existing_repo
|
|
18
|
+
git remote add origin https://gitlab.medgenome.com/mgm-linc/varminer-app-header-npm-fe.git
|
|
19
|
+
git branch -M main
|
|
20
|
+
git push -uf origin main
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Integrate with your tools
|
|
24
|
+
|
|
25
|
+
- [ ] [Set up project integrations](https://gitlab.medgenome.com/mgm-linc/varminer-app-header-npm-fe/-/settings/integrations)
|
|
26
|
+
|
|
27
|
+
## Collaborate with your team
|
|
28
|
+
|
|
29
|
+
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
|
30
|
+
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
|
31
|
+
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
|
32
|
+
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
|
33
|
+
- [ ] [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)
|
|
34
|
+
|
|
35
|
+
## Test and Deploy
|
|
36
|
+
|
|
37
|
+
Use the built-in continuous integration in GitLab.
|
|
38
|
+
|
|
39
|
+
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/)
|
|
40
|
+
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
|
41
|
+
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
|
42
|
+
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
|
43
|
+
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
|
44
|
+
|
|
45
|
+
***
|
|
46
|
+
|
|
47
|
+
# Editing this README
|
|
48
|
+
|
|
49
|
+
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
|
50
|
+
|
|
51
|
+
## Suggestions for a good README
|
|
52
|
+
|
|
53
|
+
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
54
|
+
|
|
55
|
+
## Name
|
|
56
|
+
Choose a self-explaining name for your project.
|
|
57
|
+
|
|
58
|
+
## Description
|
|
59
|
+
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
60
|
+
|
|
61
|
+
## Badges
|
|
62
|
+
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
63
|
+
|
|
64
|
+
## Visuals
|
|
65
|
+
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
69
|
+
|
|
70
|
+
## Usage
|
|
71
|
+
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
72
|
+
|
|
73
|
+
## Support
|
|
74
|
+
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
75
|
+
|
|
76
|
+
## Roadmap
|
|
77
|
+
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
78
|
+
|
|
79
|
+
## Contributing
|
|
80
|
+
State if you are open to contributions and what your requirements are for accepting them.
|
|
81
|
+
|
|
82
|
+
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
83
|
+
|
|
84
|
+
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
85
|
+
|
|
86
|
+
## Authors and acknowledgment
|
|
87
|
+
Show your appreciation to those who have contributed to the project.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
For open source projects, say how it is licensed.
|
|
91
|
+
|
|
92
|
+
## Project status
|
|
93
|
+
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ interface AppHeaderProps {
|
|
|
13
13
|
language?: 'en' | 'es';
|
|
14
14
|
/** When provided, used as Bearer token for profile picture and other authenticated requests. */
|
|
15
15
|
accessToken?: string | null;
|
|
16
|
+
/** Base URL for the object store API (e.g. profile picture). When provided, profile picture is fetched from {objectStoreUrl}/v1/objectStore/profilePicture/path/{userId}. Omit or leave empty to disable profile picture fetch. */
|
|
17
|
+
objectStoreUrl?: string | null;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
declare const AppHeader: React__default.FC<AppHeaderProps>;
|
|
@@ -115,13 +117,13 @@ declare const setI18nLocaleToStorage: (locale: string) => void;
|
|
|
115
117
|
* @returns Object with auth, decodedToken, and other keys (user/userDetails/profile null when using header key)
|
|
116
118
|
*/
|
|
117
119
|
declare const getAllDataFromStorage: () => any;
|
|
118
|
-
declare const getProfilePictureUrl: (baseUrl?: string) => string | null;
|
|
120
|
+
declare const getProfilePictureUrl: (baseUrl?: string | null) => string | null;
|
|
119
121
|
/**
|
|
120
122
|
* Get access token from all known storage keys (header, IAM, userdb, and plain keys).
|
|
121
123
|
* persist:userdb shape: authDetails (stringified) contains auth.accessToken.
|
|
122
124
|
*/
|
|
123
125
|
declare function getAccessTokenForRequest(): string | undefined;
|
|
124
|
-
declare const fetchProfilePictureAsBlobUrl: (baseUrl?: string, accessTokenOverride?: string | null) => Promise<string | null>;
|
|
126
|
+
declare const fetchProfilePictureAsBlobUrl: (baseUrl?: string | null, accessTokenOverride?: string | null) => Promise<string | null>;
|
|
125
127
|
|
|
126
128
|
export { AppHeader, DrawerProvider, PERSIST_HEADER_KEY, USER_DETAILS_STORAGE_KEY, fetchProfilePictureAsBlobUrl, getAccessTokenForRequest, getAllDataFromStorage, getI18nLocaleFromStorage, getMessageCountFromStorage, getNotificationCountFromStorage, getProfilePictureUrl, getStoredUserDetails, getTranslations, getUserDataFromStorage, setHeaderAuth, setI18nLocaleToStorage, translations, useDrawer };
|
|
127
129
|
export type { AppHeaderProps, HeaderAuthState, SupportedLanguage, Translations, UserDetailsItem, UserDetailsStoredResponse, UserProfile };
|
package/dist/index.esm.js
CHANGED
|
@@ -370,17 +370,20 @@ const getAllDataFromStorage = () => {
|
|
|
370
370
|
};
|
|
371
371
|
/**
|
|
372
372
|
* Get profile picture URL from object store API using user_id.
|
|
373
|
-
* @param baseUrl - Base URL for the object store API (
|
|
374
|
-
* @returns Profile picture URL or null if user_id is not available
|
|
373
|
+
* @param baseUrl - Base URL for the object store API (e.g. from objectStoreUrl prop). When missing or empty, returns null.
|
|
374
|
+
* @returns Profile picture URL or null if user_id or baseUrl is not available
|
|
375
375
|
*/
|
|
376
376
|
const VERIFICATION_USER_ID = 4590; // set to null to use only storage userId
|
|
377
|
-
const getProfilePictureUrl = (baseUrl
|
|
377
|
+
const getProfilePictureUrl = (baseUrl) => {
|
|
378
378
|
try {
|
|
379
|
+
const url = typeof baseUrl === "string" && baseUrl.trim() ? baseUrl.trim() : null;
|
|
380
|
+
if (!url)
|
|
381
|
+
return null;
|
|
379
382
|
const allData = getAllDataFromStorage();
|
|
380
383
|
const userId = allData.decodedToken?.user_id ?? allData.auth?.user_id ?? getStoredUserDetails()?.userId ?? VERIFICATION_USER_ID ?? null;
|
|
381
384
|
if (userId == null)
|
|
382
385
|
return null;
|
|
383
|
-
return `${
|
|
386
|
+
return `${url.replace(/\/$/, "")}/v1/objectStore/profilePicture/path/${userId}`;
|
|
384
387
|
}
|
|
385
388
|
catch (err) {
|
|
386
389
|
console.error("Error getting profile picture URL:", err);
|
|
@@ -393,10 +396,10 @@ function getKeyFromS3Uri(s3Uri) {
|
|
|
393
396
|
return match ? match[1] : null;
|
|
394
397
|
}
|
|
395
398
|
/**
|
|
396
|
-
* Fetch profile picture: (1) GET path API for JSON with filePath/s3Uri, (2) GET download API with key
|
|
397
|
-
* Path API
|
|
398
|
-
* @param baseUrl - Base URL for the object store API (
|
|
399
|
-
* @returns Promise that resolves to blob URL string or null if fetch fails
|
|
399
|
+
* Fetch profile picture: (1) GET path API for JSON with filePath/s3Uri, (2) GET download API with key; download returns JSON with base64 fileContent.
|
|
400
|
+
* Path API: { statusResponse, filePath, s3Uri, errors }. Download API: { statusResponse, fileName, contentType, fileContent (base64), errors }.
|
|
401
|
+
* @param baseUrl - Base URL for the object store API (e.g. from objectStoreUrl prop). When missing or empty, returns null without fetching.
|
|
402
|
+
* @returns Promise that resolves to blob URL string or null if fetch fails or baseUrl not provided
|
|
400
403
|
*/
|
|
401
404
|
/** Resolve access token from auth object (supports accessToken, access_token, token). */
|
|
402
405
|
function getAccessTokenFromAuth(auth) {
|
|
@@ -522,11 +525,14 @@ function getAccessTokenForRequest() {
|
|
|
522
525
|
}
|
|
523
526
|
return getAccessTokenFromAuth(getAllDataFromStorage().auth);
|
|
524
527
|
}
|
|
525
|
-
const fetchProfilePictureAsBlobUrl = async (baseUrl
|
|
528
|
+
const fetchProfilePictureAsBlobUrl = async (baseUrl, accessTokenOverride) => {
|
|
526
529
|
try {
|
|
527
530
|
const profilePicturePathUrl = getProfilePictureUrl(baseUrl);
|
|
528
531
|
if (!profilePicturePathUrl)
|
|
529
532
|
return null;
|
|
533
|
+
const cleanBase = typeof baseUrl === "string" && baseUrl.trim() ? baseUrl.trim().replace(/\/$/, "") : "";
|
|
534
|
+
if (!cleanBase)
|
|
535
|
+
return null;
|
|
530
536
|
const accessToken = (typeof accessTokenOverride === "string" && accessTokenOverride.length > 0
|
|
531
537
|
? accessTokenOverride
|
|
532
538
|
: null) ?? getAccessTokenForRequest();
|
|
@@ -565,20 +571,35 @@ const fetchProfilePictureAsBlobUrl = async (baseUrl = "http://objectstore.impact
|
|
|
565
571
|
console.warn("Profile picture response has no key/s3Uri/filePath for download");
|
|
566
572
|
return null;
|
|
567
573
|
}
|
|
568
|
-
// Step 2: GET download API →
|
|
569
|
-
const cleanBase = baseUrl.replace(/\/$/, "");
|
|
574
|
+
// Step 2: GET download API → JSON with fileContent (base64) and contentType
|
|
570
575
|
const downloadUrl = `${cleanBase}/v1/objectStore/download?key=${encodeURIComponent(downloadKey)}`;
|
|
571
576
|
const imageResponse = await fetch(downloadUrl, { method: "GET", headers });
|
|
572
577
|
if (!imageResponse.ok) {
|
|
573
578
|
console.warn(`Failed to fetch profile picture image: ${imageResponse.status} ${imageResponse.statusText}`);
|
|
574
579
|
return null;
|
|
575
580
|
}
|
|
576
|
-
const
|
|
577
|
-
|
|
578
|
-
|
|
581
|
+
const downloadData = (await imageResponse.json());
|
|
582
|
+
const downloadStatus = downloadData?.statusResponse?.status;
|
|
583
|
+
if (downloadStatus !== "SUCCESS") {
|
|
584
|
+
console.warn("Profile picture download API did not return SUCCESS:", downloadStatus, downloadData?.errors);
|
|
585
|
+
return null;
|
|
586
|
+
}
|
|
587
|
+
const fileContent = downloadData?.fileContent;
|
|
588
|
+
const contentType = (downloadData?.contentType || "").trim() || "image/png";
|
|
589
|
+
if (!fileContent || typeof fileContent !== "string") {
|
|
590
|
+
console.warn("Profile picture download response has no fileContent");
|
|
591
|
+
return null;
|
|
592
|
+
}
|
|
593
|
+
if (!contentType.startsWith("image/")) {
|
|
594
|
+
console.warn(`Profile picture download contentType is not an image: ${contentType}`);
|
|
579
595
|
return null;
|
|
580
596
|
}
|
|
581
|
-
|
|
597
|
+
// Decode base64 fileContent → Blob → object URL
|
|
598
|
+
const binary = atob(fileContent);
|
|
599
|
+
const bytes = new Uint8Array(binary.length);
|
|
600
|
+
for (let i = 0; i < binary.length; i++)
|
|
601
|
+
bytes[i] = binary.charCodeAt(i);
|
|
602
|
+
const blob = new Blob([bytes], { type: contentType });
|
|
582
603
|
return URL.createObjectURL(blob);
|
|
583
604
|
}
|
|
584
605
|
catch (err) {
|
|
@@ -699,7 +720,7 @@ const DEFAULT_ROUTES = {
|
|
|
699
720
|
profile: "/user/profile",
|
|
700
721
|
logout: "/user/login",
|
|
701
722
|
};
|
|
702
|
-
const AppHeader = ({ language: languageProp, accessToken: accessTokenProp }) => {
|
|
723
|
+
const AppHeader = ({ language: languageProp, accessToken: accessTokenProp, objectStoreUrl }) => {
|
|
703
724
|
// Get initial language from props, URL, localStorage, or default to 'en'
|
|
704
725
|
const getInitialLanguage = () => {
|
|
705
726
|
// Priority 1: Props
|
|
@@ -823,7 +844,7 @@ const AppHeader = ({ language: languageProp, accessToken: accessTokenProp }) =>
|
|
|
823
844
|
React__default.useEffect(() => {
|
|
824
845
|
const fetchProfilePicture = async () => {
|
|
825
846
|
const token = accessTokenProp ?? getAccessTokenForRequest();
|
|
826
|
-
const blobUrl = await fetchProfilePictureAsBlobUrl(undefined, token ?? undefined);
|
|
847
|
+
const blobUrl = await fetchProfilePictureAsBlobUrl(objectStoreUrl ?? undefined, token ?? undefined);
|
|
827
848
|
if (blobUrl) {
|
|
828
849
|
// Clean up previous blob URL if it exists
|
|
829
850
|
setProfilePictureBlobUrl((prevUrl) => {
|
|
@@ -844,7 +865,7 @@ const AppHeader = ({ language: languageProp, accessToken: accessTokenProp }) =>
|
|
|
844
865
|
return null;
|
|
845
866
|
});
|
|
846
867
|
};
|
|
847
|
-
}, [accessTokenProp]); // Refetch when accessToken
|
|
868
|
+
}, [accessTokenProp, objectStoreUrl]); // Refetch when accessToken or objectStoreUrl changes (e.g. after login or env switch)
|
|
848
869
|
React__default.useEffect(() => {
|
|
849
870
|
const allData = getAllDataFromStorage();
|
|
850
871
|
let userName = "";
|