api-core-lib 3.3.3 → 4.3.3

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/index.d.mts CHANGED
@@ -61,6 +61,7 @@ interface RequestConfig extends AxiosRequestConfig {
61
61
  cancelTokenKey?: string;
62
62
  onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
63
63
  onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void;
64
+ isPublic?: boolean;
64
65
  }
65
66
  /**
66
67
  * يمثل خيارات الاستعلام للترقيم والبحث والفرز.
package/dist/index.d.ts CHANGED
@@ -61,6 +61,7 @@ interface RequestConfig extends AxiosRequestConfig {
61
61
  cancelTokenKey?: string;
62
62
  onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
63
63
  onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void;
64
+ isPublic?: boolean;
64
65
  }
65
66
  /**
66
67
  * يمثل خيارات الاستعلام للترقيم والبحث والفرز.
package/dist/index.js CHANGED
@@ -106,7 +106,10 @@ function createApiClient(config) {
106
106
  let tokenRefreshPromise = null;
107
107
  axiosInstance.interceptors.request.use(async (req) => {
108
108
  req.headers["X-Request-ID"] = (0, import_uuid.v4)();
109
- if (req.url?.includes("/auth/")) return req;
109
+ if (req.isPublic) {
110
+ console.log(`[API Core] Skipping token for public request: ${req.url}`);
111
+ return req;
112
+ }
110
113
  if (tokenRefreshPromise) {
111
114
  await tokenRefreshPromise;
112
115
  }
@@ -125,6 +128,9 @@ function createApiClient(config) {
125
128
  if (tokens.accessToken && !tokenManager.isHttpOnly()) {
126
129
  const tokenType = tokens.tokenType || "Bearer";
127
130
  req.headers.Authorization = `${tokenType} ${tokens.accessToken}`;
131
+ console.log(`[API Core] Token attached to request: ${req.url}`);
132
+ } else {
133
+ console.warn(`[API Core] No token attached for request: ${req.url}`);
128
134
  }
129
135
  return req;
130
136
  }, (error) => Promise.reject(error));
package/dist/index.mjs CHANGED
@@ -64,7 +64,10 @@ function createApiClient(config) {
64
64
  let tokenRefreshPromise = null;
65
65
  axiosInstance.interceptors.request.use(async (req) => {
66
66
  req.headers["X-Request-ID"] = uuidv4();
67
- if (req.url?.includes("/auth/")) return req;
67
+ if (req.isPublic) {
68
+ console.log(`[API Core] Skipping token for public request: ${req.url}`);
69
+ return req;
70
+ }
68
71
  if (tokenRefreshPromise) {
69
72
  await tokenRefreshPromise;
70
73
  }
@@ -83,6 +86,9 @@ function createApiClient(config) {
83
86
  if (tokens.accessToken && !tokenManager.isHttpOnly()) {
84
87
  const tokenType = tokens.tokenType || "Bearer";
85
88
  req.headers.Authorization = `${tokenType} ${tokens.accessToken}`;
89
+ console.log(`[API Core] Token attached to request: ${req.url}`);
90
+ } else {
91
+ console.warn(`[API Core] No token attached for request: ${req.url}`);
86
92
  }
87
93
  return req;
88
94
  }, (error) => Promise.reject(error));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api-core-lib",
3
- "version": "3.3.3",
3
+ "version": "4.3.3",
4
4
  "description": "A flexible and powerful API client library for modern web applications.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",