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,200 +1,200 @@
1
- import chalk from 'chalk';
2
-
3
- export default function ssoCommand(program) {
4
- const cmd = program
5
- .command('sso')
6
- .description('manage enterprise SSO (SAML/OIDC)')
7
- .addHelpText('after', `
8
- Examples:
9
- $ pe sso configure --provider oidc --issuer https://auth.example.com --client-id abc --client-secret xyz
10
- $ pe sso configure --provider saml --issuer https://idp.example.com/metadata
11
- $ pe sso login Initiate SSO login
12
- $ pe sso status Show current SSO configuration
13
- $ pe sso enforce --on Enforce mandatory SSO
14
- $ pe sso enforce --off Disable mandatory SSO
15
- `)
16
- .action(() => {
17
- cmd.outputHelp();
18
- });
19
-
20
- cmd
21
- .command('configure')
22
- .description('configure SSO provider (SAML or OIDC)')
23
- .requiredOption('--provider <type>', 'SSO provider type (saml or oidc)')
24
- .option('--issuer <url>', 'IdP issuer URL')
25
- .option('--client-id <id>', 'OIDC client ID')
26
- .option('--client-secret <secret>', 'OIDC client secret')
27
- .action(async (opts) => {
28
- try {
29
- const provider = opts.provider.toLowerCase();
30
- if (provider !== 'saml' && provider !== 'oidc') {
31
- console.log(chalk.red('Provider must be "saml" or "oidc".'));
32
- process.exitCode = 1;
33
- return;
34
- }
35
-
36
- if (provider === 'oidc' && (!opts.clientId || !opts.clientSecret)) {
37
- console.log(chalk.red('OIDC requires --client-id and --client-secret.'));
38
- process.exitCode = 1;
39
- return;
40
- }
41
-
42
- if (!opts.issuer) {
43
- console.log(chalk.red('--issuer is required.'));
44
- process.exitCode = 1;
45
- return;
46
- }
47
-
48
- const extConfig = (await import('../utils/config.js')).default;
49
- const existing = extConfig.get('ext.sso-connector') || {};
50
-
51
- const clientSecret = opts.clientSecret || existing.clientSecret || null;
52
- const ssoConfig = {
53
- ...existing,
54
- provider,
55
- issuer: opts.issuer,
56
- clientId: opts.clientId || existing.clientId || null,
57
- clientSecret: null,
58
- };
59
-
60
- if (clientSecret) {
61
- try {
62
- const keytar = (await import('keytar')).default;
63
- await keytar.setPassword('palexplorer', 'sso.clientSecret', clientSecret);
64
- } catch {
65
- ssoConfig.clientSecret = clientSecret;
66
- }
67
- }
68
-
69
- extConfig.set('ext.sso-connector', ssoConfig);
70
-
71
- console.log(chalk.green(`✔ SSO configured`));
72
- console.log(` Provider: ${chalk.white(provider.toUpperCase())}`);
73
- console.log(` Issuer: ${chalk.white(opts.issuer)}`);
74
- if (provider === 'oidc') {
75
- console.log(` Client: ${chalk.white(opts.clientId)}`);
76
- }
77
- } catch (err) {
78
- console.log(chalk.red(`Failed to configure SSO: ${err.message}`));
79
- process.exitCode = 1;
80
- }
81
- });
82
-
83
- cmd
84
- .command('login')
85
- .description('initiate SSO login')
86
- .action(async () => {
87
- try {
88
- const extConfig = (await import('../utils/config.js')).default;
89
- const cfg = extConfig.get('ext.sso-connector');
90
-
91
- if (!cfg || !cfg.provider) {
92
- console.log(chalk.red('SSO not configured. Run: pe sso configure'));
93
- process.exitCode = 1;
94
- return;
95
- }
96
-
97
- let redirectUrl;
98
- if (cfg.provider === 'oidc') {
99
- let clientId = cfg.clientId;
100
- let clientSecret = cfg.clientSecret;
101
- if (!clientSecret) {
102
- try {
103
- const keytar = (await import('keytar')).default;
104
- clientSecret = await keytar.getPassword('palexplorer', 'sso.clientSecret');
105
- } catch {}
106
- }
107
- const state = Math.random().toString(36).slice(2);
108
- const params = new URLSearchParams({
109
- response_type: 'code',
110
- client_id: clientId,
111
- redirect_uri: 'http://localhost:9876/callback',
112
- scope: 'openid profile email',
113
- state,
114
- });
115
- redirectUrl = `${cfg.issuer}/authorize?${params}`;
116
- } else {
117
- redirectUrl = `${cfg.issuer}/sso/saml?RelayState=palexplorer`;
118
- }
119
-
120
- console.log('');
121
- console.log(chalk.cyan('SSO Login'));
122
- console.log(` Provider: ${chalk.white(cfg.provider.toUpperCase())}`);
123
- console.log(` Redirect: ${chalk.white(redirectUrl)}`);
124
- console.log('');
125
- console.log(chalk.gray('Open the URL above in your browser to authenticate.'));
126
- } catch (err) {
127
- console.log(chalk.red(`SSO login failed: ${err.message}`));
128
- process.exitCode = 1;
129
- }
130
- });
131
-
132
- cmd
133
- .command('status')
134
- .description('show current SSO configuration')
135
- .action(async () => {
136
- try {
137
- const extConfig = (await import('../utils/config.js')).default;
138
- const cfg = extConfig.get('ext.sso-connector');
139
-
140
- console.log('');
141
- console.log(chalk.cyan.bold('SSO Configuration'));
142
-
143
- if (!cfg || !cfg.provider) {
144
- console.log(chalk.gray(' Not configured. Run: pe sso configure'));
145
- console.log('');
146
- return;
147
- }
148
-
149
- console.log(` Provider: ${chalk.white(cfg.provider.toUpperCase())}`);
150
- console.log(` Issuer: ${chalk.white(cfg.issuer || 'not set')}`);
151
- if (cfg.provider === 'oidc') {
152
- console.log(` Client ID: ${chalk.white(cfg.clientId || 'not set')}`);
153
- console.log(` Client Secret: ${cfg.clientSecret ? chalk.gray('********') : chalk.yellow('not set')}`);
154
- }
155
- console.log(` Enforce SSO: ${cfg.enforceSSO ? chalk.green('yes') : chalk.gray('no')}`);
156
- console.log('');
157
- } catch (err) {
158
- console.log(chalk.red(`Failed to get SSO status: ${err.message}`));
159
- process.exitCode = 1;
160
- }
161
- });
162
-
163
- cmd
164
- .command('enforce')
165
- .description('enable or disable mandatory SSO')
166
- .option('--on', 'Enable mandatory SSO')
167
- .option('--off', 'Disable mandatory SSO')
168
- .action(async (opts) => {
169
- try {
170
- if (!opts.on && !opts.off) {
171
- console.log(chalk.red('Specify --on or --off.'));
172
- process.exitCode = 1;
173
- return;
174
- }
175
-
176
- const extConfig = (await import('../utils/config.js')).default;
177
- const cfg = extConfig.get('ext.sso-connector');
178
-
179
- if (!cfg || !cfg.provider) {
180
- console.log(chalk.red('SSO not configured. Run: pe sso configure'));
181
- process.exitCode = 1;
182
- return;
183
- }
184
-
185
- const enforce = !!opts.on;
186
- extConfig.set('ext.sso-connector', { ...cfg, enforceSSO: enforce });
187
-
188
- if (enforce) {
189
- console.log(chalk.green('✔ Mandatory SSO enabled'));
190
- console.log(chalk.gray(' All users must authenticate via SSO.'));
191
- } else {
192
- console.log(chalk.green('✔ Mandatory SSO disabled'));
193
- console.log(chalk.gray(' Users can authenticate with local credentials.'));
194
- }
195
- } catch (err) {
196
- console.log(chalk.red(`Failed to update enforcement: ${err.message}`));
197
- process.exitCode = 1;
198
- }
199
- });
200
- }
1
+ import chalk from 'chalk';
2
+
3
+ export default function ssoCommand(program) {
4
+ const cmd = program
5
+ .command('sso')
6
+ .description('manage enterprise SSO (SAML/OIDC)')
7
+ .addHelpText('after', `
8
+ Examples:
9
+ $ pal sso configure --provider oidc --issuer https://auth.example.com --client-id abc --client-secret xyz
10
+ $ pal sso configure --provider saml --issuer https://idp.example.com/metadata
11
+ $ pal sso login Initiate SSO login
12
+ $ pal sso status Show current SSO configuration
13
+ $ pal sso enforce --on Enforce mandatory SSO
14
+ $ pal sso enforce --off Disable mandatory SSO
15
+ `)
16
+ .action(() => {
17
+ cmd.outputHelp();
18
+ });
19
+
20
+ cmd
21
+ .command('configure')
22
+ .description('configure SSO provider (SAML or OIDC)')
23
+ .requiredOption('--provider <type>', 'SSO provider type (saml or oidc)')
24
+ .option('--issuer <url>', 'IdP issuer URL')
25
+ .option('--client-id <id>', 'OIDC client ID')
26
+ .option('--client-secret <secret>', 'OIDC client secret')
27
+ .action(async (opts) => {
28
+ try {
29
+ const provider = opts.provider.toLowerCase();
30
+ if (provider !== 'saml' && provider !== 'oidc') {
31
+ console.log(chalk.red('Provider must be "saml" or "oidc".'));
32
+ process.exitCode = 1;
33
+ return;
34
+ }
35
+
36
+ if (provider === 'oidc' && (!opts.clientId || !opts.clientSecret)) {
37
+ console.log(chalk.red('OIDC requires --client-id and --client-secret.'));
38
+ process.exitCode = 1;
39
+ return;
40
+ }
41
+
42
+ if (!opts.issuer) {
43
+ console.log(chalk.red('--issuer is required.'));
44
+ process.exitCode = 1;
45
+ return;
46
+ }
47
+
48
+ const extConfig = (await import('../utils/config.js')).default;
49
+ const existing = extConfig.get('ext.sso-connector') || {};
50
+
51
+ const clientSecret = opts.clientSecret || existing.clientSecret || null;
52
+ const ssoConfig = {
53
+ ...existing,
54
+ provider,
55
+ issuer: opts.issuer,
56
+ clientId: opts.clientId || existing.clientId || null,
57
+ clientSecret: null,
58
+ };
59
+
60
+ if (clientSecret) {
61
+ try {
62
+ const keytar = (await import('keytar')).default;
63
+ await keytar.setPassword('palexplorer', 'sso.clientSecret', clientSecret);
64
+ } catch {
65
+ ssoConfig.clientSecret = clientSecret;
66
+ }
67
+ }
68
+
69
+ extConfig.set('ext.sso-connector', ssoConfig);
70
+
71
+ console.log(chalk.green(`✔ SSO configured`));
72
+ console.log(` Provider: ${chalk.white(provider.toUpperCase())}`);
73
+ console.log(` Issuer: ${chalk.white(opts.issuer)}`);
74
+ if (provider === 'oidc') {
75
+ console.log(` Client: ${chalk.white(opts.clientId)}`);
76
+ }
77
+ } catch (err) {
78
+ console.log(chalk.red(`Failed to configure SSO: ${err.message}`));
79
+ process.exitCode = 1;
80
+ }
81
+ });
82
+
83
+ cmd
84
+ .command('login')
85
+ .description('initiate SSO login')
86
+ .action(async () => {
87
+ try {
88
+ const extConfig = (await import('../utils/config.js')).default;
89
+ const cfg = extConfig.get('ext.sso-connector');
90
+
91
+ if (!cfg || !cfg.provider) {
92
+ console.log(chalk.red('SSO not configured. Run: pal sso configure'));
93
+ process.exitCode = 1;
94
+ return;
95
+ }
96
+
97
+ let redirectUrl;
98
+ if (cfg.provider === 'oidc') {
99
+ let clientId = cfg.clientId;
100
+ let clientSecret = cfg.clientSecret;
101
+ if (!clientSecret) {
102
+ try {
103
+ const keytar = (await import('keytar')).default;
104
+ clientSecret = await keytar.getPassword('palexplorer', 'sso.clientSecret');
105
+ } catch {}
106
+ }
107
+ const state = Math.random().toString(36).slice(2);
108
+ const params = new URLSearchParams({
109
+ response_type: 'code',
110
+ client_id: clientId,
111
+ redirect_uri: 'http://localhost:9876/callback',
112
+ scope: 'openid profile email',
113
+ state,
114
+ });
115
+ redirectUrl = `${cfg.issuer}/authorize?${params}`;
116
+ } else {
117
+ redirectUrl = `${cfg.issuer}/sso/saml?RelayState=palexplorer`;
118
+ }
119
+
120
+ console.log('');
121
+ console.log(chalk.cyan('SSO Login'));
122
+ console.log(` Provider: ${chalk.white(cfg.provider.toUpperCase())}`);
123
+ console.log(` Redirect: ${chalk.white(redirectUrl)}`);
124
+ console.log('');
125
+ console.log(chalk.gray('Open the URL above in your browser to authenticate.'));
126
+ } catch (err) {
127
+ console.log(chalk.red(`SSO login failed: ${err.message}`));
128
+ process.exitCode = 1;
129
+ }
130
+ });
131
+
132
+ cmd
133
+ .command('status')
134
+ .description('show current SSO configuration')
135
+ .action(async () => {
136
+ try {
137
+ const extConfig = (await import('../utils/config.js')).default;
138
+ const cfg = extConfig.get('ext.sso-connector');
139
+
140
+ console.log('');
141
+ console.log(chalk.cyan.bold('SSO Configuration'));
142
+
143
+ if (!cfg || !cfg.provider) {
144
+ console.log(chalk.gray(' Not configured. Run: pal sso configure'));
145
+ console.log('');
146
+ return;
147
+ }
148
+
149
+ console.log(` Provider: ${chalk.white(cfg.provider.toUpperCase())}`);
150
+ console.log(` Issuer: ${chalk.white(cfg.issuer || 'not set')}`);
151
+ if (cfg.provider === 'oidc') {
152
+ console.log(` Client ID: ${chalk.white(cfg.clientId || 'not set')}`);
153
+ console.log(` Client Secret: ${cfg.clientSecret ? chalk.gray('********') : chalk.yellow('not set')}`);
154
+ }
155
+ console.log(` Enforce SSO: ${cfg.enforceSSO ? chalk.green('yes') : chalk.gray('no')}`);
156
+ console.log('');
157
+ } catch (err) {
158
+ console.log(chalk.red(`Failed to get SSO status: ${err.message}`));
159
+ process.exitCode = 1;
160
+ }
161
+ });
162
+
163
+ cmd
164
+ .command('enforce')
165
+ .description('enable or disable mandatory SSO')
166
+ .option('--on', 'Enable mandatory SSO')
167
+ .option('--off', 'Disable mandatory SSO')
168
+ .action(async (opts) => {
169
+ try {
170
+ if (!opts.on && !opts.off) {
171
+ console.log(chalk.red('Specify --on or --off.'));
172
+ process.exitCode = 1;
173
+ return;
174
+ }
175
+
176
+ const extConfig = (await import('../utils/config.js')).default;
177
+ const cfg = extConfig.get('ext.sso-connector');
178
+
179
+ if (!cfg || !cfg.provider) {
180
+ console.log(chalk.red('SSO not configured. Run: pal sso configure'));
181
+ process.exitCode = 1;
182
+ return;
183
+ }
184
+
185
+ const enforce = !!opts.on;
186
+ extConfig.set('ext.sso-connector', { ...cfg, enforceSSO: enforce });
187
+
188
+ if (enforce) {
189
+ console.log(chalk.green('✔ Mandatory SSO enabled'));
190
+ console.log(chalk.gray(' All users must authenticate via SSO.'));
191
+ } else {
192
+ console.log(chalk.green('✔ Mandatory SSO disabled'));
193
+ console.log(chalk.gray(' Users can authenticate with local credentials.'));
194
+ }
195
+ } catch (err) {
196
+ console.log(chalk.red(`Failed to update enforcement: ${err.message}`));
197
+ process.exitCode = 1;
198
+ }
199
+ });
200
+ }