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.
- package/README.md +149 -149
- package/bin/pal.js +63 -2
- package/extensions/@palexplorer/analytics/extension.json +20 -1
- package/extensions/@palexplorer/analytics/index.js +19 -9
- package/extensions/@palexplorer/audit/extension.json +14 -0
- package/extensions/@palexplorer/auth-email/extension.json +15 -0
- package/extensions/@palexplorer/auth-oauth/extension.json +15 -0
- package/extensions/@palexplorer/chat/extension.json +14 -0
- package/extensions/@palexplorer/discovery/extension.json +17 -0
- package/extensions/@palexplorer/discovery/index.js +1 -1
- package/extensions/@palexplorer/email-notifications/extension.json +23 -0
- package/extensions/@palexplorer/groups/extension.json +15 -0
- package/extensions/@palexplorer/share-links/extension.json +15 -0
- package/extensions/@palexplorer/sync/extension.json +16 -0
- package/extensions/@palexplorer/user-mgmt/extension.json +15 -0
- package/lib/capabilities.js +24 -24
- package/lib/commands/analytics.js +175 -175
- package/lib/commands/api-keys.js +131 -131
- package/lib/commands/audit.js +235 -235
- package/lib/commands/auth.js +137 -137
- package/lib/commands/backup.js +76 -76
- package/lib/commands/billing.js +148 -148
- package/lib/commands/chat.js +217 -217
- package/lib/commands/cloud-backup.js +231 -231
- package/lib/commands/comment.js +99 -99
- package/lib/commands/completion.js +203 -203
- package/lib/commands/compliance.js +218 -218
- package/lib/commands/config.js +136 -136
- package/lib/commands/connect.js +44 -44
- package/lib/commands/dept.js +294 -294
- package/lib/commands/device.js +146 -146
- package/lib/commands/download.js +240 -226
- package/lib/commands/explorer.js +178 -178
- package/lib/commands/extension.js +1060 -970
- package/lib/commands/favorite.js +90 -90
- package/lib/commands/federation.js +270 -270
- package/lib/commands/file.js +533 -533
- package/lib/commands/group.js +271 -271
- package/lib/commands/gui-share.js +29 -29
- package/lib/commands/init.js +61 -61
- package/lib/commands/invite.js +59 -59
- package/lib/commands/list.js +58 -58
- package/lib/commands/log.js +116 -116
- package/lib/commands/nearby.js +108 -108
- package/lib/commands/network.js +251 -251
- package/lib/commands/notify.js +198 -198
- package/lib/commands/org.js +273 -273
- package/lib/commands/pal.js +403 -180
- package/lib/commands/permissions.js +216 -216
- package/lib/commands/pin.js +97 -97
- package/lib/commands/protocol.js +357 -357
- package/lib/commands/rbac.js +147 -147
- package/lib/commands/recover.js +36 -36
- package/lib/commands/register.js +171 -171
- package/lib/commands/relay.js +131 -131
- package/lib/commands/remote.js +368 -368
- package/lib/commands/revoke.js +50 -50
- package/lib/commands/scanner.js +280 -280
- package/lib/commands/schedule.js +344 -344
- package/lib/commands/scim.js +203 -203
- package/lib/commands/search.js +181 -181
- package/lib/commands/serve.js +438 -438
- package/lib/commands/server.js +350 -350
- package/lib/commands/share-link.js +199 -199
- package/lib/commands/share.js +336 -323
- package/lib/commands/sso.js +200 -200
- package/lib/commands/status.js +145 -145
- package/lib/commands/stream.js +562 -562
- package/lib/commands/su.js +187 -187
- package/lib/commands/sync.js +979 -979
- package/lib/commands/transfers.js +152 -152
- package/lib/commands/uninstall.js +188 -188
- package/lib/commands/update.js +204 -204
- package/lib/commands/user.js +276 -276
- package/lib/commands/vfs.js +84 -84
- package/lib/commands/web-login.js +79 -79
- package/lib/commands/web.js +52 -52
- package/lib/commands/webhook.js +180 -180
- package/lib/commands/whoami.js +59 -59
- package/lib/commands/workspace.js +121 -121
- package/lib/core/billing.js +16 -5
- package/lib/core/dhtDiscovery.js +9 -2
- package/lib/core/discoveryClient.js +13 -7
- package/lib/core/extensions.js +142 -1
- package/lib/core/identity.js +33 -2
- package/lib/core/imageProcessor.js +109 -0
- package/lib/core/imageTorrent.js +167 -0
- package/lib/core/permissions.js +1 -1
- package/lib/core/pro.js +11 -4
- package/lib/core/serverList.js +4 -1
- package/lib/core/shares.js +12 -1
- package/lib/core/signalingServer.js +14 -2
- package/lib/core/su.js +1 -1
- package/lib/core/users.js +1 -1
- package/lib/protocol/messages.js +12 -3
- package/lib/utils/explorer.js +1 -1
- package/lib/utils/help.js +357 -357
- package/lib/utils/torrent.js +1 -0
- package/package.json +4 -3
package/lib/commands/webhook.js
CHANGED
|
@@ -1,180 +1,180 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
|
|
3
|
-
export default function webhookCommand(program) {
|
|
4
|
-
const cmd = program
|
|
5
|
-
.command('webhook')
|
|
6
|
-
.description('manage outgoing webhooks (Pro)')
|
|
7
|
-
.addHelpText('after', `
|
|
8
|
-
Examples:
|
|
9
|
-
$
|
|
10
|
-
$
|
|
11
|
-
$
|
|
12
|
-
$
|
|
13
|
-
$
|
|
14
|
-
`)
|
|
15
|
-
.action(() => { cmd.outputHelp(); });
|
|
16
|
-
|
|
17
|
-
cmd
|
|
18
|
-
.command('add')
|
|
19
|
-
.description('register a new webhook')
|
|
20
|
-
.requiredOption('--name <name>', 'webhook name')
|
|
21
|
-
.requiredOption('--url <url>', 'webhook delivery URL (HTTPS)')
|
|
22
|
-
.requiredOption('--events <events>', 'comma-separated event types')
|
|
23
|
-
.option('--secret <secret>', 'HMAC signing secret')
|
|
24
|
-
.action(async (opts) => {
|
|
25
|
-
try {
|
|
26
|
-
if (!opts.url.startsWith('https://')) {
|
|
27
|
-
console.log(chalk.red('Webhook URL must use HTTPS.'));
|
|
28
|
-
process.exitCode = 1;
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
const extConfig = (await import('../utils/config.js')).default;
|
|
32
|
-
const conf = extConfig.get('ext.webhook-integrations') || {};
|
|
33
|
-
const webhooks = conf.webhooks || [];
|
|
34
|
-
if (webhooks.find(w => w.name === opts.name)) {
|
|
35
|
-
console.log(chalk.red(`Webhook "${opts.name}" already exists. Remove it first.`));
|
|
36
|
-
process.exitCode = 1;
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
webhooks.push({
|
|
40
|
-
name: opts.name,
|
|
41
|
-
url: opts.url,
|
|
42
|
-
events: opts.events.split(',').map(e => e.trim()),
|
|
43
|
-
secret: opts.secret || '',
|
|
44
|
-
enabled: true,
|
|
45
|
-
});
|
|
46
|
-
conf.webhooks = webhooks;
|
|
47
|
-
extConfig.set('ext.webhook-integrations', conf);
|
|
48
|
-
console.log(chalk.green(`✔ Webhook "${opts.name}" added.`));
|
|
49
|
-
console.log(` URL: ${chalk.cyan(opts.url)}`);
|
|
50
|
-
console.log(` Events: ${chalk.white(opts.events)}`);
|
|
51
|
-
} catch (err) {
|
|
52
|
-
console.log(chalk.red(`Failed: ${err.message}`));
|
|
53
|
-
process.exitCode = 1;
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
cmd
|
|
58
|
-
.command('remove <name>')
|
|
59
|
-
.description('remove a webhook')
|
|
60
|
-
.action(async (name) => {
|
|
61
|
-
try {
|
|
62
|
-
const extConfig = (await import('../utils/config.js')).default;
|
|
63
|
-
const conf = extConfig.get('ext.webhook-integrations') || {};
|
|
64
|
-
const webhooks = conf.webhooks || [];
|
|
65
|
-
const idx = webhooks.findIndex(w => w.name === name);
|
|
66
|
-
if (idx === -1) {
|
|
67
|
-
console.log(chalk.yellow(`Webhook "${name}" not found.`));
|
|
68
|
-
process.exitCode = 1;
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
webhooks.splice(idx, 1);
|
|
72
|
-
conf.webhooks = webhooks;
|
|
73
|
-
extConfig.set('ext.webhook-integrations', conf);
|
|
74
|
-
console.log(chalk.green(`✔ Webhook "${name}" removed.`));
|
|
75
|
-
} catch (err) {
|
|
76
|
-
console.log(chalk.red(`Failed: ${err.message}`));
|
|
77
|
-
process.exitCode = 1;
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
cmd
|
|
82
|
-
.command('list')
|
|
83
|
-
.description('list all registered webhooks')
|
|
84
|
-
.action(async () => {
|
|
85
|
-
try {
|
|
86
|
-
const extConfig = (await import('../utils/config.js')).default;
|
|
87
|
-
const conf = extConfig.get('ext.webhook-integrations') || {};
|
|
88
|
-
const webhooks = conf.webhooks || [];
|
|
89
|
-
if (webhooks.length === 0) {
|
|
90
|
-
console.log(chalk.dim('No webhooks configured.'));
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
console.log(chalk.bold(`Webhooks (${webhooks.length})\n`));
|
|
94
|
-
for (const w of webhooks) {
|
|
95
|
-
const status = w.enabled ? chalk.green('●') : chalk.red('○');
|
|
96
|
-
console.log(` ${status} ${chalk.cyan(w.name)}`);
|
|
97
|
-
console.log(` URL: ${chalk.white(w.url)}`);
|
|
98
|
-
console.log(` Events: ${chalk.dim(w.events.join(', '))}`);
|
|
99
|
-
console.log(` Secret: ${w.secret ? chalk.dim('configured') : chalk.dim('none')}`);
|
|
100
|
-
}
|
|
101
|
-
} catch (err) {
|
|
102
|
-
console.log(chalk.red(`Failed: ${err.message}`));
|
|
103
|
-
process.exitCode = 1;
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
cmd
|
|
108
|
-
.command('test <name>')
|
|
109
|
-
.description('send a test ping to a webhook')
|
|
110
|
-
.action(async (name) => {
|
|
111
|
-
try {
|
|
112
|
-
const extConfig = (await import('../utils/config.js')).default;
|
|
113
|
-
const conf = extConfig.get('ext.webhook-integrations') || {};
|
|
114
|
-
const webhooks = conf.webhooks || [];
|
|
115
|
-
const webhook = webhooks.find(w => w.name === name);
|
|
116
|
-
if (!webhook) {
|
|
117
|
-
console.log(chalk.red(`Webhook "${name}" not found.`));
|
|
118
|
-
process.exitCode = 1;
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const payload = JSON.stringify({
|
|
123
|
-
event: 'test.ping',
|
|
124
|
-
data: { message: 'Test ping from Palexplorer' },
|
|
125
|
-
timestamp: new Date().toISOString(),
|
|
126
|
-
source: 'palexplorer',
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
const headers = { 'Content-Type': 'application/json' };
|
|
130
|
-
if (webhook.secret) {
|
|
131
|
-
const crypto = await import('crypto');
|
|
132
|
-
const sig = crypto.createHmac('sha256', webhook.secret).update(payload).digest('hex');
|
|
133
|
-
headers['X-Palexplorer-Signature'] = `sha256=${sig}`;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
console.log(chalk.dim(`Sending test ping to ${webhook.url}...`));
|
|
137
|
-
const res = await fetch(webhook.url, { method: 'POST', headers, body: payload });
|
|
138
|
-
if (res.ok) {
|
|
139
|
-
console.log(chalk.green(`✔ Test ping delivered (${res.status}).`));
|
|
140
|
-
} else {
|
|
141
|
-
console.log(chalk.yellow(`⚠ Server responded with ${res.status}.`));
|
|
142
|
-
}
|
|
143
|
-
} catch (err) {
|
|
144
|
-
console.log(chalk.red(`Test failed: ${err.message}`));
|
|
145
|
-
process.exitCode = 1;
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
cmd
|
|
150
|
-
.command('log')
|
|
151
|
-
.description('show webhook delivery log')
|
|
152
|
-
.option('--limit <n>', 'number of entries', '20')
|
|
153
|
-
.option('--verbose', 'show full payload')
|
|
154
|
-
.action(async (opts) => {
|
|
155
|
-
try {
|
|
156
|
-
const extConfig = (await import('../utils/config.js')).default;
|
|
157
|
-
const store = extConfig.get('ext_store.webhook-integrations') || {};
|
|
158
|
-
const log = store.deliveryLog || [];
|
|
159
|
-
const limit = parseInt(opts.limit, 10) || 20;
|
|
160
|
-
const entries = log.slice(-limit);
|
|
161
|
-
|
|
162
|
-
if (entries.length === 0) {
|
|
163
|
-
console.log(chalk.dim('No delivery log entries.'));
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
console.log(chalk.bold(`Delivery Log (last ${entries.length})\n`));
|
|
168
|
-
for (const entry of entries) {
|
|
169
|
-
const icon = entry.success ? chalk.green('✔') : chalk.red('✗');
|
|
170
|
-
console.log(` ${icon} ${chalk.dim(entry.timestamp)} ${chalk.cyan(entry.event)} → ${entry.status || 'failed'}`);
|
|
171
|
-
if (opts.verbose && entry.payload) {
|
|
172
|
-
console.log(` ${chalk.dim(JSON.stringify(entry.payload).slice(0, 200))}`);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
} catch (err) {
|
|
176
|
-
console.log(chalk.red(`Failed: ${err.message}`));
|
|
177
|
-
process.exitCode = 1;
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
}
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
|
|
3
|
+
export default function webhookCommand(program) {
|
|
4
|
+
const cmd = program
|
|
5
|
+
.command('webhook')
|
|
6
|
+
.description('manage outgoing webhooks (Pro)')
|
|
7
|
+
.addHelpText('after', `
|
|
8
|
+
Examples:
|
|
9
|
+
$ pal webhook add --name deploy --url https://hook.example.com --events share.created
|
|
10
|
+
$ pal webhook list
|
|
11
|
+
$ pal webhook test deploy
|
|
12
|
+
$ pal webhook log
|
|
13
|
+
$ pal webhook remove deploy
|
|
14
|
+
`)
|
|
15
|
+
.action(() => { cmd.outputHelp(); });
|
|
16
|
+
|
|
17
|
+
cmd
|
|
18
|
+
.command('add')
|
|
19
|
+
.description('register a new webhook')
|
|
20
|
+
.requiredOption('--name <name>', 'webhook name')
|
|
21
|
+
.requiredOption('--url <url>', 'webhook delivery URL (HTTPS)')
|
|
22
|
+
.requiredOption('--events <events>', 'comma-separated event types')
|
|
23
|
+
.option('--secret <secret>', 'HMAC signing secret')
|
|
24
|
+
.action(async (opts) => {
|
|
25
|
+
try {
|
|
26
|
+
if (!opts.url.startsWith('https://')) {
|
|
27
|
+
console.log(chalk.red('Webhook URL must use HTTPS.'));
|
|
28
|
+
process.exitCode = 1;
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const extConfig = (await import('../utils/config.js')).default;
|
|
32
|
+
const conf = extConfig.get('ext.webhook-integrations') || {};
|
|
33
|
+
const webhooks = conf.webhooks || [];
|
|
34
|
+
if (webhooks.find(w => w.name === opts.name)) {
|
|
35
|
+
console.log(chalk.red(`Webhook "${opts.name}" already exists. Remove it first.`));
|
|
36
|
+
process.exitCode = 1;
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
webhooks.push({
|
|
40
|
+
name: opts.name,
|
|
41
|
+
url: opts.url,
|
|
42
|
+
events: opts.events.split(',').map(e => e.trim()),
|
|
43
|
+
secret: opts.secret || '',
|
|
44
|
+
enabled: true,
|
|
45
|
+
});
|
|
46
|
+
conf.webhooks = webhooks;
|
|
47
|
+
extConfig.set('ext.webhook-integrations', conf);
|
|
48
|
+
console.log(chalk.green(`✔ Webhook "${opts.name}" added.`));
|
|
49
|
+
console.log(` URL: ${chalk.cyan(opts.url)}`);
|
|
50
|
+
console.log(` Events: ${chalk.white(opts.events)}`);
|
|
51
|
+
} catch (err) {
|
|
52
|
+
console.log(chalk.red(`Failed: ${err.message}`));
|
|
53
|
+
process.exitCode = 1;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
cmd
|
|
58
|
+
.command('remove <name>')
|
|
59
|
+
.description('remove a webhook')
|
|
60
|
+
.action(async (name) => {
|
|
61
|
+
try {
|
|
62
|
+
const extConfig = (await import('../utils/config.js')).default;
|
|
63
|
+
const conf = extConfig.get('ext.webhook-integrations') || {};
|
|
64
|
+
const webhooks = conf.webhooks || [];
|
|
65
|
+
const idx = webhooks.findIndex(w => w.name === name);
|
|
66
|
+
if (idx === -1) {
|
|
67
|
+
console.log(chalk.yellow(`Webhook "${name}" not found.`));
|
|
68
|
+
process.exitCode = 1;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
webhooks.splice(idx, 1);
|
|
72
|
+
conf.webhooks = webhooks;
|
|
73
|
+
extConfig.set('ext.webhook-integrations', conf);
|
|
74
|
+
console.log(chalk.green(`✔ Webhook "${name}" removed.`));
|
|
75
|
+
} catch (err) {
|
|
76
|
+
console.log(chalk.red(`Failed: ${err.message}`));
|
|
77
|
+
process.exitCode = 1;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
cmd
|
|
82
|
+
.command('list')
|
|
83
|
+
.description('list all registered webhooks')
|
|
84
|
+
.action(async () => {
|
|
85
|
+
try {
|
|
86
|
+
const extConfig = (await import('../utils/config.js')).default;
|
|
87
|
+
const conf = extConfig.get('ext.webhook-integrations') || {};
|
|
88
|
+
const webhooks = conf.webhooks || [];
|
|
89
|
+
if (webhooks.length === 0) {
|
|
90
|
+
console.log(chalk.dim('No webhooks configured.'));
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
console.log(chalk.bold(`Webhooks (${webhooks.length})\n`));
|
|
94
|
+
for (const w of webhooks) {
|
|
95
|
+
const status = w.enabled ? chalk.green('●') : chalk.red('○');
|
|
96
|
+
console.log(` ${status} ${chalk.cyan(w.name)}`);
|
|
97
|
+
console.log(` URL: ${chalk.white(w.url)}`);
|
|
98
|
+
console.log(` Events: ${chalk.dim(w.events.join(', '))}`);
|
|
99
|
+
console.log(` Secret: ${w.secret ? chalk.dim('configured') : chalk.dim('none')}`);
|
|
100
|
+
}
|
|
101
|
+
} catch (err) {
|
|
102
|
+
console.log(chalk.red(`Failed: ${err.message}`));
|
|
103
|
+
process.exitCode = 1;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
cmd
|
|
108
|
+
.command('test <name>')
|
|
109
|
+
.description('send a test ping to a webhook')
|
|
110
|
+
.action(async (name) => {
|
|
111
|
+
try {
|
|
112
|
+
const extConfig = (await import('../utils/config.js')).default;
|
|
113
|
+
const conf = extConfig.get('ext.webhook-integrations') || {};
|
|
114
|
+
const webhooks = conf.webhooks || [];
|
|
115
|
+
const webhook = webhooks.find(w => w.name === name);
|
|
116
|
+
if (!webhook) {
|
|
117
|
+
console.log(chalk.red(`Webhook "${name}" not found.`));
|
|
118
|
+
process.exitCode = 1;
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const payload = JSON.stringify({
|
|
123
|
+
event: 'test.ping',
|
|
124
|
+
data: { message: 'Test ping from Palexplorer' },
|
|
125
|
+
timestamp: new Date().toISOString(),
|
|
126
|
+
source: 'palexplorer',
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
130
|
+
if (webhook.secret) {
|
|
131
|
+
const crypto = await import('crypto');
|
|
132
|
+
const sig = crypto.createHmac('sha256', webhook.secret).update(payload).digest('hex');
|
|
133
|
+
headers['X-Palexplorer-Signature'] = `sha256=${sig}`;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
console.log(chalk.dim(`Sending test ping to ${webhook.url}...`));
|
|
137
|
+
const res = await fetch(webhook.url, { method: 'POST', headers, body: payload });
|
|
138
|
+
if (res.ok) {
|
|
139
|
+
console.log(chalk.green(`✔ Test ping delivered (${res.status}).`));
|
|
140
|
+
} else {
|
|
141
|
+
console.log(chalk.yellow(`⚠ Server responded with ${res.status}.`));
|
|
142
|
+
}
|
|
143
|
+
} catch (err) {
|
|
144
|
+
console.log(chalk.red(`Test failed: ${err.message}`));
|
|
145
|
+
process.exitCode = 1;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
cmd
|
|
150
|
+
.command('log')
|
|
151
|
+
.description('show webhook delivery log')
|
|
152
|
+
.option('--limit <n>', 'number of entries', '20')
|
|
153
|
+
.option('--verbose', 'show full payload')
|
|
154
|
+
.action(async (opts) => {
|
|
155
|
+
try {
|
|
156
|
+
const extConfig = (await import('../utils/config.js')).default;
|
|
157
|
+
const store = extConfig.get('ext_store.webhook-integrations') || {};
|
|
158
|
+
const log = store.deliveryLog || [];
|
|
159
|
+
const limit = parseInt(opts.limit, 10) || 20;
|
|
160
|
+
const entries = log.slice(-limit);
|
|
161
|
+
|
|
162
|
+
if (entries.length === 0) {
|
|
163
|
+
console.log(chalk.dim('No delivery log entries.'));
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
console.log(chalk.bold(`Delivery Log (last ${entries.length})\n`));
|
|
168
|
+
for (const entry of entries) {
|
|
169
|
+
const icon = entry.success ? chalk.green('✔') : chalk.red('✗');
|
|
170
|
+
console.log(` ${icon} ${chalk.dim(entry.timestamp)} ${chalk.cyan(entry.event)} → ${entry.status || 'failed'}`);
|
|
171
|
+
if (opts.verbose && entry.payload) {
|
|
172
|
+
console.log(` ${chalk.dim(JSON.stringify(entry.payload).slice(0, 200))}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
} catch (err) {
|
|
176
|
+
console.log(chalk.red(`Failed: ${err.message}`));
|
|
177
|
+
process.exitCode = 1;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
package/lib/commands/whoami.js
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { getIdentity } from '../core/identity.js';
|
|
3
|
-
import { getActiveUser, getProfiles } from '../core/users.js';
|
|
4
|
-
|
|
5
|
-
export default function whoamiCommand(program) {
|
|
6
|
-
program
|
|
7
|
-
.command('whoami')
|
|
8
|
-
.description('display your current identity details')
|
|
9
|
-
.addHelpText('after', `
|
|
10
|
-
Examples:
|
|
11
|
-
$
|
|
12
|
-
`)
|
|
13
|
-
.action(async () => {
|
|
14
|
-
const identity = await getIdentity();
|
|
15
|
-
|
|
16
|
-
if (!identity) {
|
|
17
|
-
console.log(chalk.red('No identity found. Run `
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const activeUser = getActiveUser();
|
|
22
|
-
const profiles = getProfiles();
|
|
23
|
-
const role = activeUser?.role || 'owner';
|
|
24
|
-
|
|
25
|
-
if (program.opts().json) {
|
|
26
|
-
console.log(JSON.stringify({
|
|
27
|
-
name: identity.name || 'Unknown',
|
|
28
|
-
handle: identity.handle || null,
|
|
29
|
-
role,
|
|
30
|
-
publicKey: identity.publicKey,
|
|
31
|
-
deviceName: identity.deviceName || 'Unknown',
|
|
32
|
-
deviceId: identity.deviceId || 'Unknown',
|
|
33
|
-
createdAt: identity.createdAt,
|
|
34
|
-
profileCount: profiles.length,
|
|
35
|
-
}, null, 2));
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const roleColor = role === 'owner' ? chalk.yellow : role === 'user' ? chalk.blue : chalk.gray;
|
|
40
|
-
|
|
41
|
-
console.log('');
|
|
42
|
-
console.log(chalk.cyan('Your Identity:'));
|
|
43
|
-
console.log(` Name: ${chalk.green(identity.name || 'Unknown')}`);
|
|
44
|
-
console.log(` Handle: ${chalk.green(identity.handle ? `@${identity.handle}` : 'Not registered')}`);
|
|
45
|
-
console.log(` Role: ${roleColor(role)}`);
|
|
46
|
-
console.log(` Public Key: ${chalk.yellow(identity.publicKey)}`);
|
|
47
|
-
console.log(` Device: ${chalk.gray(identity.deviceName || 'Unknown')} ${chalk.gray(`(${identity.deviceId || 'Unknown'})`)}`);
|
|
48
|
-
console.log(` Created At: ${chalk.gray(identity.createdAt)}`);
|
|
49
|
-
if (profiles.length > 1) {
|
|
50
|
-
console.log(` Profiles: ${chalk.gray(`${profiles.length} users on this machine`)}`);
|
|
51
|
-
}
|
|
52
|
-
console.log('');
|
|
53
|
-
if (!identity.handle) {
|
|
54
|
-
console.log(chalk.gray('Register a handle:
|
|
55
|
-
} else {
|
|
56
|
-
console.log(chalk.gray('Others can add you:
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { getIdentity } from '../core/identity.js';
|
|
3
|
+
import { getActiveUser, getProfiles } from '../core/users.js';
|
|
4
|
+
|
|
5
|
+
export default function whoamiCommand(program) {
|
|
6
|
+
program
|
|
7
|
+
.command('whoami')
|
|
8
|
+
.description('display your current identity details')
|
|
9
|
+
.addHelpText('after', `
|
|
10
|
+
Examples:
|
|
11
|
+
$ pal whoami Show your identity info
|
|
12
|
+
`)
|
|
13
|
+
.action(async () => {
|
|
14
|
+
const identity = await getIdentity();
|
|
15
|
+
|
|
16
|
+
if (!identity) {
|
|
17
|
+
console.log(chalk.red('No identity found. Run `pal init <name>` to get started!'));
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const activeUser = getActiveUser();
|
|
22
|
+
const profiles = getProfiles();
|
|
23
|
+
const role = activeUser?.role || 'owner';
|
|
24
|
+
|
|
25
|
+
if (program.opts().json) {
|
|
26
|
+
console.log(JSON.stringify({
|
|
27
|
+
name: identity.name || 'Unknown',
|
|
28
|
+
handle: identity.handle || null,
|
|
29
|
+
role,
|
|
30
|
+
publicKey: identity.publicKey,
|
|
31
|
+
deviceName: identity.deviceName || 'Unknown',
|
|
32
|
+
deviceId: identity.deviceId || 'Unknown',
|
|
33
|
+
createdAt: identity.createdAt,
|
|
34
|
+
profileCount: profiles.length,
|
|
35
|
+
}, null, 2));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const roleColor = role === 'owner' ? chalk.yellow : role === 'user' ? chalk.blue : chalk.gray;
|
|
40
|
+
|
|
41
|
+
console.log('');
|
|
42
|
+
console.log(chalk.cyan('Your Identity:'));
|
|
43
|
+
console.log(` Name: ${chalk.green(identity.name || 'Unknown')}`);
|
|
44
|
+
console.log(` Handle: ${chalk.green(identity.handle ? `@${identity.handle}` : 'Not registered')}`);
|
|
45
|
+
console.log(` Role: ${roleColor(role)}`);
|
|
46
|
+
console.log(` Public Key: ${chalk.yellow(identity.publicKey)}`);
|
|
47
|
+
console.log(` Device: ${chalk.gray(identity.deviceName || 'Unknown')} ${chalk.gray(`(${identity.deviceId || 'Unknown'})`)}`);
|
|
48
|
+
console.log(` Created At: ${chalk.gray(identity.createdAt)}`);
|
|
49
|
+
if (profiles.length > 1) {
|
|
50
|
+
console.log(` Profiles: ${chalk.gray(`${profiles.length} users on this machine`)}`);
|
|
51
|
+
}
|
|
52
|
+
console.log('');
|
|
53
|
+
if (!identity.handle) {
|
|
54
|
+
console.log(chalk.gray('Register a handle: pal register <handle>'));
|
|
55
|
+
} else {
|
|
56
|
+
console.log(chalk.gray('Others can add you: pal pal add @' + identity.handle));
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|