@jango-blockchained/hoox-cli 0.7.2 → 0.7.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.
Files changed (2) hide show
  1. package/dist/index.js +52 -7
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -14792,22 +14792,57 @@ function toError(err, fallback = "Unknown error") {
14792
14792
  return fallback;
14793
14793
  }
14794
14794
  }
14795
+ function hasSensitiveFields(obj) {
14796
+ for (const key of Object.keys(obj)) {
14797
+ if (SENSITIVE_FIELDS.has(key))
14798
+ return true;
14799
+ }
14800
+ return false;
14801
+ }
14802
+ function hasErrorValues(obj) {
14803
+ for (const v of Object.values(obj)) {
14804
+ if (v instanceof Error)
14805
+ return true;
14806
+ }
14807
+ return false;
14808
+ }
14795
14809
  function sanitizeOutput(data) {
14810
+ if (data === null || data === undefined)
14811
+ return data;
14812
+ const t = typeof data;
14813
+ if (t === "string" || t === "number" || t === "boolean")
14814
+ return data;
14796
14815
  if (data instanceof Error) {
14797
14816
  return { name: data.name, message: data.message };
14798
14817
  }
14799
- if (data && typeof data === "object" && !Array.isArray(data)) {
14818
+ if (Array.isArray(data)) {
14819
+ return data.map(sanitizeOutput);
14820
+ }
14821
+ if (t === "object") {
14822
+ const obj = data;
14823
+ const keys = Object.keys(obj);
14824
+ if (keys.length < 10) {
14825
+ const sanitized2 = {};
14826
+ for (const k of keys) {
14827
+ if (k === "stack" || k === "cause")
14828
+ continue;
14829
+ const v = obj[k];
14830
+ sanitized2[k] = v instanceof Error ? { name: v.name, message: v.message } : sanitizeOutput(v);
14831
+ }
14832
+ return sanitized2;
14833
+ }
14834
+ if (!hasSensitiveFields(obj) && !hasErrorValues(obj)) {
14835
+ return obj;
14836
+ }
14800
14837
  const sanitized = {};
14801
- for (const [k, v] of Object.entries(data)) {
14838
+ for (const k of keys) {
14802
14839
  if (k === "stack" || k === "cause")
14803
14840
  continue;
14841
+ const v = obj[k];
14804
14842
  sanitized[k] = v instanceof Error ? { name: v.name, message: v.message } : sanitizeOutput(v);
14805
14843
  }
14806
14844
  return sanitized;
14807
14845
  }
14808
- if (Array.isArray(data)) {
14809
- return data.map(sanitizeOutput);
14810
- }
14811
14846
  return data;
14812
14847
  }
14813
14848
  function createJsonResponse(data, status = 200) {
@@ -14832,8 +14867,16 @@ function createErrorResponse(error51, status) {
14832
14867
  headers: { "Content-Type": "application/json" }
14833
14868
  });
14834
14869
  }
14835
- var Errors;
14870
+ var SENSITIVE_FIELDS, Errors;
14836
14871
  var init_errors3 = __esm(() => {
14872
+ SENSITIVE_FIELDS = new Set([
14873
+ "password",
14874
+ "token",
14875
+ "secret",
14876
+ "api_key",
14877
+ "apiKey",
14878
+ "authorization"
14879
+ ]);
14837
14880
  Errors = {
14838
14881
  badRequest: (message) => createErrorResponse({ message, status: 400, code: "BAD_REQUEST" }),
14839
14882
  unauthorized: (message = "Unauthorized") => createErrorResponse({ message, status: 401, code: "UNAUTHORIZED" }),
@@ -15324,13 +15367,15 @@ var init_d1 = __esm(() => {
15324
15367
 
15325
15368
  // ../shared/src/service-bindings.ts
15326
15369
  function serviceFetch(binding, path2, body, options) {
15370
+ const timeout = options?.timeout ?? 30000;
15327
15371
  return binding.fetch(`http://internal${path2}`, {
15328
15372
  method: options?.method ?? "POST",
15329
15373
  headers: {
15330
15374
  "Content-Type": "application/json",
15331
15375
  ...options?.headers
15332
15376
  },
15333
- body: body != null ? JSON.stringify(body) : undefined
15377
+ body: body != null ? JSON.stringify(body) : undefined,
15378
+ signal: AbortSignal.timeout(timeout)
15334
15379
  });
15335
15380
  }
15336
15381
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jango-blockchained/hoox-cli",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "Hoox CLI — manage Cloudflare Workers, infrastructure, secrets, and deployments (@jango-blockchained/hoox-cli)",
5
5
  "type": "module",
6
6
  "bin": {
@@ -23,7 +23,7 @@
23
23
  "wrangler": "^4.97.0"
24
24
  },
25
25
  "devDependencies": {
26
- "@jango-blockchained/hoox-shared": "^1.0.8",
26
+ "@jango-blockchained/hoox-shared": "^1.0.9",
27
27
  "@types/node": "^25.8.0",
28
28
  "bun-types": "^1.3.14",
29
29
  "typescript": "^6.0.3"