pal-explorer-cli 0.4.11 → 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,187 +1,187 @@
1
- import chalk from 'chalk';
2
- import readline from 'readline';
3
- import config from '../utils/config.js';
4
- import { setSuToken, hasSuToken, authenticate, isAuthenticated, requireSu, removeSuToken } from '../core/su.js';
5
- import { getPrimaryServer, getServers, addServer as addDiscoveryServer, removeServer as removeDiscoveryServer, setPrimaryServer, addUserServer } from '../core/discoveryClient.js';
6
- import { refreshServerList, healthCheckServers, getServerRoles, SERVER_ROLES, isWriteTrusted } from '../core/serverList.js';
7
- import { parseCommaList } from '../utils/cli.js';
8
-
9
- function prompt(question, { hidden = false } = {}) {
10
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
11
- if (hidden) {
12
- const origWrite = process.stdout.write.bind(process.stdout);
13
- process.stdout.write = (s) => {
14
- if (s === question) return origWrite(s);
15
- return origWrite('');
16
- };
17
- return new Promise(resolve => rl.question(question, answer => {
18
- process.stdout.write = origWrite;
19
- origWrite('\n');
20
- rl.close();
21
- resolve(answer.trim());
22
- }));
23
- }
24
- return new Promise(resolve => rl.question(question, answer => { rl.close(); resolve(answer.trim()); }));
25
- }
26
-
27
- function confirm(question) {
28
- return prompt(question).then(a => a.toLowerCase() === 'y');
29
- }
30
-
31
- export default function suCommand(program) {
32
- const su = program.command('su').description('super user commands (network-level administration)');
33
-
34
- su.addHelpText('after', `
35
- The super user (SU) controls the discovery server network.
36
- SU is separate from the local device owner role.
37
-
38
- Setup:
39
- $ pe su setup Set the SU token (first time only)
40
- $ pe su auth Authenticate for this session
41
-
42
- Server management:
43
- $ pe su server add <url> Add a server to the network
44
- $ pe su server remove <url> Remove a server
45
- $ pe su server set-primary <url> Change primary server
46
-
47
- Other:
48
- $ pe su reset Remove the SU token
49
- `);
50
-
51
- su
52
- .command('setup')
53
- .description('set the super user token (first time or reset)')
54
- .action(async () => {
55
- if (hasSuToken()) {
56
- const current = await prompt('Enter current SU token: ', { hidden: true });
57
- if (!authenticate(current)) {
58
- console.log(chalk.red('Invalid SU token.'));
59
- return;
60
- }
61
- }
62
- const token = await prompt('Enter new SU token: ', { hidden: true });
63
- if (!token || token.length < 8) {
64
- console.log(chalk.red('Token must be at least 8 characters.'));
65
- return;
66
- }
67
- const confirm2 = await prompt('Confirm SU token: ', { hidden: true });
68
- if (token !== confirm2) {
69
- console.log(chalk.red('Tokens do not match.'));
70
- return;
71
- }
72
- setSuToken(token);
73
- authenticate(token);
74
- console.log(chalk.green('SU token set and authenticated for this session.'));
75
- });
76
-
77
- su
78
- .command('auth')
79
- .description('authenticate as super user for this session')
80
- .action(async () => {
81
- if (!hasSuToken()) {
82
- console.log(chalk.red('No SU token configured. Run "pe su setup" first.'));
83
- return;
84
- }
85
- if (isAuthenticated()) {
86
- console.log(chalk.green('Already authenticated as SU.'));
87
- return;
88
- }
89
- const token = await prompt('SU token: ', { hidden: true });
90
- if (authenticate(token)) {
91
- console.log(chalk.green('Authenticated as super user.'));
92
- } else {
93
- console.log(chalk.red('Invalid SU token.'));
94
- }
95
- });
96
-
97
- su
98
- .command('reset')
99
- .description('remove the SU token')
100
- .action(async () => {
101
- if (!hasSuToken()) {
102
- console.log(chalk.yellow('No SU token is set.'));
103
- return;
104
- }
105
- const token = await prompt('Enter current SU token to confirm: ', { hidden: true });
106
- if (!authenticate(token)) {
107
- console.log(chalk.red('Invalid SU token.'));
108
- return;
109
- }
110
- removeSuToken();
111
- console.log(chalk.green('SU token removed.'));
112
- });
113
-
114
- // Server management subcommands
115
- const server = su.command('server').description('manage discovery servers (SU only)');
116
-
117
- server
118
- .command('add <url>')
119
- .description('add a discovery server to the network')
120
- .option('-y, --yes', 'Skip confirmation prompt')
121
- .option('--skip-verify', 'Skip server verification (not recommended)')
122
- .option('--read-only', 'Add as read-only (no writes sent to this server)')
123
- .option('--roles <roles>', 'Comma-separated roles (discovery,signaling,turn,stun,relay,billing)')
124
- .action(async (url, opts) => {
125
- try { requireSu(); } catch (e) { console.log(chalk.red(e.message)); return; }
126
- const roles = parseCommaList(opts.roles).filter(r => SERVER_ROLES.includes(r));
127
- const trustWrites = !opts.readOnly;
128
-
129
- if (opts.skipVerify) {
130
- addDiscoveryServer(url, { skipVerify: true });
131
- if (roles.length > 0) {
132
- await addUserServer(url, roles, { trustWrites });
133
- }
134
- console.log(chalk.yellow('Added without verification (no pinned key).'));
135
- return;
136
- }
137
-
138
- try {
139
- console.log(chalk.blue(`Verifying server at ${url}...`));
140
- const result = await addDiscoveryServer(url);
141
- console.log('');
142
- console.log(chalk.white(` Server key fingerprint: ${chalk.cyan(result.fingerprint)}`));
143
- console.log(chalk.gray(` Trust: ${trustWrites ? 'read + write' : 'read-only'}`));
144
- console.log('');
145
-
146
- if (!opts.yes) {
147
- const ok = await confirm(chalk.white(' Trust this server and add it? (y/N) '));
148
- if (!ok) {
149
- removeDiscoveryServer(url);
150
- const pinned = config.get('pinnedServerKeys') || {};
151
- delete pinned[url.replace(/\/+$/, '')];
152
- config.set('pinnedServerKeys', pinned);
153
- console.log(chalk.yellow(' Aborted.'));
154
- return;
155
- }
156
- }
157
-
158
- const roleResult = await addUserServer(url, roles, { trustWrites });
159
- console.log(chalk.green(`Added server: ${url}`));
160
- console.log(chalk.gray(` Roles: ${roleResult.roles.join(', ')}`));
161
- console.log(chalk.gray(` Trust: ${trustWrites ? 'read + write' : 'read-only'}`));
162
- console.log(chalk.gray(` Key pinned. Run 'pe server verify' to re-check.`));
163
- } catch (err) {
164
- console.log(chalk.red(`${err.message}`));
165
- }
166
- });
167
-
168
- server
169
- .command('remove <url>')
170
- .description('remove a discovery server from the network')
171
- .action((url) => {
172
- try { requireSu(); } catch (e) { console.log(chalk.red(e.message)); return; }
173
- const servers = removeDiscoveryServer(url);
174
- console.log(chalk.green(`Removed: ${url}`));
175
- console.log(chalk.gray(` Remaining: ${servers.length}`));
176
- });
177
-
178
- server
179
- .command('set-primary <url>')
180
- .description('set a discovery server as the primary')
181
- .action((url) => {
182
- try { requireSu(); } catch (e) { console.log(chalk.red(e.message)); return; }
183
- const servers = setPrimaryServer(url);
184
- console.log(chalk.green(`Primary set to: ${url}`));
185
- console.log(chalk.gray(` Order: ${servers.join(', ')}`));
186
- });
187
- }
1
+ import chalk from 'chalk';
2
+ import readline from 'readline';
3
+ import config from '../utils/config.js';
4
+ import { setSuToken, hasSuToken, authenticate, isAuthenticated, requireSu, removeSuToken } from '../core/su.js';
5
+ import { getPrimaryServer, getServers, addServer as addDiscoveryServer, removeServer as removeDiscoveryServer, setPrimaryServer, addUserServer } from '../core/discoveryClient.js';
6
+ import { refreshServerList, healthCheckServers, getServerRoles, SERVER_ROLES, isWriteTrusted } from '../core/serverList.js';
7
+ import { parseCommaList } from '../utils/cli.js';
8
+
9
+ function prompt(question, { hidden = false } = {}) {
10
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
11
+ if (hidden) {
12
+ const origWrite = process.stdout.write.bind(process.stdout);
13
+ process.stdout.write = (s) => {
14
+ if (s === question) return origWrite(s);
15
+ return origWrite('');
16
+ };
17
+ return new Promise(resolve => rl.question(question, answer => {
18
+ process.stdout.write = origWrite;
19
+ origWrite('\n');
20
+ rl.close();
21
+ resolve(answer.trim());
22
+ }));
23
+ }
24
+ return new Promise(resolve => rl.question(question, answer => { rl.close(); resolve(answer.trim()); }));
25
+ }
26
+
27
+ function confirm(question) {
28
+ return prompt(question).then(a => a.toLowerCase() === 'y');
29
+ }
30
+
31
+ export default function suCommand(program) {
32
+ const su = program.command('su').description('super user commands (network-level administration)');
33
+
34
+ su.addHelpText('after', `
35
+ The super user (SU) controls the discovery server network.
36
+ SU is separate from the local device owner role.
37
+
38
+ Setup:
39
+ $ pal su setup Set the SU token (first time only)
40
+ $ pal su auth Authenticate for this session
41
+
42
+ Server management:
43
+ $ pal su server add <url> Add a server to the network
44
+ $ pal su server remove <url> Remove a server
45
+ $ pal su server set-primary <url> Change primary server
46
+
47
+ Other:
48
+ $ pal su reset Remove the SU token
49
+ `);
50
+
51
+ su
52
+ .command('setup')
53
+ .description('set the super user token (first time or reset)')
54
+ .action(async () => {
55
+ if (hasSuToken()) {
56
+ const current = await prompt('Enter current SU token: ', { hidden: true });
57
+ if (!authenticate(current)) {
58
+ console.log(chalk.red('Invalid SU token.'));
59
+ return;
60
+ }
61
+ }
62
+ const token = await prompt('Enter new SU token: ', { hidden: true });
63
+ if (!token || token.length < 8) {
64
+ console.log(chalk.red('Token must be at least 8 characters.'));
65
+ return;
66
+ }
67
+ const confirm2 = await prompt('Confirm SU token: ', { hidden: true });
68
+ if (token !== confirm2) {
69
+ console.log(chalk.red('Tokens do not match.'));
70
+ return;
71
+ }
72
+ setSuToken(token);
73
+ authenticate(token);
74
+ console.log(chalk.green('SU token set and authenticated for this session.'));
75
+ });
76
+
77
+ su
78
+ .command('auth')
79
+ .description('authenticate as super user for this session')
80
+ .action(async () => {
81
+ if (!hasSuToken()) {
82
+ console.log(chalk.red('No SU token configured. Run "pal su setup" first.'));
83
+ return;
84
+ }
85
+ if (isAuthenticated()) {
86
+ console.log(chalk.green('Already authenticated as SU.'));
87
+ return;
88
+ }
89
+ const token = await prompt('SU token: ', { hidden: true });
90
+ if (authenticate(token)) {
91
+ console.log(chalk.green('Authenticated as super user.'));
92
+ } else {
93
+ console.log(chalk.red('Invalid SU token.'));
94
+ }
95
+ });
96
+
97
+ su
98
+ .command('reset')
99
+ .description('remove the SU token')
100
+ .action(async () => {
101
+ if (!hasSuToken()) {
102
+ console.log(chalk.yellow('No SU token is set.'));
103
+ return;
104
+ }
105
+ const token = await prompt('Enter current SU token to confirm: ', { hidden: true });
106
+ if (!authenticate(token)) {
107
+ console.log(chalk.red('Invalid SU token.'));
108
+ return;
109
+ }
110
+ removeSuToken();
111
+ console.log(chalk.green('SU token removed.'));
112
+ });
113
+
114
+ // Server management subcommands
115
+ const server = su.command('server').description('manage discovery servers (SU only)');
116
+
117
+ server
118
+ .command('add <url>')
119
+ .description('add a discovery server to the network')
120
+ .option('-y, --yes', 'Skip confirmation prompt')
121
+ .option('--skip-verify', 'Skip server verification (not recommended)')
122
+ .option('--read-only', 'Add as read-only (no writes sent to this server)')
123
+ .option('--roles <roles>', 'Comma-separated roles (discovery,signaling,turn,stun,relay,billing)')
124
+ .action(async (url, opts) => {
125
+ try { requireSu(); } catch (e) { console.log(chalk.red(e.message)); return; }
126
+ const roles = parseCommaList(opts.roles).filter(r => SERVER_ROLES.includes(r));
127
+ const trustWrites = !opts.readOnly;
128
+
129
+ if (opts.skipVerify) {
130
+ addDiscoveryServer(url, { skipVerify: true });
131
+ if (roles.length > 0) {
132
+ await addUserServer(url, roles, { trustWrites });
133
+ }
134
+ console.log(chalk.yellow('Added without verification (no pinned key).'));
135
+ return;
136
+ }
137
+
138
+ try {
139
+ console.log(chalk.blue(`Verifying server at ${url}...`));
140
+ const result = await addDiscoveryServer(url);
141
+ console.log('');
142
+ console.log(chalk.white(` Server key fingerprint: ${chalk.cyan(result.fingerprint)}`));
143
+ console.log(chalk.gray(` Trust: ${trustWrites ? 'read + write' : 'read-only'}`));
144
+ console.log('');
145
+
146
+ if (!opts.yes) {
147
+ const ok = await confirm(chalk.white(' Trust this server and add it? (y/N) '));
148
+ if (!ok) {
149
+ removeDiscoveryServer(url);
150
+ const pinned = config.get('pinnedServerKeys') || {};
151
+ delete pinned[url.replace(/\/+$/, '')];
152
+ config.set('pinnedServerKeys', pinned);
153
+ console.log(chalk.yellow(' Aborted.'));
154
+ return;
155
+ }
156
+ }
157
+
158
+ const roleResult = await addUserServer(url, roles, { trustWrites });
159
+ console.log(chalk.green(`Added server: ${url}`));
160
+ console.log(chalk.gray(` Roles: ${roleResult.roles.join(', ')}`));
161
+ console.log(chalk.gray(` Trust: ${trustWrites ? 'read + write' : 'read-only'}`));
162
+ console.log(chalk.gray(` Key pinned. Run 'pal server verify' to re-check.`));
163
+ } catch (err) {
164
+ console.log(chalk.red(`${err.message}`));
165
+ }
166
+ });
167
+
168
+ server
169
+ .command('remove <url>')
170
+ .description('remove a discovery server from the network')
171
+ .action((url) => {
172
+ try { requireSu(); } catch (e) { console.log(chalk.red(e.message)); return; }
173
+ const servers = removeDiscoveryServer(url);
174
+ console.log(chalk.green(`Removed: ${url}`));
175
+ console.log(chalk.gray(` Remaining: ${servers.length}`));
176
+ });
177
+
178
+ server
179
+ .command('set-primary <url>')
180
+ .description('set a discovery server as the primary')
181
+ .action((url) => {
182
+ try { requireSu(); } catch (e) { console.log(chalk.red(e.message)); return; }
183
+ const servers = setPrimaryServer(url);
184
+ console.log(chalk.green(`Primary set to: ${url}`));
185
+ console.log(chalk.gray(` Order: ${servers.join(', ')}`));
186
+ });
187
+ }