pal-explorer-cli 0.4.12 → 0.4.13

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 (99) hide show
  1. package/README.md +149 -149
  2. package/bin/pal.js +63 -2
  3. package/extensions/@palexplorer/analytics/extension.json +20 -1
  4. package/extensions/@palexplorer/analytics/index.js +19 -9
  5. package/extensions/@palexplorer/audit/extension.json +14 -0
  6. package/extensions/@palexplorer/auth-email/extension.json +15 -0
  7. package/extensions/@palexplorer/auth-oauth/extension.json +15 -0
  8. package/extensions/@palexplorer/chat/extension.json +14 -0
  9. package/extensions/@palexplorer/discovery/extension.json +17 -0
  10. package/extensions/@palexplorer/discovery/index.js +1 -1
  11. package/extensions/@palexplorer/email-notifications/extension.json +23 -0
  12. package/extensions/@palexplorer/groups/extension.json +15 -0
  13. package/extensions/@palexplorer/share-links/extension.json +15 -0
  14. package/extensions/@palexplorer/sync/extension.json +16 -0
  15. package/extensions/@palexplorer/user-mgmt/extension.json +15 -0
  16. package/lib/capabilities.js +24 -24
  17. package/lib/commands/analytics.js +175 -175
  18. package/lib/commands/api-keys.js +131 -131
  19. package/lib/commands/audit.js +235 -235
  20. package/lib/commands/auth.js +137 -137
  21. package/lib/commands/backup.js +76 -76
  22. package/lib/commands/billing.js +148 -148
  23. package/lib/commands/chat.js +217 -217
  24. package/lib/commands/cloud-backup.js +231 -231
  25. package/lib/commands/comment.js +99 -99
  26. package/lib/commands/completion.js +203 -203
  27. package/lib/commands/compliance.js +218 -218
  28. package/lib/commands/config.js +136 -136
  29. package/lib/commands/connect.js +44 -44
  30. package/lib/commands/dept.js +294 -294
  31. package/lib/commands/device.js +146 -146
  32. package/lib/commands/download.js +240 -226
  33. package/lib/commands/explorer.js +178 -178
  34. package/lib/commands/extension.js +1060 -970
  35. package/lib/commands/favorite.js +90 -90
  36. package/lib/commands/federation.js +270 -270
  37. package/lib/commands/file.js +533 -533
  38. package/lib/commands/group.js +271 -271
  39. package/lib/commands/gui-share.js +29 -29
  40. package/lib/commands/init.js +61 -61
  41. package/lib/commands/invite.js +59 -59
  42. package/lib/commands/list.js +58 -58
  43. package/lib/commands/log.js +116 -116
  44. package/lib/commands/nearby.js +108 -108
  45. package/lib/commands/network.js +251 -251
  46. package/lib/commands/notify.js +198 -198
  47. package/lib/commands/org.js +273 -273
  48. package/lib/commands/pal.js +403 -180
  49. package/lib/commands/permissions.js +216 -216
  50. package/lib/commands/pin.js +97 -97
  51. package/lib/commands/protocol.js +357 -357
  52. package/lib/commands/rbac.js +147 -147
  53. package/lib/commands/recover.js +36 -36
  54. package/lib/commands/register.js +171 -171
  55. package/lib/commands/relay.js +131 -131
  56. package/lib/commands/remote.js +368 -368
  57. package/lib/commands/revoke.js +50 -50
  58. package/lib/commands/scanner.js +280 -280
  59. package/lib/commands/schedule.js +344 -344
  60. package/lib/commands/scim.js +203 -203
  61. package/lib/commands/search.js +181 -181
  62. package/lib/commands/serve.js +438 -438
  63. package/lib/commands/server.js +350 -350
  64. package/lib/commands/share-link.js +199 -199
  65. package/lib/commands/share.js +336 -323
  66. package/lib/commands/sso.js +200 -200
  67. package/lib/commands/status.js +145 -145
  68. package/lib/commands/stream.js +562 -562
  69. package/lib/commands/su.js +187 -187
  70. package/lib/commands/sync.js +979 -979
  71. package/lib/commands/transfers.js +152 -152
  72. package/lib/commands/uninstall.js +188 -188
  73. package/lib/commands/update.js +204 -204
  74. package/lib/commands/user.js +276 -276
  75. package/lib/commands/vfs.js +84 -84
  76. package/lib/commands/web-login.js +79 -79
  77. package/lib/commands/web.js +52 -52
  78. package/lib/commands/webhook.js +180 -180
  79. package/lib/commands/whoami.js +59 -59
  80. package/lib/commands/workspace.js +121 -121
  81. package/lib/core/billing.js +16 -5
  82. package/lib/core/dhtDiscovery.js +9 -2
  83. package/lib/core/discoveryClient.js +13 -7
  84. package/lib/core/extensions.js +142 -1
  85. package/lib/core/identity.js +33 -2
  86. package/lib/core/imageProcessor.js +109 -0
  87. package/lib/core/imageTorrent.js +167 -0
  88. package/lib/core/permissions.js +1 -1
  89. package/lib/core/pro.js +11 -4
  90. package/lib/core/serverList.js +4 -1
  91. package/lib/core/shares.js +12 -1
  92. package/lib/core/signalingServer.js +14 -2
  93. package/lib/core/su.js +1 -1
  94. package/lib/core/users.js +1 -1
  95. package/lib/protocol/messages.js +12 -3
  96. package/lib/utils/explorer.js +1 -1
  97. package/lib/utils/help.js +357 -357
  98. package/lib/utils/torrent.js +1 -0
  99. package/package.json +4 -3
