not-manage 0.1.17 → 0.1.18

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/bin/not-manage.js CHANGED
@@ -2,8 +2,7 @@
2
2
 
3
3
  const { run } = require("../src/cli");
4
4
 
5
- run(process.argv.slice(2)).catch((error) => {
6
- const message = error && error.message ? error.message : String(error);
7
- console.error(`Error: ${message}`);
5
+ run(process.argv.slice(2)).catch((_error) => {
6
+ console.error("Error: command failed.");
8
7
  process.exit(1);
9
8
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "not-manage",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "Unofficial command-line tool for Clio Manage integrations",
5
5
  "license": "Apache-2.0",
6
6
  "private": false,
@@ -80,6 +80,60 @@ function maskCredential(value) {
80
80
  return `${text.slice(0, 4)}...${text.slice(-4)}`;
81
81
  }
82
82
 
83
+ function maskEmail(value) {
84
+ const text = String(value || "").trim();
85
+ const atIndex = text.indexOf("@");
86
+
87
+ if (!text || text === "unknown" || atIndex <= 0 || atIndex === text.length - 1) {
88
+ return text || "unknown";
89
+ }
90
+
91
+ const localPart = text.slice(0, atIndex);
92
+ const domain = text.slice(atIndex);
93
+ return `${localPart.slice(0, 1)}${"*".repeat(Math.max(localPart.length - 1, 0))}${domain}`;
94
+ }
95
+
96
+ function maskUserSummary(user) {
97
+ if (!user) {
98
+ return user;
99
+ }
100
+
101
+ return {
102
+ ...user,
103
+ email: maskEmail(user.email),
104
+ };
105
+ }
106
+
107
+ function resolveRegionInfo(regionCode) {
108
+ if (regionCode && REGIONS[regionCode]) {
109
+ return REGIONS[regionCode];
110
+ }
111
+
112
+ return {
113
+ code: regionCode || "unknown",
114
+ label: regionCode || "unknown",
115
+ host: "unknown",
116
+ };
117
+ }
118
+
119
+ function buildAuthDisplayContext(config, tokenSet = null, user = null) {
120
+ const regionInfo = resolveRegionInfo(config?.region);
121
+
122
+ return {
123
+ configSource: config?.source === "keychain" ? "keychain" : String(config?.source || "unknown"),
124
+ host: regionInfo.host,
125
+ redirectUri:
126
+ config?.redirectUri === DEFAULT_REDIRECT_URI
127
+ ? DEFAULT_REDIRECT_URI
128
+ : "custom loopback redirect configured",
129
+ region: regionInfo.code,
130
+ regionLabel: regionInfo.label,
131
+ tokenSource:
132
+ tokenSet?.source === "keychain" ? "keychain" : String(tokenSet?.source || "unknown"),
133
+ user: maskUserSummary(user),
134
+ };
135
+ }
136
+
83
137
  function formatConfigSummary(config) {
84
138
  return [
85
139
  `Config source: ${config.source}`,
@@ -308,11 +362,12 @@ async function authLogin(options = {}) {
308
362
  const config = options.config || (await getConfig());
309
363
  const state = crypto.randomBytes(16).toString("hex");
310
364
  const authUrl = authorizeUrl(config, state);
365
+ const authContext = buildAuthDisplayContext(config);
311
366
 
312
- console.log(`Config source: ${config.source}`);
313
- console.log(`Starting OAuth for region ${config.region} (${config.regionLabel}).`);
314
- console.log(`Using host ${config.host}`);
315
- console.log(`Waiting for callback on ${config.redirectUri}`);
367
+ console.log(`Config source: ${authContext.configSource}`);
368
+ console.log(`Starting OAuth for region ${authContext.region} (${authContext.regionLabel}).`);
369
+ console.log(`Using host ${authContext.host}`);
370
+ console.log(`Waiting for callback on ${authContext.redirectUri}`);
316
371
 
317
372
  const callbackPromise = waitForOAuthCallback(config.redirectUri, state);
318
373
 
@@ -336,19 +391,21 @@ async function authLogin(options = {}) {
336
391
  const tokenSet = await saveTokenSet(tokenPayload);
337
392
  const accessToken = await getValidAccessToken(config, tokenSet);
338
393
  const { user } = await fetchCurrentUserSummary(config, accessToken);
394
+ const maskedUser = maskUserSummary(user);
339
395
 
340
396
  console.log("");
341
397
  console.log("Clio login complete.");
342
- console.log(`Connected user: ${user.name} <${user.email}> (id: ${user.id})`);
398
+ console.log(`Connected user: ${maskedUser.name} <${maskedUser.email}> (id: ${maskedUser.id})`);
343
399
  }
344
400
 
345
401
  async function authStatus(options = {}) {
346
402
  const config = await getConfig();
347
403
  const tokenSet = await getTokenSet();
404
+ const disconnectedContext = buildAuthDisplayContext(config);
348
405
 
349
406
  if (!tokenSet || !tokenSet.accessToken) {
350
- console.log(`Config source: ${config.source}`);
351
- console.log(`Region: ${config.region} (${config.regionLabel})`);
407
+ console.log(`Config source: ${disconnectedContext.configSource}`);
408
+ console.log(`Region: ${disconnectedContext.region} (${disconnectedContext.regionLabel})`);
352
409
  console.log("Login status: not logged in");
353
410
  console.log("Run `not-manage auth login`.");
354
411
  return;
@@ -357,16 +414,17 @@ async function authStatus(options = {}) {
357
414
  const accessToken = await getValidAccessToken(config, tokenSet);
358
415
  const { user } = await fetchCurrentUserSummary(config, accessToken);
359
416
  const warnings = collectSecurityWarnings(config, tokenSet);
417
+ const authContext = buildAuthDisplayContext(config, tokenSet, user);
360
418
 
361
419
  if (options.json) {
362
420
  console.log(
363
421
  JSON.stringify(
364
422
  {
365
- configSource: config.source,
366
- tokenSource: tokenSet.source,
367
- region: config.region,
368
- host: config.host,
369
- user,
423
+ configSource: authContext.configSource,
424
+ tokenSource: authContext.tokenSource,
425
+ region: authContext.region,
426
+ host: authContext.host,
427
+ user: authContext.user,
370
428
  },
371
429
  null,
372
430
  2
@@ -375,12 +433,14 @@ async function authStatus(options = {}) {
375
433
  return;
376
434
  }
377
435
 
378
- console.log(`Config source: ${config.source}`);
379
- console.log(`Token source: ${tokenSet.source}`);
380
- console.log(`Region: ${config.region} (${config.regionLabel})`);
381
- console.log(`Host: ${config.host}`);
436
+ console.log(`Config source: ${authContext.configSource}`);
437
+ console.log(`Token source: ${authContext.tokenSource}`);
438
+ console.log(`Region: ${authContext.region} (${authContext.regionLabel})`);
439
+ console.log(`Host: ${authContext.host}`);
382
440
  console.log(`Login status: connected`);
383
- console.log(`Connected user: ${user.name} <${user.email}> (id: ${user.id})`);
441
+ console.log(
442
+ `Connected user: ${authContext.user.name} <${authContext.user.email}> (id: ${authContext.user.id})`
443
+ );
384
444
  warnings.forEach((warning) => {
385
445
  console.log(`Security warning: ${warning}`);
386
446
  });
@@ -457,9 +517,12 @@ module.exports = {
457
517
  setupWizard,
458
518
  whoAmI,
459
519
  __private: {
520
+ buildAuthDisplayContext,
460
521
  collectSecurityWarnings,
461
522
  fetchCurrentUserSummary,
462
523
  formatUserSummary,
463
524
  hydrateUserSummary,
525
+ maskEmail,
526
+ maskUserSummary,
464
527
  },
465
528
  };
@@ -121,8 +121,8 @@ async function main(options = {}) {
121
121
 
122
122
  try {
123
123
  await maybeRunPostinstallOnboarding(options);
124
- } catch (error) {
125
- errorLog(`Post-install setup was skipped: ${error.message}`);
124
+ } catch (_error) {
125
+ errorLog("Post-install setup was skipped.");
126
126
  log("Run `not-manage setup` when you are ready.");
127
127
  }
128
128
  }