cloudron 7.1.0 → 7.1.2

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/bin/cloudron CHANGED
@@ -418,7 +418,8 @@ versionsCommand.command('list')
418
418
  .action(versionsActions.list);
419
419
 
420
420
  versionsCommand.command('revoke')
421
- .description('Revoke the latest version')
421
+ .description('Revoke a version')
422
+ .option('--version <version>', 'Version to revoke (defaults to latest)')
422
423
  .action(versionsActions.revoke);
423
424
 
424
425
  versionsCommand.command('update')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudron",
3
- "version": "7.1.0",
3
+ "version": "7.1.2",
4
4
  "license": "MIT",
5
5
  "description": "Cloudron Commandline Tool",
6
6
  "type": "module",
package/src/actions.js CHANGED
@@ -31,7 +31,7 @@ function requestOptions(options) {
31
31
  // ensure config can return the correct section
32
32
  config.setActive(adminFqdn);
33
33
 
34
- const token = options.token || config.token();
34
+ const token = options.token || process.env.CLOUDRON_CLI_AUTH_TOKEN || config.token();
35
35
  const rejectUnauthorized = !(options.allowSelfsigned || options.acceptSelfsigned || config.allowSelfsigned());
36
36
 
37
37
  if (!adminFqdn && !token) return exit('Login with "cloudron login" first'); // a bit rough to put this here!
package/src/helper.js CHANGED
@@ -3,6 +3,7 @@ import fs from 'fs';
3
3
  import http from 'http';
4
4
  import open from 'open';
5
5
  import path from 'path';
6
+ import readline from 'readline';
6
7
  import safe from '@cloudron/safetydance';
7
8
  import superagent from '@cloudron/superagent';
8
9
  import util from 'util';
@@ -128,15 +129,22 @@ async function performOidcLogin(adminFqdn, { rejectUnauthorized = true } = {}) {
128
129
  }
129
130
 
130
131
  const receivedCode = url.searchParams.get('code');
132
+ const successHtml = fs.readFileSync(path.join(import.meta.dirname, 'login-success.html'), 'utf8');
131
133
  res.writeHead(200, { 'Content-Type': 'text/html' });
132
- res.end('<html><body><h1>Login successful!</h1><p>You can close this window and return to the terminal.</p></body></html>');
134
+ res.end(successHtml);
133
135
  server.close();
134
136
  resolve(receivedCode);
135
137
  });
136
138
 
137
- server.listen(1312, () => {
138
- console.log('Opening browser for authentication...');
139
- open(authUrl.toString());
139
+ // without the host ip, it will listen on :: . on mac, which has dual stack disabled, it will listen on ipv6 only
140
+ server.listen(1312, '127.0.0.1', () => {
141
+ // console.log('Login at:');
142
+ // console.log(authUrl.toString());
143
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
144
+ rl.question('Press ENTER to authenticate using the browser...', () => {
145
+ rl.close();
146
+ open(authUrl.toString());
147
+ });
140
148
  });
141
149
 
142
150
  server.on('error', (err) => {
@@ -0,0 +1,61 @@
1
+ <html>
2
+ <head>
3
+ <meta charset="utf-8">
4
+ <meta name="viewport" content="width=device-width, initial-scale=1">
5
+ <title>Authentication successful</title>
6
+ <style>
7
+ * { margin: 0; padding: 0; box-sizing: border-box; }
8
+ body {
9
+ font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
10
+ min-height: 100vh;
11
+ display: flex;
12
+ align-items: center;
13
+ justify-content: center;
14
+ background: #f3f4f6;
15
+ color: #333;
16
+ }
17
+ .card {
18
+ text-align: center;
19
+ background: #fff;
20
+ border-radius: 4px;
21
+ padding: 48px 40px;
22
+ box-shadow: 0 2px 5px rgba(0,0,0,.1);
23
+ }
24
+ .icon {
25
+ width: 64px; height: 64px;
26
+ margin: 0 auto 24px;
27
+ background: #1a76bf21;
28
+ border-radius: 50%;
29
+ display: flex;
30
+ align-items: center;
31
+ justify-content: center;
32
+ }
33
+ .icon svg { width: 32px; height: 32px; color: #1a76bf; }
34
+ h1 { font-size: 22px; font-weight: 600; margin-bottom: 8px; }
35
+ p { font-size: 15px; color: #666; line-height: 1.5; }
36
+ @media (prefers-color-scheme: dark) {
37
+ body {
38
+ background-color: black;
39
+ color: white;
40
+ }
41
+ .card {
42
+ background: #15181f;
43
+ }
44
+ p {
45
+ color: #aaa;
46
+ }
47
+ }
48
+ </style>
49
+ </head>
50
+ <body>
51
+ <div class="card">
52
+ <div class="icon">
53
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
54
+ <polyline points="20 6 9 17 4 12"/>
55
+ </svg>
56
+ </div>
57
+ <h1>Authentication successful</h1>
58
+ <p>You can close this tab and return to your command line.</p>
59
+ </div>
60
+ </body>
61
+ </html>
@@ -252,21 +252,30 @@ async function list(/*localOptions, cmd*/) {
252
252
  console.log(t.toString());
253
253
  }
254
254
 
255
- async function revoke() {
255
+ async function revoke(localOptions, cmd) {
256
256
  const versionsFilePath = await locateVersions();
257
257
  if (!versionsFilePath) return exit(NO_VERSIONS_FOUND_ERROR_STRING);
258
258
 
259
+ const options = cmd.optsWithGlobals();
259
260
  const versionsRoot = await readVersions(versionsFilePath);
260
261
  const versions = versionsRoot.versions;
261
- const sortedVersions = Object.keys(versions).sort(manifestFormat.packageVersionCompare);
262
- const latestVersion = sortedVersions.at(-1);
263
- if (versions[latestVersion].publishState !== PUBLISH_STATE_PUBLISHED) {
264
- return exit(`Only versions in "${PUBLISH_STATE_PUBLISHED}" can be revoked. ${latestVersion} is currently marked as "${versions[latestVersion].publishState}"`);
262
+
263
+ let targetVersion;
264
+ if (options.version) {
265
+ if (!(options.version in versions)) exit(`${options.version} does not exist in ${path.relative(process.cwd(), versionsFilePath)}.`);
266
+ targetVersion = options.version;
267
+ } else {
268
+ const sortedVersions = Object.keys(versions).sort(manifestFormat.packageVersionCompare);
269
+ targetVersion = sortedVersions.at(-1);
270
+ }
271
+
272
+ if (versions[targetVersion].publishState !== PUBLISH_STATE_PUBLISHED) {
273
+ return exit(`Only versions in "${PUBLISH_STATE_PUBLISHED}" can be revoked. ${targetVersion} is currently marked as "${versions[targetVersion].publishState}"`);
265
274
  }
266
275
 
267
- versions[latestVersion].publishState = PUBLISH_STATE_REVOKED;
276
+ versions[targetVersion].publishState = PUBLISH_STATE_REVOKED;
268
277
  await writeVersions(versionsFilePath, versionsRoot);
269
- console.log(`Marked ${latestVersion} as revoked in ${path.relative(process.cwd(), versionsFilePath)}`);
278
+ console.log(`Marked ${targetVersion} as revoked in ${path.relative(process.cwd(), versionsFilePath)}`);
270
279
  }
271
280
 
272
281
  export default {