@synth1s/cloak 1.7.0 → 1.8.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synth1s/cloak",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Cloak your Claude. Switch identities in seconds.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,4 +1,4 @@
1
- import { listProfileNames, getActiveProfile } from '../lib/paths.js'
1
+ import { listProfileNames, getActiveProfile, getAccountEmail } from '../lib/paths.js'
2
2
  import * as msg from '../lib/messages.js'
3
3
 
4
4
  export function listAccounts() {
@@ -8,6 +8,7 @@ export function listAccounts() {
8
8
  const accounts = names.map(name => ({
9
9
  name,
10
10
  active: name === active,
11
+ email: getAccountEmail(name),
11
12
  }))
12
13
 
13
14
  if (accounts.length === 0) {
@@ -17,8 +18,8 @@ export function listAccounts() {
17
18
  }
18
19
 
19
20
  console.log(msg.accountListHeader())
20
- accounts.forEach(({ name, active: isActive }) => {
21
- console.log(msg.accountListItem(name, isActive))
21
+ accounts.forEach(({ name, active: isActive, email }) => {
22
+ console.log(msg.accountListItem(name, isActive, email))
22
23
  })
23
24
  console.log()
24
25
 
@@ -98,11 +98,12 @@ export function accountListHeader() {
98
98
  return chalk.bold('\nYour Cloaks\n')
99
99
  }
100
100
 
101
- export function accountListItem(name, isActive) {
101
+ export function accountListItem(name, isActive, email) {
102
102
  const marker = isActive ? icon.active : icon.inactive
103
103
  const label = isActive ? chalk.green.bold(name) : chalk.white(name)
104
104
  const tag = isActive ? chalk.green(' (active)') : ''
105
- return ` ${marker} ${label}${tag}`
105
+ const emailTag = email ? chalk.dim(` ${email}`) : ''
106
+ return ` ${marker} ${label}${tag}${emailTag}`
106
107
  }
107
108
 
108
109
  export function alreadyInstalled(rcFile) {
package/src/lib/paths.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { homedir } from 'os'
2
2
  import { join, resolve, sep } from 'path'
3
- import { existsSync, mkdirSync, readdirSync } from 'fs'
3
+ import { existsSync, mkdirSync, readdirSync, readFileSync } from 'fs'
4
4
 
5
5
  function getHome() {
6
6
  return process.env.HOME || homedir()
@@ -67,3 +67,14 @@ export function getActiveProfile() {
67
67
  const name = resolved.slice(profilesResolved.length + 1).split(sep)[0]
68
68
  return name || null
69
69
  }
70
+
71
+ export function getAccountEmail(name) {
72
+ try {
73
+ const authFile = profileAuthPath(name)
74
+ if (!existsSync(authFile)) return null
75
+ const data = JSON.parse(readFileSync(authFile, 'utf8'))
76
+ return data?.oauthAccount?.emailAddress || null
77
+ } catch {
78
+ return null
79
+ }
80
+ }