@bindu-dashing/dam-solution-v2 5.8.144 → 5.8.146

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.
@@ -12,7 +12,7 @@ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
12
12
  import { createContext, useContext, useState, useEffect } from "react";
13
13
  import { USER_LOGIN, FETCH_TEAMS_LIST, } from "../utilities/constants/apiUrls";
14
14
  import axios from "axios";
15
- import { getBaseUrl } from "./helpers";
15
+ import { getBaseUrl, encodeBase64 } from "./helpers";
16
16
  import { get } from "lodash";
17
17
  import Loader from "../common/loader/loader";
18
18
  import { SUBSCRIPTION_EXPIRED_ERROR_MESSAGE } from "./appConstants";
@@ -76,8 +76,22 @@ export const DamConfigProvider = ({ children, config }) => {
76
76
  console.log("Could not extract teamID from token");
77
77
  return;
78
78
  }
79
- // Get the Teams API base URL (different from MIXDRIVE_API_URL)
80
- const teamsApiBaseUrl = "https://f5ubolirub.execute-api.ap-southeast-2.amazonaws.com/dev/api/v1";
79
+ // Get the Teams API base URL from environment variable
80
+ const teamsApiBaseUrl = process.env.REACT_APP_CORE_API_URL || "";
81
+ if (!teamsApiBaseUrl) {
82
+ console.error("REACT_APP_CORE_API_URL is not defined in environment variables");
83
+ return;
84
+ }
85
+ // Get Basic Auth credentials from environment variables
86
+ const username = process.env.REACT_APP_TEAMS_API_TOKEN_USERNAME || "";
87
+ const password = process.env.REACT_APP_TEAMS_API_TOKEN_PASSWORD || "";
88
+ if (!username || !password) {
89
+ console.error("REACT_APP_TEAMS_API_TOKEN_USERNAME or REACT_APP_TEAMS_API_TOKEN_PASSWORD is not defined in environment variables");
90
+ return;
91
+ }
92
+ // Create Basic Auth header by encoding username:password to Base64
93
+ const basicAuthToken = encodeBase64(`${username}:${password}`);
94
+ const authorizationHeader = `Basic ${basicAuthToken}`;
81
95
  const teamsEndpoint = FETCH_TEAMS_LIST.replace(":teamID", teamID);
82
96
  const fullUrl = teamsApiBaseUrl + teamsEndpoint;
83
97
  console.log("Fetching teams from:", fullUrl);
@@ -85,7 +99,7 @@ export const DamConfigProvider = ({ children, config }) => {
85
99
  // Call the new API endpoint using Teams API base URL
86
100
  const response = yield axios.get(fullUrl, {
87
101
  headers: {
88
- Authorization: `Basic ZXh0ZXJuYWxfdXNlcjp1SHlTZ0toYTEyM1VqZWhL`,
102
+ Authorization: authorizationHeader,
89
103
  },
90
104
  });
91
105
  console.log("Teams API response:", response === null || response === void 0 ? void 0 : response.data);
@@ -9,6 +9,13 @@ export declare const getDateRangeFromKey: (key: string) => {
9
9
  endDate?: string;
10
10
  };
11
11
  export declare const getBaseUrl: (appType: string) => string;
12
+ /**
13
+ * Encodes a string to Base64 in a cross-platform way
14
+ * Works in both browser and Node.js environments
15
+ * @param str - The string to encode
16
+ * @returns Base64 encoded string
17
+ */
18
+ export declare const encodeBase64: (str: string) => string;
12
19
  export declare const getRelativeTime: (timestamp: string) => string;
13
20
  export declare const getReadableFileType: (file: FileEntity) => string;
14
21
  export declare const humanFileSize: (size: any) => any;
@@ -102,6 +102,29 @@ export const getBaseUrl = (appType) => {
102
102
  return process.env.REACT_APP_MIXDRIVE_API_URL || "";
103
103
  }
104
104
  };
105
+ /**
106
+ * Encodes a string to Base64 in a cross-platform way
107
+ * Works in both browser and Node.js environments
108
+ * @param str - The string to encode
109
+ * @returns Base64 encoded string
110
+ */
111
+ export const encodeBase64 = (str) => {
112
+ // Use Buffer if available (Node.js environment)
113
+ if (typeof Buffer !== "undefined") {
114
+ return Buffer.from(str, "utf-8").toString("base64");
115
+ }
116
+ // Fallback to btoa for browser environments
117
+ // Note: btoa only works with Latin-1 characters, so we encode URI component first
118
+ try {
119
+ return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (match, p1) => {
120
+ return String.fromCharCode(parseInt(p1, 16));
121
+ }));
122
+ }
123
+ catch (e) {
124
+ // If btoa fails, throw a more descriptive error
125
+ throw new Error("Failed to encode string to Base64");
126
+ }
127
+ };
105
128
  export const getRelativeTime = (timestamp) => {
106
129
  const now = new Date();
107
130
  const created = new Date(timestamp);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bindu-dashing/dam-solution-v2",
3
- "version": "5.8.144",
3
+ "version": "5.8.146",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.0.1",
6
6
  "@emoji-mart/data": "^1.2.1",