@rome-os/node 0.1.1 → 0.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/README.md CHANGED
@@ -23,6 +23,16 @@ Open the printed authorization URL in a browser on that computer and approve it.
23
23
  The browser callback uses a temporary loopback listener. A remote browser needs
24
24
  a tunnel to that listener. Ctrl+C disconnects and preserves the credential.
25
25
 
26
+ Over SSH or on a headless computer, use device authorization:
27
+
28
+ ```sh
29
+ rome-node connect --device-code --name "Remote Linux" --cloud https://romeos.cc
30
+ ```
31
+
32
+ Open the printed URL on another device and approve the displayed user code.
33
+ The CLI prints the expiry and waits for approval without a callback listener or SSH tunnel.
34
+ Ctrl+C cancels the authorization. Both modes reuse stored credentials when valid.
35
+
26
36
  Rome instances prepare caller authorization automatically at startup and after
27
37
  Cloud enrollment. In a server environment that supplies `ROME_INSTANCE_TOKEN`, run:
28
38
 
package/dist/entry.js CHANGED
@@ -31,6 +31,7 @@ async function main() {
31
31
  name: { type: "string" },
32
32
  args: { type: "string" },
33
33
  server: { type: "boolean" },
34
+ "device-code": { type: "boolean" },
34
35
  },
35
36
  });
36
37
  if (values.help || positionals.length === 0 || positionals[0] === "help") {
@@ -41,6 +42,8 @@ async function main() {
41
42
  const config = nodeConfigFromEnvironment(process.env);
42
43
  if (values.server && !(positionals[0] === "auth" && positionals.length === 1))
43
44
  throw new Error("--server is only supported by rome-node auth.");
45
+ if (values["device-code"] && !(positionals[0] === "connect" && positionals.length === 1))
46
+ throw new Error("--device-code is only supported by rome-node connect.");
44
47
  if (positionals[0] === "auth" && positionals[1] === "status" && positionals.length === 2) {
45
48
  const credential = await readOptionalCallerCredential(config);
46
49
  process.stdout.write(`${JSON.stringify(credential ? { configured: true, cloudUrl: credential.cloudUrl } : { configured: false })}\n`);
@@ -119,16 +122,23 @@ async function main() {
119
122
  return;
120
123
  }
121
124
  if (positionals[0] === "connect" && positionals.length === 1) {
122
- const { connectHost, defaultDeviceName, loginDevice, createFileCredentialStore } = await import("@rome-os/node-core/host");
125
+ const { connectHost, defaultDeviceName, loginDevice, loginDeviceCode, createFileCredentialStore, } = await import("@rome-os/node-core/host");
123
126
  const name = values.name ?? defaultDeviceName();
124
127
  await withShutdown((signal) => connectHost({
125
128
  cloudUrl: values.cloud ?? "https://romeos.cc",
126
129
  name,
127
130
  signal,
128
131
  credentials: createFileCredentialStore(join(config.directory, "credential.json")),
129
- authorize: (origin, deviceName, abort) => loginDevice(origin, deviceName, abort, (url) => {
130
- process.stderr.write(`Open this URL in your browser to authorize ${deviceName}:\n${url}\n`);
131
- }),
132
+ authorize: (origin, deviceName, abort) => values["device-code"]
133
+ ? loginDeviceCode(origin, deviceName, abort, (prompt) => {
134
+ process.stderr.write(`Open this URL in a browser on another device:\n${prompt.verificationUri}\n` +
135
+ `User code: ${prompt.userCode}\n` +
136
+ `Or open: ${prompt.verificationUriComplete}\n` +
137
+ `Expires in ${prompt.expiresIn} seconds. Waiting for approval. Ctrl+C cancels.\n`);
138
+ })
139
+ : loginDevice(origin, deviceName, abort, (url) => {
140
+ process.stderr.write(`Open this URL in your browser to authorize ${deviceName}:\n${url}\n`);
141
+ }),
132
142
  onEvent: (event) => {
133
143
  if (event.type === "authorization_required")
134
144
  process.stderr.write("While connect is running, Rome instances in your account can execute programs and read or change files as your OS user.\n");
package/dist/help.js CHANGED
@@ -38,19 +38,25 @@ A watcher does not restart an explicitly stopped daemon. Another command can sta
38
38
  Ctrl+C exits the watcher without stopping the daemon or remote operations.
39
39
  These events do not indicate whether individual remote devices are online.
40
40
  `,
41
- connect: `Usage: rome-node connect [--cloud <origin>] [--name <name>]
41
+ connect: `Usage: rome-node connect [--device-code] [--cloud <origin>] [--name <name>]
42
42
 
43
43
  Run this on the computer that will execute programs.
44
44
  Open the printed browser URL and approve access when authorization is needed.
45
+ By default, the browser returns to a loopback listener on this computer.
46
+ Use --device-code over SSH or on a headless computer to approve from another device.
47
+ This mode prints a URL and user code without opening a browser or callback listener.
48
+ Stored credentials are reused in either mode. SSH is not detected automatically.
45
49
  The process stays in the foreground. Ctrl+C disconnects and preserves authorization.
46
50
  Programs run as the OS user who starts connect.
47
51
 
48
52
  Options:
49
53
  --cloud <origin> Cloud origin (default: https://romeos.cc).
50
54
  --name <name> Name for browser authorization (default: computer hostname).
55
+ --device-code Authorize from another device without a callback or SSH tunnel.
51
56
 
52
57
  Example:
53
58
  rome-node connect --name "My computer"
59
+ rome-node connect --device-code --name "Remote Linux" --cloud https://romeos.cc
54
60
  `,
55
61
  auth: `Usage:
56
62
  rome-node auth [--cloud <origin>] < token-file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rome-os/node",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Standalone CLI for Rome remote devices",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -22,7 +22,7 @@
22
22
  }
23
23
  },
24
24
  "dependencies": {
25
- "@rome-os/node-core": "^0.1.0"
25
+ "@rome-os/node-core": "^0.1.1"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@rstest/core": "^0.11.11",