asyx 0.8.0 → 0.9.1

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
@@ -118,6 +118,7 @@ Hostnames and ports belong to your **account**, not to one computer. Any device
118
118
  asyx name check orders-api # is orders-api.tunnel.asyx.ai available? (no setup needed)
119
119
  asyx setup --hostname orders-api # enroll this machine with that name
120
120
  asyx setup --random # or a generated name such as quiet-otter-482
121
+ asyx setup --address fast # use one of your addresses as this device's default (also changes it on a device already set up)
121
122
  asyx setup # or choose on the approval page (it proposes <machine>-<account>)
122
123
  asyx name add orders-api # add orders-api.tunnel.asyx.ai to your account from a set-up device
123
124
  ```
@@ -129,7 +130,7 @@ Names use 3–30 characters: lowercase letters, digits and hyphens, starting and
129
130
  With `--json`, `asyx setup` prints one JSON object per line on stdout and nothing else:
130
131
 
131
132
  ```text
132
- {"event":"approval_required","url":"https://www.asyx.ai/console/tunnel?...","code":"ABC-123","clientId":"cli_…","expiresInSeconds":600}
133
+ {"event":"approval_required","url":"https://www.asyx.ai/console/devices?...","code":"ABC-123","clientId":"cli_…","expiresInSeconds":600}
133
134
  {"event":"enrolled","clientId":"cli_…","hostname":"orders-api.tunnel.asyx.ai"}
134
135
  ```
135
136
 
@@ -242,7 +243,7 @@ Messages name the other computer by its name; they never contain an IP address.
242
243
  ```bash
243
244
  asyx help # commands; asyx tunnel --help for tunnel options
244
245
  asyx --version
245
- asyx setup [--hostname <name> | --random] [--json]
246
+ asyx setup [--hostname <name> | --random | --address <name>] [--json]
246
247
  asyx name check <name> [--json]
247
248
  asyx name add <name> [--json]
248
249
  asyx port release --tcp <port> | --udp <port> [--json]
@@ -255,6 +256,20 @@ asyx tunnel --minecraft --to <hostname> [--port <n>] [--name <alias>]
255
256
 
256
257
  ---
257
258
 
259
+ ## What's new in 0.9.1
260
+
261
+ **The live line names your public address** — an HTTP tunnel now prints `Tunnel live at https://<your address>` and then `Forwarding to http://localhost:<port>`, instead of only the local address.
262
+
263
+ **Approval opens on the Devices page** — the link `asyx setup` prints now opens asyx.ai/console/devices, where the new computer is approved above your device list. Links printed by older versions still work.
264
+
265
+ ## What's new in 0.9.0
266
+
267
+ **Pick one of your addresses at setup** — `asyx setup --address <name>` makes one of your account's existing addresses this device's default instead of creating a new one. On a device that is already set up, it changes its default. The approval page also lists your addresses next to "A new address".
268
+
269
+ **Takeover email** — when `--replace` takes over a running tunnel, the account owner gets an email saying what was taken, when, and from which device and computer to which. The same device taking over a tunnel that was running on another computer is marked as suspicious.
270
+
271
+ **Devices and addresses in the console** — the console has a Devices page (remove a device, change its default address) and lets you add or delete addresses and release ports. A deleted address loses its DNS records, and its name stays yours for 24 hours.
272
+
258
273
  ## What's new in 0.8.0
259
274
 
260
275
  **Add an address from the terminal** — `asyx name add <name>` adds `<name>.tunnel.asyx.ai` to your account (within your plan, with the same name check as the console). Any of your devices can then serve it with `--to`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asyx",
3
- "version": "0.8.0",
3
+ "version": "0.9.1",
4
4
  "description": "Asyx tunnel CLI — secure localhost exposure (HTTP, TCP, UDP)",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -7,7 +7,7 @@ import { ensureKeyAndCsr } from '../lib/csr.js';
7
7
  import { loadOrCreateClientId } from '../lib/device.js';
8
8
  import { parseSetupArgs, approvalUrl, checkName, describeAnswer, setupCode, EXIT } from '../lib/naming.js';
9
9
 
10
- const CONSOLE_URL = process.env.ASYX_CONSOLE_URL || 'https://www.asyx.ai/console/tunnel';
10
+ const CONSOLE_URL = process.env.ASYX_CONSOLE_URL || 'https://www.asyx.ai/console/devices'; // Story 4.15 c4: approval opens on the Devices page
11
11
  const STS_URL = process.env.ASYX_STS_URL || 'https://www.asyx.ai/www/sts';
12
12
  // A person has to open the link, maybe sign in, and press Approve (4.7): wait up to 10 minutes.
13
13
  const APPROVAL_DEADLINE_MS = Number(process.env.ASYX_SETUP_TIMEOUT_MS || 10 * 60_000);
@@ -22,7 +22,8 @@ function isJsonResponse(res) {
22
22
  }
23
23
 
