@hallohuman/hightea 0.1.15 → 0.1.30

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hallohuman/hightea",
3
- "version": "0.1.15",
3
+ "version": "0.1.30",
4
4
  "description": "The Hightea command line: join this machine to a Hightea workspace as a host.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -17,13 +17,16 @@
17
17
  },
18
18
  "scripts": {
19
19
  "build": "bun build.ts",
20
+ "cut": "bun cut.ts",
21
+ "prepublishOnly": "bun run build && bun cut.ts --check",
20
22
  "prepack": "bun run build"
21
23
  },
22
24
  "dependencies": {
23
- "@ahpd/deploy": "https://github.com/beorn/ahpd/releases/download/hh-38277-3a159188/ahpd-deploy-0.15.0-beorn.3a159188.tgz",
24
- "@ahpd/sdk": "https://github.com/beorn/ahpd/releases/download/hh-38277-3a159188/ahpd-sdk-0.15.0-beorn.3a159188.tgz",
25
- "@ahpd/server": "https://github.com/beorn/ahpd/releases/download/hh-38277-3a159188/ahpd-server-0.15.0-beorn.3a159188.tgz",
26
- "@hallohuman/hightea-services": "https://github.com/beorn/ahpd/releases/download/hh-38277-3a159188/hallohuman-hightea-services-0.16.0-beorn.3a159188.tgz",
25
+ "@ahpd/agent-acp": "https://github.com/beorn/ahpd/releases/download/hh-38499-dc5a62e1/ahpd-agent-acp-0.15.0-beorn.dc5a62e1.tgz",
26
+ "@ahpd/deploy": "https://github.com/beorn/ahpd/releases/download/hh-38499-dc5a62e1/ahpd-deploy-0.15.0-beorn.dc5a62e1.tgz",
27
+ "@ahpd/sdk": "https://github.com/beorn/ahpd/releases/download/hh-38499-dc5a62e1/ahpd-sdk-0.15.0-beorn.dc5a62e1.tgz",
28
+ "@ahpd/server": "https://github.com/beorn/ahpd/releases/download/hh-38499-dc5a62e1/ahpd-server-0.15.0-beorn.dc5a62e1.tgz",
29
+ "@hallohuman/hightea-services": "https://github.com/beorn/ahpd/releases/download/hh-38499-dc5a62e1/hallohuman-hightea-services-0.16.0-beorn.dc5a62e1.tgz",
27
30
  "@silvery/commander": "0.29.3",
28
31
  "ws": "8.21.0"
29
32
  },
@@ -1,91 +0,0 @@
1
- import {
2
- TRUSTED_KEY_NAME,
3
- trustedKeyId,
4
- readTrustedKeys,
5
- localHost2
6
- } from "./chunk-h5s3wwdz.js";
7
-
8
- // ../ahp-host/src/trust.ts
9
- import { writeJsonAtomic } from "@ahpd/sdk";
10
- var TRUST_MEANS = "A trusted browser key lets posts made in that browser ask this machine's agents; a trusted host key " + "lets that machine's agents ask them too.";
11
- async function hostTrust(input, now = () => new Date) {
12
- const found = await localHost2(input.host);
13
- if ("error" in found) {
14
- console.error(found.error.replace(/^SERVICE_/u, "TRUST_"));
15
- return 1;
16
- }
17
- let current;
18
- try {
19
- current = readTrustedKeys(found.configDir);
20
- } catch (error) {
21
- console.error(`${error.message}; it was left unchanged`);
22
- return 1;
23
- }
24
- const keys = current.state === "read" ? current.keys : [];
25
- const where = `host ${found.hostId} (${current.file})`;
26
- if (input.action === "list") {
27
- if (input.json === true) {
28
- console.log(JSON.stringify({ hostId: found.hostId, file: current.file, keys }));
29
- return 0;
30
- }
31
- if (keys.length === 0) {
32
- console.log(`No trusted keys for ${where}: room asks to this machine's agents are refused until you add one with` + " `hightea host trust add <name> <public key>`.");
33
- return 0;
34
- }
35
- console.log(`Trusted keys for ${where}:`);
36
- for (const key of keys)
37
- console.log(` ${key.name} key ${key.keyId} added ${key.addedAt}`);
38
- console.log(TRUST_MEANS);
39
- return 0;
40
- }
41
- if (!TRUSTED_KEY_NAME.test(input.name)) {
42
- console.error("TRUST_NAME_INVALID: a name is 1 to 64 letters, digits, '.', '_' or '-', starting with a letter or digit; nothing was changed");
43
- return 1;
44
- }
45
- const named = keys.find((key) => key.name === input.name);
46
- if (input.action === "remove") {
47
- if (named === undefined) {
48
- console.error(`TRUST_NAME_UNKNOWN: ${where} trusts no key named ${input.name} (trusted: ${keys.map((key) => key.name).join(", ") || "none"}); nothing was changed`);
49
- return 1;
50
- }
51
- if (!write(current.file, keys.filter((key) => key !== named)))
52
- return 1;
53
- console.log(`Removed ${input.name} (key ${named.keyId}) from ${where}. Asks signed with it are refused from now on.`);
54
- return 0;
55
- }
56
- const id = trustedKeyId(input.publicKey);
57
- if ("error" in id) {
58
- console.error(`${id.error}; nothing was changed`);
59
- return 1;
60
- }
61
- if (named !== undefined) {
62
- if (named.publicKey === input.publicKey) {
63
- console.log(`${input.name} (key ${id.keyId}) is already trusted by ${where}; it was left unchanged.`);
64
- return 0;
65
- }
66
- console.error(`TRUST_NAME_TAKEN: ${where} already trusts another key as ${input.name}; remove it first or pick another name. Nothing was changed`);
67
- return 1;
68
- }
69
- const holder = keys.find((key) => key.keyId === id.keyId);
70
- if (holder !== undefined) {
71
- console.error(`TRUST_KEY_TAKEN: ${where} already trusts this key as ${holder.name}; nothing was changed`);
72
- return 1;
73
- }
74
- const added = { name: input.name, keyId: id.keyId, publicKey: input.publicKey, addedAt: now().toISOString() };
75
- if (!write(current.file, [...keys, added]))
76
- return 1;
77
- console.log(`Trusted ${input.name} (key ${id.keyId}) on ${where}. ${TRUST_MEANS}`);
78
- return 0;
79
- }
80
- function write(file, keys) {
81
- try {
82
- writeJsonAtomic(file, { v: 1, keys }, { mode: 384 });
83
- } catch (error) {
84
- console.error(`TRUST_FILE_UNWRITABLE: ${file}: ${error.message}`);
85
- return false;
86
- }
87
- return true;
88
- }
89
- export {
90
- hostTrust
91
- };