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,137 +1,137 @@
1
- import chalk from 'chalk';
2
- import readline from 'readline';
3
- import { getExtension, loadExtension, deployBundledExtensions, BUNDLED_DIR } from '../core/extensions.js';
4
- import path from 'path';
5
- import fs from 'fs';
6
-
7
- export default function authCommand(program) {
8
- const auth = program
9
- .command('auth')
10
- .description('manage account linking and identity verification');
11
-
12
- auth
13
- .command('login [email]')
14
- .description('login with email OTP to link your account')
15
- .action(async (email) => {
16
- // 1. Ensure extension is loaded
17
- let ext = getExtension('@palexplorer/auth-email');
18
- if (!ext) {
19
- console.log(chalk.blue('Loading auth-email extension...'));
20
- deployBundledExtensions();
21
- const appDir = path.dirname(new URL(import.meta.url).pathname.replace(/^\/([A-Z]:)/, '$1'));
22
- const extPath = path.resolve(appDir, '../../extensions/@palexplorer/auth-email');
23
- const manifest = JSON.parse(fs.readFileSync(path.join(extPath, 'extension.json'), 'utf8'));
24
- await loadExtension(extPath, { ...manifest, bundled: true });
25
- ext = getExtension('@palexplorer/auth-email');
26
- }
27
-
28
- if (!ext || !ext.ctx?.auth) {
29
- console.log(chalk.red('Error: auth-email extension not available.'));
30
- process.exitCode = 1;
31
- return;
32
- }
33
-
34
- const authExt = ext.ctx.auth;
35
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
36
- const ask = (q) => new Promise(r => rl.question(q, r));
37
-
38
- try {
39
- let targetEmail = email;
40
- if (!targetEmail) {
41
- targetEmail = await ask('Enter your email address: ');
42
- }
43
-
44
- if (!targetEmail || !targetEmail.includes('@')) {
45
- console.log(chalk.red('Invalid email address.'));
46
- rl.close();
47
- process.exitCode = 1;
48
- return;
49
- }
50
-
51
- console.log(chalk.blue(`Sending verification code to ${targetEmail}...`));
52
- await authExt.requestVerificationCode(targetEmail);
53
- console.log(chalk.green('✔ Code sent! Please check your inbox.'));
54
-
55
- const code = await ask('Enter the 6-digit code: ');
56
- if (!code || code.length !== 6) {
57
- console.log(chalk.red('Invalid code format.'));
58
- rl.close();
59
- process.exitCode = 1;
60
- return;
61
- }
62
-
63
- console.log(chalk.blue('Verifying...'));
64
- await authExt.confirmCode(targetEmail, code);
65
- console.log(chalk.green(`✔ Email ${targetEmail} verified successfully!`));
66
-
67
- console.log(chalk.blue('Linking your Palexplorer identity...'));
68
- await authExt.linkIdentity();
69
- console.log(chalk.green('✔ Identity linked! You now have a verified badge.'));
70
-
71
- rl.close();
72
- } catch (err) {
73
- rl.close();
74
- console.log(chalk.red(`Login failed: ${err.message}`));
75
- process.exitCode = 1;
76
- }
77
- });
78
-
79
- auth
80
- .command('google')
81
- .description('link your account using Google')
82
- .action(async () => {
83
- const { getIdentity } = await import('../core/identity.js');
84
- const { getPrimaryServer } = await import('../core/discoveryClient.js');
85
- const identity = await getIdentity();
86
- if (!identity?.publicKey) {
87
- console.log(chalk.red('No identity found. Run `pe init` first.'));
88
- process.exitCode = 1; return;
89
- }
90
- const baseUrl = getPrimaryServer();
91
- const returnUrl = encodeURIComponent('palexplorer://auth-callback');
92
- const url = `${baseUrl}/auth/google?publicKey=${encodeURIComponent(identity.publicKey)}&return_url=${returnUrl}`;
93
- console.log(chalk.blue('Opening browser for Google login...'));
94
- console.log(chalk.gray(`URL: ${url}`));
95
- const { default: open } = await import('open');
96
- await open(url);
97
- });
98
-
99
- auth
100
- .command('github')
101
- .description('link your account using GitHub')
102
- .action(async () => {
103
- const { getIdentity } = await import('../core/identity.js');
104
- const { getPrimaryServer } = await import('../core/discoveryClient.js');
105
- const identity = await getIdentity();
106
- if (!identity?.publicKey) {
107
- console.log(chalk.red('No identity found. Run `pe init` first.'));
108
- process.exitCode = 1; return;
109
- }
110
- const baseUrl = getPrimaryServer();
111
- const returnUrl = encodeURIComponent('palexplorer://auth-callback');
112
- const url = `${baseUrl}/auth/github?publicKey=${encodeURIComponent(identity.publicKey)}&return_url=${returnUrl}`;
113
- console.log(chalk.blue('Opening browser for GitHub login...'));
114
- console.log(chalk.gray(`URL: ${url}`));
115
- const { default: open } = await import('open');
116
- await open(url);
117
- });
118
-
119
- auth
120
- .command('status')
121
- .description('show current authentication status')
122
- .action(async () => {
123
- let ext = getExtension('@palexplorer/auth-email');
124
- if (!ext || !ext.ctx?.config) {
125
- console.log(chalk.gray('Authentication extension not loaded.'));
126
- return;
127
- }
128
-
129
- const verifiedEmail = ext.ctx.config.get('verifiedEmail');
130
- if (verifiedEmail) {
131
- console.log(chalk.green(`✔ Verified: ${verifiedEmail}`));
132
- console.log(chalk.gray(` Token: ${ext.ctx.config.get('verifiedToken').slice(0, 32)}...`));
133
- } else {
134
- console.log(chalk.yellow('! Not verified. Run `pe auth login` to link an email.'));
135
- }
136
- });
137
- }
1
+ import chalk from 'chalk';
2
+ import readline from 'readline';
3
+ import { getExtension, loadExtension, deployBundledExtensions, BUNDLED_DIR } from '../core/extensions.js';
4
+ import path from 'path';
5
+ import fs from 'fs';
6
+
7
+ export default function authCommand(program) {
8
+ const auth = program
9
+ .command('auth')
10
+ .description('manage account linking and identity verification');
11
+
12
+ auth
13
+ .command('login [email]')
14
+ .description('login with email OTP to link your account')
15
+ .action(async (email) => {
16
+ // 1. Ensure extension is loaded
17
+ let ext = getExtension('@palexplorer/auth-email');
18
+ if (!ext) {
19
+ console.log(chalk.blue('Loading auth-email extension...'));
20
+ deployBundledExtensions();
21
+ const appDir = path.dirname(new URL(import.meta.url).pathname.replace(/^\/([A-Z]:)/, '$1'));
22
+ const extPath = path.resolve(appDir, '../../extensions/@palexplorer/auth-email');
23
+ const manifest = JSON.parse(fs.readFileSync(path.join(extPath, 'extension.json'), 'utf8'));
24
+ await loadExtension(extPath, { ...manifest, bundled: true });
25
+ ext = getExtension('@palexplorer/auth-email');
26
+ }
27
+
28
+ if (!ext || !ext.ctx?.auth) {
29
+ console.log(chalk.red('Error: auth-email extension not available.'));
30
+ process.exitCode = 1;
31
+ return;
32
+ }
33
+
34
+ const authExt = ext.ctx.auth;
35
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
36
+ const ask = (q) => new Promise(r => rl.question(q, r));
37
+
38
+ try {
39
+ let targetEmail = email;
40
+ if (!targetEmail) {
41
+ targetEmail = await ask('Enter your email address: ');
42
+ }
43
+
44
+ if (!targetEmail || !targetEmail.includes('@')) {
45
+ console.log(chalk.red('Invalid email address.'));
46
+ rl.close();
47
+ process.exitCode = 1;
48
+ return;
49
+ }
50
+
51
+ console.log(chalk.blue(`Sending verification code to ${targetEmail}...`));
52
+ await authExt.requestVerificationCode(targetEmail);
53
+ console.log(chalk.green('✔ Code sent! Please check your inbox.'));
54
+
55
+ const code = await ask('Enter the 6-digit code: ');
56
+ if (!code || code.length !== 6) {
57
+ console.log(chalk.red('Invalid code format.'));
58
+ rl.close();
59
+ process.exitCode = 1;
60
+ return;
61
+ }
62
+
63
+ console.log(chalk.blue('Verifying...'));
64
+ await authExt.confirmCode(targetEmail, code);
65
+ console.log(chalk.green(`✔ Email ${targetEmail} verified successfully!`));
66
+
67
+ console.log(chalk.blue('Linking your Palexplorer identity...'));
68
+ await authExt.linkIdentity();
69
+ console.log(chalk.green('✔ Identity linked! You now have a verified badge.'));
70
+
71
+ rl.close();
72
+ } catch (err) {
73
+ rl.close();
74
+ console.log(chalk.red(`Login failed: ${err.message}`));
75
+ process.exitCode = 1;
76
+ }
77
+ });
78
+
79
+ auth
80
+ .command('google')
81
+ .description('link your account using Google')
82
+ .action(async () => {
83
+ const { getIdentity } = await import('../core/identity.js');
84
+ const { getPrimaryServer } = await import('../core/discoveryClient.js');
85
+ const identity = await getIdentity();
86
+ if (!identity?.publicKey) {
87
+ console.log(chalk.red('No identity found. Run `pal init` first.'));
88
+ process.exitCode = 1; return;
89
+ }
90
+ const baseUrl = getPrimaryServer();
91
+ const returnUrl = encodeURIComponent('palexplorer://auth-callback');
92
+ const url = `${baseUrl}/auth/google?publicKey=${encodeURIComponent(identity.publicKey)}&return_url=${returnUrl}`;
93
+ console.log(chalk.blue('Opening browser for Google login...'));
94
+ console.log(chalk.gray(`URL: ${url}`));
95
+ const { default: open } = await import('open');
96
+ await open(url);
97
+ });
98
+
99
+ auth
100
+ .command('github')
101
+ .description('link your account using GitHub')
102
+ .action(async () => {
103
+ const { getIdentity } = await import('../core/identity.js');
104
+ const { getPrimaryServer } = await import('../core/discoveryClient.js');
105
+ const identity = await getIdentity();
106
+ if (!identity?.publicKey) {
107
+ console.log(chalk.red('No identity found. Run `pal init` first.'));
108
+ process.exitCode = 1; return;
109
+ }
110
+ const baseUrl = getPrimaryServer();
111
+ const returnUrl = encodeURIComponent('palexplorer://auth-callback');
112
+ const url = `${baseUrl}/auth/github?publicKey=${encodeURIComponent(identity.publicKey)}&return_url=${returnUrl}`;
113
+ console.log(chalk.blue('Opening browser for GitHub login...'));
114
+ console.log(chalk.gray(`URL: ${url}`));
115
+ const { default: open } = await import('open');
116
+ await open(url);
117
+ });
118
+
119
+ auth
120
+ .command('status')
121
+ .description('show current authentication status')
122
+ .action(async () => {
123
+ let ext = getExtension('@palexplorer/auth-email');
124
+ if (!ext || !ext.ctx?.config) {
125
+ console.log(chalk.gray('Authentication extension not loaded.'));
126
+ return;
127
+ }
128
+
129
+ const verifiedEmail = ext.ctx.config.get('verifiedEmail');
130
+ if (verifiedEmail) {
131
+ console.log(chalk.green(`✔ Verified: ${verifiedEmail}`));
132
+ console.log(chalk.gray(` Token: ${ext.ctx.config.get('verifiedToken').slice(0, 32)}...`));
133
+ } else {
134
+ console.log(chalk.yellow('! Not verified. Run `pal auth login` to link an email.'));
135
+ }
136
+ });
137
+ }
@@ -1,76 +1,76 @@
1
- import chalk from 'chalk';
2
- import fs from 'fs';
3
- import path from 'path';
4
- import { createBackup, restoreBackup } from '../core/backup.js';
5
-
6
- export default function backupCommand(program) {
7
- const cmd = program
8
- .command('backup')
9
- .description('create and restore encrypted backups (Pro)')
10
- .addHelpText('after', `
11
- Examples:
12
- $ pe backup create Create backup (prompted for password)
13
- $ pe backup create --password "s3cret" Create with password
14
- $ pe backup create -o ~/backup.json Custom output path
15
- $ pe backup restore ./palexplorer-backup.json
16
- `)
17
- .action(() => {
18
- cmd.outputHelp();
19
- });
20
-
21
- cmd
22
- .command('create')
23
- .description('create an encrypted backup of identity, shares, pals, and settings')
24
- .option('-o, --output <path>', 'Output file path')
25
- .option('-p, --password <password>', 'Encryption password')
26
- .action(async (opts) => {
27
- try {
28
- const password = opts.password || process.env.PE_BACKUP_PASSWORD;
29
- if (!password) {
30
- console.log(chalk.red('Password required. Use --password or PE_BACKUP_PASSWORD env var.'));
31
- process.exitCode = 1;
32
- return;
33
- }
34
-
35
- const backupData = await createBackup(password);
36
- const outPath = opts.output || `palexplorer-backup-${new Date().toISOString().slice(0, 10)}.json`;
37
- const resolved = path.resolve(outPath);
38
- fs.writeFileSync(resolved, backupData, 'utf8');
39
- console.log(chalk.green(`✔ Backup created: ${resolved}`));
40
- } catch (err) {
41
- console.log(chalk.red(`Backup failed: ${err.message}`));
42
- process.exitCode = 1;
43
- }
44
- });
45
-
46
- cmd
47
- .command('restore <file>')
48
- .description('restore from an encrypted backup file')
49
- .option('-p, --password <password>', 'Decryption password')
50
- .action(async (file, opts) => {
51
- try {
52
- const resolved = path.resolve(file);
53
- if (!fs.existsSync(resolved)) {
54
- console.log(chalk.red(`File not found: ${resolved}`));
55
- process.exitCode = 1;
56
- return;
57
- }
58
-
59
- const password = opts.password || process.env.PE_BACKUP_PASSWORD;
60
- if (!password) {
61
- console.log(chalk.red('Password required. Use --password or PE_BACKUP_PASSWORD env var.'));
62
- process.exitCode = 1;
63
- return;
64
- }
65
-
66
- const data = fs.readFileSync(resolved, 'utf8');
67
- const result = await restoreBackup(data, password);
68
- console.log(chalk.green('✔ Backup restored successfully.'));
69
- if (result.sharesRestored) console.log(` Shares: ${chalk.white(result.sharesRestored)}`);
70
- if (result.palsRestored) console.log(` Pals: ${chalk.white(result.palsRestored)}`);
71
- } catch (err) {
72
- console.log(chalk.red(`Restore failed: ${err.message}`));
73
- process.exitCode = 1;
74
- }
75
- });
76
- }
1
+ import chalk from 'chalk';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import { createBackup, restoreBackup } from '../core/backup.js';
5
+
6
+ export default function backupCommand(program) {
7
+ const cmd = program
8
+ .command('backup')
9
+ .description('create and restore encrypted backups (Pro)')
10
+ .addHelpText('after', `
11
+ Examples:
12
+ $ pal backup create Create backup (prompted for password)
13
+ $ pal backup create --password "s3cret" Create with password
14
+ $ pal backup create -o ~/backup.json Custom output path
15
+ $ pal backup restore ./palexplorer-backup.json
16
+ `)
17
+ .action(() => {
18
+ cmd.outputHelp();
19
+ });
20
+
21
+ cmd
22
+ .command('create')
23
+ .description('create an encrypted backup of identity, shares, pals, and settings')
24
+ .option('-o, --output <path>', 'Output file path')
25
+ .option('-p, --password <password>', 'Encryption password')
26
+ .action(async (opts) => {
27
+ try {
28
+ const password = opts.password || process.env.PAL_BACKUP_PASSWORD;
29
+ if (!password) {
30
+ console.log(chalk.red('Password required. Use --password or PAL_BACKUP_PASSWORD env var.'));
31
+ process.exitCode = 1;
32
+ return;
33
+ }
34
+
35
+ const backupData = await createBackup(password);
36
+ const outPath = opts.output || `palexplorer-backup-${new Date().toISOString().slice(0, 10)}.json`;
37
+ const resolved = path.resolve(outPath);
38
+ fs.writeFileSync(resolved, backupData, 'utf8');
39
+ console.log(chalk.green(`✔ Backup created: ${resolved}`));
40
+ } catch (err) {
41
+ console.log(chalk.red(`Backup failed: ${err.message}`));
42
+ process.exitCode = 1;
43
+ }
44
+ });
45
+
46
+ cmd
47
+ .command('restore <file>')
48
+ .description('restore from an encrypted backup file')
49
+ .option('-p, --password <password>', 'Decryption password')
50
+ .action(async (file, opts) => {
51
+ try {
52
+ const resolved = path.resolve(file);
53
+ if (!fs.existsSync(resolved)) {
54
+ console.log(chalk.red(`File not found: ${resolved}`));
55
+ process.exitCode = 1;
56
+ return;
57
+ }
58
+
59
+ const password = opts.password || process.env.PAL_BACKUP_PASSWORD;
60
+ if (!password) {
61
+ console.log(chalk.red('Password required. Use --password or PAL_BACKUP_PASSWORD env var.'));
62
+ process.exitCode = 1;
63
+ return;
64
+ }
65
+
66
+ const data = fs.readFileSync(resolved, 'utf8');
67
+ const result = await restoreBackup(data, password);
68
+ console.log(chalk.green('✔ Backup restored successfully.'));
69
+ if (result.sharesRestored) console.log(` Shares: ${chalk.white(result.sharesRestored)}`);
70
+ if (result.palsRestored) console.log(` Pals: ${chalk.white(result.palsRestored)}`);
71
+ } catch (err) {
72
+ console.log(chalk.red(`Restore failed: ${err.message}`));
73
+ process.exitCode = 1;
74
+ }
75
+ });
76
+ }