24
24
  /**
25
- * `asyx setup [--hostname <name> | --random] [--json]` (Stories 2.1 r3, 4.7).
25
+ * `asyx setup [--hostname <name> | --random | --address <name>] [--json]` (Stories 2.1 r3, 4.7, 2.11 c5/c8).
26
+ * --address: one of the account's addresses as this device's default (a new device, or one already set up).
26
27
  * Returns the exit code. The terminal never prompts: it prints the approval link, waits, and reports
27
28
  * the approved hostname. With --json, stdout carries one JSON object per line and nothing else.
28
29
  *
@@ -52,7 +53,7 @@ export async function runSetup(argv = [], deps = {}) {
52
53
  return code;
53
54
  };
54
55
 
55
- if (opts.error) return fail(EXIT.USAGE, 'usage', `${opts.error}\nUsage: asyx setup [--hostname <name> | --random] [--json]`);
56
+ if (opts.error) return fail(EXIT.USAGE, 'usage', `${opts.error}\nUsage: asyx setup [--hostname <name> | --random | --address <name>] [--json]`);
56
57
 
57
58
  const clientId = clientIdImpl();
58
59
  if (!/^cli_[A-F0-9]{12}$/.test(clientId)) return fail(EXIT.FAILED, 'invalid_client_id', 'Invalid clientId format (expected cli_[A-F0-9]{12})');
@@ -73,7 +74,7 @@ export async function runSetup(argv = [], deps = {}) {
73
74
 
74
75
  // 1) Approval link
75
76
  const ticket = randHex(16);
76
- const url = approvalUrl(CONSOLE_URL, { clientId, ticket, hostname: opts.hostname, random: opts.random });
77
+ const url = approvalUrl(CONSOLE_URL, { clientId, ticket, hostname: opts.hostname, random: opts.random, address: opts.address });
77
78
  const code = setupCode(ticket);
78
79
  emit({ event: 'approval_required', url, code, clientId, expiresInSeconds: Math.round(deadlineMs / 1000) });
79
80
  say('Approve this device in your browser:');
@@ -620,7 +620,7 @@ async function httpTunnel(localPort, secGroupSlug) {
620
620
  if (secGroupSlug && assignment.quickpassSlug) {
621
621
  process.stdout.write(`🛡️ QuickPass secured (group=${assignment.quickpassSlug})\n`);
622
622
  }
623
- process.stdout.write(`🌐 Tunnel live at http://localhost:${localPort}\n`);
623
+ process.stdout.write(httpLiveLines(assignment, localPort));
624
624
  // QPA-CLI-12: Lease and relay info only shown with LOG_LEVEL=info or higher
625
625
  const logLevel = (process.env.ASYX_LOG_LEVEL || process.env.LOG_LEVEL || 'warn').toLowerCase();
626
626
  if (logLevel === 'info' || logLevel === 'debug') {
@@ -984,3 +984,11 @@ async function udpTunnel(targetPort, requestedExternalPort = null, targetHost =
984
984
  function sleep(ms) { return new Promise(r => setTimeout(r, ms)); }
985
985
 
986
986
  // Story 11.2: exp claim (seconds) of an assignment token, or null
987
+
988
+ /** Defect 11.47: the HTTP live line names the public address visitors use, then the local port. */
989
+ export function httpLiveLines(assignment, localPort) {
990
+ const publicHost = typeof assignment?.fqdn === 'string' && assignment.fqdn.trim() ? assignment.fqdn.trim() : null;
991
+ return publicHost
992
+ ? `🌐 Tunnel live at https://${publicHost}\n Forwarding to http://localhost:${localPort}\n`
993
+ : `🌐 Tunnel live at http://localhost:${localPort}\n`;
994
+ }
package/src/lib/naming.js CHANGED
@@ -20,7 +20,7 @@ export function normalizeLabel(input) {
20
20
 
21
21
  /** Parses `asyx setup` options. Returns { hostname, random, json } or { error }. */
22
22
  export function parseSetupArgs(argv) {
23
- const out = { hostname: null, random: false, json: false };
23
+ const out = { hostname: null, random: false, json: false, address: null };
24
24
  for (let i = 0; i < argv.length; i++) {
25
25
  const a = argv[i];
26
26
  if (a === 'setup') continue;
@@ -32,18 +32,26 @@ export function parseSetupArgs(argv) {
32
32
  const label = normalizeLabel(v);
33
33
  if (!label) return { error: `"${v}" is not a valid name: use 3-30 characters a-z, 0-9 and hyphens, starting and ending with a letter or digit` };
34
34
  out.hostname = label;
35
+ } else if (a === '--address' || a.startsWith('--address=')) {
36
+ // Story 2.11 c5/c8: one of the account's addresses as this device's default (new or already set up)
37
+ const v = a.includes('=') ? a.slice(a.indexOf('=') + 1) : argv[++i];
38
+ if (!v) return { error: '--address needs one of your addresses, for example --address orders-api' };
39
+ const label = normalizeLabel(v);
40
+ if (!label) return { error: `"${v}" is not a valid address name` };
41
+ out.address = label;
35
42
  } else return { error: `unknown option ${a}` };
36
43
  }
37
- if (out.hostname && out.random) return { error: 'use either --hostname or --random, not both' };
44
+ if ([out.hostname, out.random, out.address].filter(Boolean).length > 1) return { error: 'use one of --hostname, --random or --address' };
38
45
  return out;
39
46
  }
40
47
 
41
48
  /** The approval link. v=2 tells the page this CLI supports device naming (2.1 r3). */
42
- export function approvalUrl(base, { clientId, ticket, hostname, random, machine = os.hostname() }) {
49
+ export function approvalUrl(base, { clientId, ticket, hostname, random, address, machine = os.hostname() }) {
43
50
  const q = new URLSearchParams({ clientId, ticket, v: '2' });
44
51
  if (machine) q.set('machine', String(machine).slice(0, 64));
45
52
  if (hostname) q.set('hostname', hostname);
46
53
  if (random) q.set('random', '1');
54
+ if (address) q.set('address', address); // Story 2.11 c5/c8
47
55
  return `${base}?${q.toString()}`;
48
56
  }
49
57
 
package/src/main.js CHANGED
@@ -41,6 +41,7 @@ Usage: asyx <command>
41
41
  Examples:
42
42
  asyx setup
43
43
  asyx setup --hostname orders-api (or --random; add --json for agents)
44
+ asyx setup --address fast (use one of your addresses as this device's default)
44
45
  asyx name check orders-api
45
46
  asyx name add orders-api
46
47
  asyx tunnel --http --port 3000 --to orders-api.tunnel.asyx.ai