securenow 7.6.1 → 7.6.2

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/app-config.js +78 -6
  2. package/package.json +1 -1
package/app-config.js CHANGED
@@ -164,10 +164,84 @@ function readJsonSafe(filepath) {
164
164
  }
165
165
  }
166
166
 
167
+ function fileIfReadable(filepath) {
168
+ if (!filepath) return null;
169
+ try {
170
+ return fs.existsSync(filepath) && fs.statSync(filepath).isFile() ? filepath : null;
171
+ } catch {
172
+ return null;
173
+ }
174
+ }
175
+
176
+ function findUpFile(startDir, relativePath) {
177
+ if (!startDir) return null;
178
+ let dir;
179
+ try {
180
+ dir = path.resolve(startDir);
181
+ } catch {
182
+ return null;
183
+ }
184
+
185
+ while (true) {
186
+ const found = fileIfReadable(path.join(dir, relativePath));
187
+ if (found) return found;
188
+
189
+ const parent = path.dirname(dir);
190
+ if (!parent || parent === dir) return null;
191
+ dir = parent;
192
+ }
193
+ }
194
+
195
+ function uniq(values) {
196
+ const seen = new Set();
197
+ const out = [];
198
+ for (const value of values) {
199
+ if (!value || seen.has(value)) continue;
200
+ seen.add(value);
201
+ out.push(value);
202
+ }
203
+ return out;
204
+ }
205
+
206
+ function resolveLocalCredentialsFile() {
207
+ const starts = [];
208
+ try {
209
+ if (typeof process !== 'undefined' && process.cwd) starts.push(process.cwd());
210
+ } catch {}
211
+
212
+ if (process.env.INIT_CWD) starts.push(process.env.INIT_CWD);
213
+ if (process.argv && process.argv[1]) starts.push(path.dirname(process.argv[1]));
214
+ if (require.main && require.main.filename) starts.push(path.dirname(require.main.filename));
215
+
216
+ for (const start of uniq(starts)) {
217
+ const found = findUpFile(start, path.join('.securenow', 'credentials.json'));
218
+ if (found) return found;
219
+ }
220
+
221
+ return null;
222
+ }
223
+
224
+ function resolvePackageJsonFile() {
225
+ const starts = [];
226
+ try {
227
+ if (typeof process !== 'undefined' && process.cwd) starts.push(process.cwd());
228
+ } catch {}
229
+
230
+ if (process.env.INIT_CWD) starts.push(process.env.INIT_CWD);
231
+ if (process.argv && process.argv[1]) starts.push(path.dirname(process.argv[1]));
232
+ if (require.main && require.main.filename) starts.push(path.dirname(require.main.filename));
233
+
234
+ for (const start of uniq(starts)) {
235
+ const found = findUpFile(start, 'package.json');
236
+ if (found) return found;
237
+ }
238
+
239
+ return null;
240
+ }
241
+
167
242
  function loadLocalCredentials() {
168
243
  try {
169
- const cwd = typeof process !== 'undefined' && process.cwd ? process.cwd() : '.';
170
- return withCredentialDefaults(readJsonSafe(path.join(cwd, '.securenow', 'credentials.json')));
244
+ return withCredentialDefaults(readJsonSafe(resolveLocalCredentialsFile()));
171
245
  } catch {
172
246
  return null;
173
247
  }
@@ -183,8 +257,7 @@ function loadGlobalCredentials() {
183
257
 
184
258
  function loadCredentials() {
185
259
  try {
186
- const cwd = typeof process !== 'undefined' && process.cwd ? process.cwd() : '.';
187
- const local = readJsonSafe(path.join(cwd, '.securenow', 'credentials.json'));
260
+ const local = readJsonSafe(resolveLocalCredentialsFile());
188
261
  const global = readJsonSafe(path.join(os.homedir(), '.securenow', 'credentials.json'));
189
262
  return withCredentialDefaults(mergeCredentials(global, local));
190
263
  } catch {
@@ -194,8 +267,7 @@ function loadCredentials() {
194
267
 
195
268
  function loadPackageJsonName() {
196
269
  try {
197
- const cwd = typeof process !== 'undefined' && process.cwd ? process.cwd() : '.';
198
- const pkg = readJsonSafe(path.join(cwd, 'package.json'));
270
+ const pkg = readJsonSafe(resolvePackageJsonFile());
199
271
  if (pkg && typeof pkg.name === 'string' && pkg.name.trim()) {
200
272
  return pkg.name.trim().replace(/^@[^/]+\//, '');
201
273
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securenow",
3
- "version": "7.6.1",
3
+ "version": "7.6.2",
4
4
  "description": "OpenTelemetry instrumentation for Node.js, Next.js, and Nuxt - Send traces and logs to any OTLP-compatible backend",
5
5
  "type": "commonjs",
6
6
  "main": "register.js",