asyx 0.8.0 → 0.9.0

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
  ```
@@ -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,14 @@ asyx tunnel --minecraft --to <hostname> [--port <n>] [--name <alias>]
255
256
 
256
257
  ---
257
258
 
259
+ ## What's new in 0.9.0
260
+
261
+ **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".
262
+
263
+ **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.
264
+
265
+ **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.
266
+
258
267
  ## What's new in 0.8.0
259
268
 
260
269
  **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.0",
4
4
  "description": "Asyx tunnel CLI — secure localhost exposure (HTTP, TCP, UDP)",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -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:');
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