@base44-preview/sdk 0.8.51-pr.294.a7ae332 → 0.8.52-pr.295.865dd57

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.
@@ -101,6 +101,38 @@ function safeErrorLog(prefix, error) {
101
101
  console.error(`${prefix} ${error instanceof Error ? error.message : String(error)}`);
102
102
  }
103
103
  }
104
+ const CREDENTIAL_HEADERS = new Set([
105
+ "authorization",
106
+ "on-behalf-of",
107
+ "base44-service-authorization",
108
+ ]);
109
+ /**
110
+ * Removes credentials from a failed request's error before app code sees it.
111
+ *
112
+ * An axios error carries its request config and the raw Node request, so
113
+ * logging it (for example `console.log(error)`) printed the bearer token.
114
+ *
115
+ * @param error - The axios error to scrub in place
116
+ * @internal
117
+ */
118
+ function redactCredentials(error) {
119
+ var _a;
120
+ const headers = (_a = error === null || error === void 0 ? void 0 : error.config) === null || _a === void 0 ? void 0 : _a.headers;
121
+ if (headers) {
122
+ const names = Object.keys(typeof headers.toJSON === "function" ? headers.toJSON() : headers);
123
+ for (const name of names) {
124
+ if (CREDENTIAL_HEADERS.has(name.toLowerCase())) {
125
+ headers[name] = "[REDACTED]";
126
+ }
127
+ }
128
+ }
129
+ // The Node request object also holds the raw header block (`_header`).
130
+ for (const target of [error, error === null || error === void 0 ? void 0 : error.response]) {
131
+ if (target && "request" in target) {
132
+ Object.defineProperty(target, "request", { enumerable: false });
133
+ }
134
+ }
135
+ }
104
136
  /**
105
137
  * Creates an axios client with default configuration and interceptors.
106
138
  *
@@ -128,6 +160,11 @@ export function createAxiosClient({ baseURL, headers = {}, token, interceptRespo
128
160
  if (token) {
129
161
  client.defaults.headers.common["Authorization"] = `Bearer ${token}`;
130
162
  }
163
+ // Registered first so it also covers clients that skip the Base44Error wrapper.
164
+ client.interceptors.response.use(undefined, (error) => {
165
+ redactCredentials(error);
166
+ return Promise.reject(error);
167
+ });
131
168
  // Add origin URL in browser environment
132
169
  client.interceptors.request.use((config) => {
133
170
  // `window.location` is absent on React Native (where `window` still exists),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.51-pr.294.a7ae332",
3
+ "version": "0.8.52-pr.295.865dd57",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",