@@ -1,276 +1,276 @@
1
- import chalk from 'chalk';
2
- import config from '../utils/config.js';
3
- import { createIdentity, getIdentity, guestLogin, guestLogout, isGuestSession } from '../core/identity.js';
4
- import { resolveFromServer } from '../core/discoveryClient.js';
5
- import { getPrimaryServer } from '../core/discoveryClient.js';
6
- import {
7
- getProfiles,
8
- getActiveUser,
9
- setActiveUser,
10
- addProfile,
11
- removeProfile,
12
- promoteProfile,
13
- requireRole,
14
- migrateToMultiUser,
15
- addGuestProfile,
16
- removeGuestProfile,
17
- } from '../core/users.js';
18
-
19
- export default function userCommand(program) {
20
- const cmd = program.command('user').description('manage user profiles on this machine');
21
-
22
- cmd
23
- .command('list')
24
- .description('list all user profiles')
25
- .action(() => {
26
- migrateToMultiUser();
27
- const profiles = getProfiles();
28
- const active = getActiveUser();
29
-
30
- if (profiles.length === 0) {
31
- console.log(chalk.gray('No profiles. Run `pe init <name>` to create one.'));
32
- return;
33
- }
34
-
35
- console.log('');
36
- console.log(chalk.cyan.bold('User Profiles'));
37
- console.log('');
38
- for (const p of profiles) {
39
- const isCurrent = active?.publicKey === p.publicKey;
40
- const marker = isCurrent ? chalk.green(' ← active') : '';
41
- const handle = p.handle ? chalk.cyan(` @${p.handle}`) : '';
42
- const role = p.role === 'owner' ? chalk.yellow(p.role)
43
- : p.role === 'user' ? chalk.blue(p.role)
44
- : chalk.gray(p.role);
45
- console.log(` ${isCurrent ? '●' : '○'} ${chalk.white(p.name)}${handle} [${role}]${marker}`);
46
- console.log(` ${chalk.gray(`Key: ${p.publicKey.slice(0, 16)}... Last: ${p.lastLogin || 'never'}`)}`);
47
- }
48
- console.log('');
49
- });
50
-
51
- cmd
52
- .command('add [name]')
53
- .description('create a new user profile on this machine (Owner only)')
54
- .option('--role <role>', 'Role for the new profile (owner, user, or guest)', 'user')
55
- .action(async (name, addOpts) => {
56
- migrateToMultiUser();
57
- try {
58
- requireRole('owner');
59
- } catch (err) {
60
- console.log(chalk.red(err.message));
61
- process.exitCode = 1;
62
- return;
63
- }
64
-
65
- const profileName = name || 'New User';
66
-
67
- try {
68
- // Store current identity, create new one
69
- const currentIdentity = config.get('identity');
70
- const newIdentity = await createIdentity(profileName, { force: true });
71
-
72
- // Add as profile with specified role
73
- const role = ['owner', 'user', 'guest'].includes(addOpts.role) ? addOpts.role : 'user';
74
- addProfile(newIdentity.publicKey, null, profileName, role);
75
-
76
- // Restore owner's identity as active in config
77
- config.set('identity', currentIdentity);
78
-
79
- console.log(chalk.green(`✔ Created profile: ${profileName}`));
80
- console.log(chalk.gray(` Public key: ${newIdentity.publicKey.slice(0, 16)}...`));
81
- console.log(chalk.yellow(` Mnemonic (save this!):`));
82
- console.log(chalk.white(` ${newIdentity.mnemonic}`));
83
- console.log('');
84
- console.log(chalk.gray(`They can login with: pe login ${profileName}`));
85
- console.log(chalk.gray(`Then register a handle: pe register <handle>`));
86
- } catch (err) {
87
- console.log(chalk.red(`Failed to create profile: ${err.message}`));
88
- process.exitCode = 1;
89
- }
90
- });
91
-
92
- cmd
93
- .command('remove <handle>')
94
- .description('remove a user profile (Owner only)')
95
- .action((handle) => {
96
- migrateToMultiUser();
97
- try {
98
- requireRole('owner');
99
- } catch (err) {
100
- console.log(chalk.red(err.message));
101
- process.exitCode = 1;
102
- return;
103
- }
104
-
105
- const profiles = getProfiles();
106
- const target = profiles.find(p => p.handle === handle || p.name === handle);
107
- if (!target) {
108
- console.log(chalk.red(`Profile not found: ${handle}`));
109
- process.exitCode = 1;
110
- return;
111
- }
112
-
113
- try {
114
- removeProfile(target.publicKey);
115
- console.log(chalk.green(`✔ Removed profile: ${target.name}`));
116
- } catch (err) {
117
- console.log(chalk.red(err.message));
118
- process.exitCode = 1;
119
- }
120
- });
121
-
122
- cmd
123
- .command('promote <handle>')
124
- .description('promote a guest to user (Owner only)')
125
- .option('--demote', 'Demote user back to guest')
126
- .action((handle, opts) => {
127
- migrateToMultiUser();
128
- try {
129
- requireRole('owner');
130
- } catch (err) {
131
- console.log(chalk.red(err.message));
132
- process.exitCode = 1;
133
- return;
134
- }
135
-
136
- const profiles = getProfiles();
137
- const target = profiles.find(p => p.handle === handle || p.name === handle);
138
- if (!target) {
139
- console.log(chalk.red(`Profile not found: ${handle}`));
140
- process.exitCode = 1;
141
- return;
142
- }
143
-
144
- try {
145
- const newRole = opts.demote ? 'guest' : 'user';
146
- promoteProfile(target.publicKey, newRole);
147
- console.log(chalk.green(`✔ ${target.name} is now ${newRole}`));
148
- } catch (err) {
149
- console.log(chalk.red(err.message));
150
- process.exitCode = 1;
151
- }
152
- });
153
-
154
- // pe login
155
- program
156
- .command('login [handle]')
157
- .description('switch active user profile')
158
- .option('--list', 'List available profiles')
159
- .option('--guest', 'Login as guest with a recovery phrase')
160
- .action(async (handle, opts) => {
161
- // Guest login flow
162
- if (opts.guest) {
163
- const readline = (await import('readline')).default;
164
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
165
- const ask = (q) => new Promise(r => rl.question(q, r));
166
-
167
- try {
168
- const mnemonic = await ask('Enter 24-word recovery phrase: ');
169
- rl.close();
170
- const words = mnemonic.trim().split(/\s+/);
171
- if (words.length !== 24) {
172
- console.log(chalk.red(`Expected 24 words, got ${words.length}.`));
173
- process.exitCode = 1;
174
- return;
175
- }
176
- const guest = await guestLogin(mnemonic.trim());
177
- addGuestProfile(guest.publicKey, null);
178
-
179
- // Try to resolve handle from discovery
180
- try {
181
- const server = getPrimaryServer();
182
- const resolved = await resolveFromServer(server, guest.publicKey.slice(0, 16));
183
- if (resolved?.handle) {
184
- guest.handle = resolved.handle;
185
- }
186
- } catch {}
187
-
188
- console.log(chalk.green(`Logged in as guest (${guest.publicKey.slice(0, 16)}...)`));
189
- console.log(chalk.gray('Guest access: browse shared-with-me, download, view pals/inbox.'));
190
- console.log(chalk.gray('Cannot: share, manage users, change config.'));
191
- } catch (err) {
192
- rl.close();
193
- console.log(chalk.red(`Guest login failed: ${err.message}`));
194
- process.exitCode = 1;
195
- }
196
- return;
197
- }
198
-
199
- migrateToMultiUser();
200
- const profiles = getProfiles();
201
-
202
- if (profiles.length === 0) {
203
- console.log(chalk.red('No profiles. Run `pe init <name>` first.'));
204
- process.exitCode = 1;
205
- return;
206
- }
207
-
208
- if (opts.list || !handle) {
209
- const active = getActiveUser();
210
- console.log('');
211
- console.log(chalk.cyan('Available profiles:'));
212
- for (const p of profiles) {
213
- const isCurrent = active?.publicKey === p.publicKey;
214
- const h = p.handle ? `@${p.handle}` : p.name;
215
- console.log(` ${isCurrent ? chalk.green('●') : '○'} ${h} [${p.role}]`);
216
- }
217
- if (!handle) {
218
- console.log('');
219
- console.log(chalk.gray('Usage: pe login <handle>'));
220
- }
221
- return;
222
- }
223
-
224
- const target = profiles.find(p =>
225
- p.handle === handle || p.name === handle || p.handle === handle.replace(/^@/, '')
226
- );
227
-
228
- if (!target) {
229
- console.log(chalk.red(`Profile not found: ${handle}`));
230
- process.exitCode = 1;
231
- return;
232
- }
233
-
234
- try {
235
- setActiveUser(target.publicKey);
236
- const identity = config.get('identity');
237
- if (identity) {
238
- config.set('identity', {
239
- ...identity,
240
- publicKey: target.publicKey,
241
- handle: target.handle,
242
- name: target.name,
243
- });
244
- }
245
- console.log(chalk.green(`✔ Logged in as ${target.name}${target.handle ? ` (@${target.handle})` : ''} [${target.role}]`));
246
- } catch (err) {
247
- console.log(chalk.red(err.message));
248
- process.exitCode = 1;
249
- }
250
- });
251
-
252
- // pe logout
253
- program
254
- .command('logout')
255
- .description('end guest session and wipe keys from memory')
256
- .action(() => {
257
- if (!isGuestSession()) {
258
- console.log(chalk.yellow('No guest session active. Regular users don\'t need to logout.'));
259
- return;
260
- }
261
- guestLogout();
262
- removeGuestProfile();
263
- console.log(chalk.green('Guest session ended. Keys wiped from memory.'));
264
- });
265
-
266
- cmd.addHelpText('after', `
267
- ${chalk.cyan('Examples:')}
268
- $ pe user list List all profiles
269
- $ pe user add "Bob" Create a user profile
270
- $ pe user remove bob Remove a profile
271
- $ pe user promote bob Promote to user
272
- $ pe user promote bob --demote Demote to guest
273
- $ pe login alice Switch to alice
274
- $ pe login --list Show available profiles
275
- `);
276
- }
1
+ import chalk from 'chalk';
2
+ import config from '../utils/config.js';
3
+ import { createIdentity, getIdentity, guestLogin, guestLogout, isGuestSession } from '../core/identity.js';
4
+ import { resolveFromServer } from '../core/discoveryClient.js';
5
+ import { getPrimaryServer } from '../core/discoveryClient.js';
6
+ import {
7
+ getProfiles,
8
+ getActiveUser,
9
+ setActiveUser,
10
+ addProfile,
11
+ removeProfile,
12
+ promoteProfile,
13
+ requireRole,
14
+ migrateToMultiUser,
15
+ addGuestProfile,
16
+ removeGuestProfile,
17
+ } from '../core/users.js';
18
+
19
+ export default function userCommand(program) {
20
+ const cmd = program.command('user').description('manage user profiles on this machine');
21
+
22
+ cmd
23
+ .command('list')
24
+ .description('list all user profiles')
25
+ .action(() => {
26
+ migrateToMultiUser();
27
+ const profiles = getProfiles();
28
+ const active = getActiveUser();
29
+
30
+ if (profiles.length === 0) {
31
+ console.log(chalk.gray('No profiles. Run `pal init <name>` to create one.'));
32
+ return;
33
+ }
34
+
35
+ console.log('');
36
+ console.log(chalk.cyan.bold('User Profiles'));
37
+ console.log('');
38
+ for (const p of profiles) {
39
+ const isCurrent = active?.publicKey === p.publicKey;
40
+ const marker = isCurrent ? chalk.green(' ← active') : '';
41
+ const handle = p.handle ? chalk.cyan(` @${p.handle}`) : '';
42
+ const role = p.role === 'owner' ? chalk.yellow(p.role)
43
+ : p.role === 'user' ? chalk.blue(p.role)
44
+ : chalk.gray(p.role);
45
+ console.log(` ${isCurrent ? '●' : '○'} ${chalk.white(p.name)}${handle} [${role}]${marker}`);
46
+ console.log(` ${chalk.gray(`Key: ${p.publicKey.slice(0, 16)}... Last: ${p.lastLogin || 'never'}`)}`);
47
+ }
48
+ console.log('');
49
+ });
50
+
51
+ cmd
52
+ .command('add [name]')
53
+ .description('create a new user profile on this machine (Owner only)')
54
+ .option('--role <role>', 'Role for the new profile (owner, user, or guest)', 'user')
55
+ .action(async (name, addOpts) => {
56
+ migrateToMultiUser();
57
+ try {
58
+ requireRole('owner');
59
+ } catch (err) {
60
+ console.log(chalk.red(err.message));
61
+ process.exitCode = 1;
62
+ return;
63
+ }
64
+
65
+ const profileName = name || 'New User';
66
+
67
+ try {
68
+ // Store current identity, create new one
69
+ const currentIdentity = config.get('identity');
70
+ const newIdentity = await createIdentity(profileName, { force: true });
71
+
72
+ // Add as profile with specified role
73
+ const role = ['owner', 'user', 'guest'].includes(addOpts.role) ? addOpts.role : 'user';
74
+ addProfile(newIdentity.publicKey, null, profileName, role);
75
+
76
+ // Restore owner's identity as active in config
77
+ config.set('identity', currentIdentity);
78
+
79
+ console.log(chalk.green(`✔ Created profile: ${profileName}`));
80
+ console.log(chalk.gray(` Public key: ${newIdentity.publicKey.slice(0, 16)}...`));
81
+ console.log(chalk.yellow(` Mnemonic (save this!):`));
82
+ console.log(chalk.white(` ${newIdentity.mnemonic}`));
83
+ console.log('');
84
+ console.log(chalk.gray(`They can login with: pal login ${profileName}`));
85
+ console.log(chalk.gray(`Then register a handle: pal register <handle>`));
86
+ } catch (err) {
87
+ console.log(chalk.red(`Failed to create profile: ${err.message}`));
88
+ process.exitCode = 1;
89
+ }
90
+ });
91
+
92
+ cmd
93
+ .command('remove <handle>')
94
+ .description('remove a user profile (Owner only)')
95
+ .action((handle) => {
96
+ migrateToMultiUser();
97
+ try {
98
+ requireRole('owner');
99
+ } catch (err) {
100
+ console.log(chalk.red(err.message));
101
+ process.exitCode = 1;
102
+ return;
103
+ }
104
+
105
+ const profiles = getProfiles();
106
+ const target = profiles.find(p => p.handle === handle || p.name === handle);
107
+ if (!target) {
108
+ console.log(chalk.red(`Profile not found: ${handle}`));
109
+ process.exitCode = 1;
110
+ return;
111
+ }
112
+
113
+ try {
114
+ removeProfile(target.publicKey);
115
+ console.log(chalk.green(`✔ Removed profile: ${target.name}`));
116
+ } catch (err) {
117
+ console.log(chalk.red(err.message));
118
+ process.exitCode = 1;
119
+ }
120
+ });
121
+
122
+ cmd
123
+ .command('promote <handle>')
124
+ .description('promote a guest to user (Owner only)')
125
+ .option('--demote', 'Demote user back to guest')
126
+ .action((handle, opts) => {
127
+ migrateToMultiUser();
128
+ try {
129
+ requireRole('owner');
130
+ } catch (err) {
131
+ console.log(chalk.red(err.message));
132
+ process.exitCode = 1;
133
+ return;
134
+ }
135
+
136
+ const profiles = getProfiles();
137
+ const target = profiles.find(p => p.handle === handle || p.name === handle);
138
+ if (!target) {
139
+ console.log(chalk.red(`Profile not found: ${handle}`));
140
+ process.exitCode = 1;
141
+ return;
142
+ }
143
+
144
+ try {
145
+ const newRole = opts.demote ? 'guest' : 'user';
146
+ promoteProfile(target.publicKey, newRole);
147
+ console.log(chalk.green(`✔ ${target.name} is now ${newRole}`));
148
+ } catch (err) {
149
+ console.log(chalk.red(err.message));
150
+ process.exitCode = 1;
151
+ }
152
+ });
153
+
154
+ // pal login
155
+ program
156
+ .command('login [handle]')
157
+ .description('switch active user profile')
158
+ .option('--list', 'List available profiles')
159
+ .option('--guest', 'Login as guest with a recovery phrase')
160
+ .action(async (handle, opts) => {
161
+ // Guest login flow
162
+ if (opts.guest) {
163
+ const readline = (await import('readline')).default;
164
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
165
+ const ask = (q) => new Promise(r => rl.question(q, r));
166
+
167
+ try {
168
+ const mnemonic = await ask('Enter 24-word recovery phrase: ');
169
+ rl.close();
170
+ const words = mnemonic.trim().split(/\s+/);
171
+ if (words.length !== 24) {
172
+ console.log(chalk.red(`Expected 24 words, got ${words.length}.`));
173
+ process.exitCode = 1;
174
+ return;
175
+ }
176
+ const guest = await guestLogin(mnemonic.trim());
177
+ addGuestProfile(guest.publicKey, null);
178
+
179
+ // Try to resolve handle from discovery
180
+ try {
181
+ const server = getPrimaryServer();
182
+ const resolved = await resolveFromServer(server, guest.publicKey.slice(0, 16));
183
+ if (resolved?.handle) {
184
+ guest.handle = resolved.handle;
185
+ }
186
+ } catch {}
187
+
188
+ console.log(chalk.green(`Logged in as guest (${guest.publicKey.slice(0, 16)}...)`));
189
+ console.log(chalk.gray('Guest access: browse shared-with-me, download, view pals/inbox.'));
190
+ console.log(chalk.gray('Cannot: share, manage users, change config.'));
191
+ } catch (err) {
192
+ rl.close();
193
+ console.log(chalk.red(`Guest login failed: ${err.message}`));
194
+ process.exitCode = 1;
195
+ }
196
+ return;
197
+ }
198
+
199
+ migrateToMultiUser();
200
+ const profiles = getProfiles();
201
+
202
+ if (profiles.length === 0) {
203
+ console.log(chalk.red('No profiles. Run `pal init <name>` first.'));
204
+ process.exitCode = 1;
205
+ return;
206
+ }
207
+
208
+ if (opts.list || !handle) {
209
+ const active = getActiveUser();
210
+ console.log('');
211
+ console.log(chalk.cyan('Available profiles:'));
212
+ for (const p of profiles) {
213
+ const isCurrent = active?.publicKey === p.publicKey;
214
+ const h = p.handle ? `@${p.handle}` : p.name;
215
+ console.log(` ${isCurrent ? chalk.green('●') : '○'} ${h} [${p.role}]`);
216
+ }
217
+ if (!handle) {
218
+ console.log('');
219
+ console.log(chalk.gray('Usage: pal login <handle>'));
220
+ }
221
+ return;
222
+ }
223
+
224
+ const target = profiles.find(p =>
225
+ p.handle === handle || p.name === handle || p.handle === handle.replace(/^@/, '')
226
+ );
227
+
228
+ if (!target) {
229
+ console.log(chalk.red(`Profile not found: ${handle}`));
230
+ process.exitCode = 1;
231
+ return;
232
+ }
233
+
234
+ try {
235
+ setActiveUser(target.publicKey);
236
+ const identity = config.get('identity');
237
+ if (identity) {
238
+ config.set('identity', {
239
+ ...identity,
240
+ publicKey: target.publicKey,
241
+ handle: target.handle,
242
+ name: target.name,
243
+ });
244
+ }
245
+ console.log(chalk.green(`✔ Logged in as ${target.name}${target.handle ? ` (@${target.handle})` : ''} [${target.role}]`));
246
+ } catch (err) {
247
+ console.log(chalk.red(err.message));
248
+ process.exitCode = 1;
249
+ }
250
+ });
251
+
252
+ // pal logout
253
+ program
254
+ .command('logout')
255
+ .description('end guest session and wipe keys from memory')
256
+ .action(() => {
257
+ if (!isGuestSession()) {
258
+ console.log(chalk.yellow('No guest session active. Regular users don\'t need to logout.'));
259
+ return;
260
+ }
261
+ guestLogout();
262
+ removeGuestProfile();
263
+ console.log(chalk.green('Guest session ended. Keys wiped from memory.'));
264
+ });
265
+
266
+ cmd.addHelpText('after', `
267
+ ${chalk.cyan('Examples:')}
268
+ $ pal user list List all profiles
269
+ $ pal user add "Bob" Create a user profile
270
+ $ pal user remove bob Remove a profile
271
+ $ pal user promote bob Promote to user
272
+ $ pal user promote bob --demote Demote to guest
273
+ $ pal login alice Switch to alice
274
+ $ pal login --list Show available profiles
275
+ `);
276
+ }