@biolibs/bionet-client 0.0.0-stage → 0.2.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
@@ -1,3 +1,106 @@
1
- # Temporary Holding Version
1
+ # @biolibs/bionet-client
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ One device in one lab: its key, its copy of the lab's signed log, everything a member can do, and the
4
+ connection to the lab's web peer. It works with no network and syncs when there is one.
5
+
6
+ It is an application with the edges left open. Where entries are kept, where the key lives and what
7
+ opens a socket are handed in, so the same `Lab` runs behind a desktop window, in a browser or in a test.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install @biolibs/bionet-client
13
+ ```
14
+
15
+ ## A device
16
+
17
+ ```ts
18
+ import { Lab, memoryKeys, memoryStore } from "@biolibs/bionet-client";
19
+
20
+ const lab = await new Lab({ store: memoryStore(), keys: memoryKeys() }).open();
21
+ await lab.setPerson("Ada");
22
+ await lab.found({ name: "The Wren Lab" }); // works at once, with no peer anywhere
23
+
24
+ await lab.addPart({ name: "f1", sequence: "GGATCACAGTCTACACTGCTCACTCC" });
25
+ const part = lab.snapshot().lab.parts[0].checksum;
26
+ const tube = await lab.addItem({ part, amount: 10, unit: "µL" });
27
+ await lab.adjust({ item: tube, by: -3 });
28
+ lab.snapshot().lab.items[0].amount; // 7
29
+
30
+ await lab.setPeer("wss://lab-wren.onrender.com/sync"); // now it syncs, and keeps trying when it cannot
31
+ ```
32
+
33
+ Every action becomes a signed entry in this device's own log. A change the lab would refuse is tried
34
+ first and **never written**, because a log is forever: the promise rejects with the reason.
35
+
36
+ On a desktop, keep the entries in a SQLite file. It is its own entry point because it needs Node:
37
+
38
+ ```ts
39
+ import { sqliteStore } from "@biolibs/bionet-client/sqlite";
40
+
41
+ const lab = await new Lab({ store: sqliteStore("./lab-data"), keys }).open();
42
+ ```
43
+
44
+ `keys` is anything with `load()` and `save()`. A real device keeps its key where the operating system
45
+ guards it; `memoryKeys()` is for tests.
46
+
47
+ ## Joining
48
+
49
+ 1. The new member sends a keeper their device's key: `lab.snapshot().device.key`.
50
+ 2. The keeper adds it, `lab.addMember({ key, person })`, and sends back `lab.invite`.
51
+ 3. The new member calls `lab.join(invite)`. The lab arrives once the keeper's change reaches the peer.
52
+
53
+ ## Where things are
54
+
55
+ ```ts
56
+ const freezer = await lab.addPlace({ kind: "freezer", name: "−80" });
57
+ const box = await lab.addPlace({ kind: "box", name: "Box 1", parent: freezer, grid: { rows: 9, columns: 9 } });
58
+ await lab.putItem({ item: tube, place: box, slot: { row: 0, column: 0 } });
59
+ lab.snapshot().lab?.places.length; // 2
60
+ ```
61
+
62
+ `movePlace`, `standPlace` (in metres, kept to the millimetre) and `retirePlace` do the rest.
63
+ `layoutFrom` in `@biolibs/bionet-space` turns the snapshot's lab into something that can be drawn.
64
+
65
+ ## Backing up the key
66
+
67
+ A device's key never leaves it, with one exception: a lab with one member and one device ends when
68
+ the device does.
69
+
70
+ ```ts
71
+ const backup = await lab.backUp("several unrelated words"); // text to write to a file
72
+ // later, on a new device that is not in a lab yet:
73
+ await fresh.restore({ backup, passphrase: "several unrelated words" });
74
+ await fresh.join(invite); // and it carries on the same log
75
+ ```
76
+
77
+ The key is sealed with AES-256-GCM under a key stretched from the passphrase by PBKDF2 (600,000
78
+ rounds of SHA-256). Nothing remembers the passphrase. `restore` is refused once a device is in a
79
+ lab: one key on two devices writes two histories the lab cannot tell apart.
80
+
81
+ ## The window's side
82
+
83
+ A window does not always share a process with the lab. It reaches one through a `LabSource`: the lab
84
+ as plain data, to be told when it changes, and one of a fixed list of things to be done.
85
+
86
+ ```ts
87
+ import { ACTIONS, perform, sourceOf } from "@biolibs/bionet-client";
88
+
89
+ const source = sourceOf(lab); // a lab in this process
90
+ source.snapshot(); // the same object until something changes
91
+ await source.act("adjust", { item: tube, by: -1 }); // { ok: true, result } or { ok: false, error }
92
+
93
+ await perform(lab, "close"); // { ok: false, ... }: not on the list, so refused
94
+ ```
95
+
96
+ `perform` is the door for a lab in another process: it does only what is in `ACTIONS`.
97
+
98
+ ## Testing
99
+
100
+ `test/client.test.ts` runs two devices against the real peer from `@biolibs/bionet-peer`, in process:
101
+ founding offline, joining, live changes, a network that goes away and comes back, refusals, removal,
102
+ publishing, and reopening from disk.
103
+
104
+ ## License
105
+
106
+ MIT
@@ -0,0 +1,67 @@
1
+ /** The version of the sealed-key document. */
2
+ export declare const BACKUP_VERSION = 1;
3
+ /** How many rounds the passphrase is stretched by. */
4
+ export declare const BACKUP_ROUNDS = 600000;
5
+ /** The fewest characters a passphrase may have. */
6
+ export declare const SHORTEST_PASSPHRASE = 12;
7
+ /** A device's key, sealed under a passphrase. Every byte string is base64. */
8
+ export interface KeyBackup {
9
+ /** Which version of this document it is. */
10
+ bionet_key_backup: number;
11
+ /** The fingerprint of the key inside, so a person can tell which key a file holds without opening it. */
12
+ fingerprint: string;
13
+ /** How the passphrase becomes a key. */
14
+ kdf: {
15
+ name: "PBKDF2";
16
+ hash: "SHA-256";
17
+ iterations: number;
18
+ salt: string;
19
+ };
20
+ /** How the key was sealed. */
21
+ cipher: {
22
+ name: "AES-GCM";
23
+ iv: string;
24
+ };
25
+ /** The sealed key. */
26
+ sealed: string;
27
+ }
28
+ /**
29
+ * Seal a device's key under a passphrase.
30
+ *
31
+ * @param exported - The key, as `exportSigningKey` wrote it.
32
+ * @param passphrase - What it will take to open it again.
33
+ * @param options - `iterations` is only for tests, which cannot wait for the real number.
34
+ * @returns The sealed key, safe to write to a file.
35
+ * @throws If the passphrase is too short to be worth sealing anything with.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import { exportSigningKey, generateSigningKey } from "@biolibs/opencloning";
40
+ * import { openKey, sealKey } from "@biolibs/bionet-client";
41
+ *
42
+ * const exported = await exportSigningKey(await generateSigningKey());
43
+ * const backup = await sealKey(exported, "correct horse battery staple");
44
+ * (await openKey(backup, "correct horse battery staple")) === exported; // true
45
+ * ```
46
+ */
47
+ export declare function sealKey(exported: string, passphrase: string, options?: {
48
+ iterations?: number;
49
+ }): Promise<KeyBackup>;
50
+ /**
51
+ * Read a sealed key, from the document or its text.
52
+ *
53
+ * @param value - What was in the file.
54
+ * @returns The sealed key.
55
+ * @throws If it is not one.
56
+ */
57
+ export declare function readBackup(value: unknown): KeyBackup;
58
+ /**
59
+ * Open a sealed key.
60
+ *
61
+ * @param backup - The sealed key, or the text of the file it was kept in.
62
+ * @param passphrase - What it was sealed under.
63
+ * @returns The key, as `exportSigningKey` wrote it.
64
+ * @throws If the passphrase is wrong, or the document has been changed.
65
+ */
66
+ export declare function openKey(backup: unknown, passphrase: string): Promise<string>;
67
+ //# sourceMappingURL=backup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backup.d.ts","sourceRoot":"","sources":["../src/backup.ts"],"names":[],"mappings":"AAYA,8CAA8C;AAC9C,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC,sDAAsD;AACtD,eAAO,MAAM,aAAa,SAAU,CAAC;AAErC,mDAAmD;AACnD,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC,8EAA8E;AAC9E,MAAM,WAAW,SAAS;IACxB,4CAA4C;IAC5C,iBAAiB,EAAE,MAAM,CAAC;IAC1B,yGAAyG;IACzG,WAAW,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,GAAG,EAAE;QAAE,IAAI,EAAE,QAAQ,CAAC;QAAC,IAAI,EAAE,SAAS,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3E,8BAA8B;IAC9B,MAAM,EAAE;QAAE,IAAI,EAAE,SAAS,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB;AAWD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAgB7H;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAcpD;AAED;;;;;;;GAOG;AACH,wBAAsB,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAelF"}
package/dist/backup.js ADDED
@@ -0,0 +1,111 @@
1
+ /**
2
+ * A device's key, sealed so that it can be kept somewhere else.
3
+ *
4
+ * A device's key never leaves the device, with one exception: a lab with one member and one device
5
+ * is a lab that ends when the device does. So the key can be written out sealed under a passphrase,
6
+ * as a small document to keep somewhere that is not this machine, and opened again on a new one.
7
+ *
8
+ * What is sealed is useless without the passphrase, and nothing here remembers it. A sealed key
9
+ * whose passphrase is forgotten is a lost key.
10
+ */
11
+ import { importSigningKey, keyFingerprint } from "@biolibs/opencloning";
12
+ /** The version of the sealed-key document. */
13
+ export const BACKUP_VERSION = 1;
14
+ /** How many rounds the passphrase is stretched by. */
15
+ export const BACKUP_ROUNDS = 600_000;
16
+ /** The fewest characters a passphrase may have. */
17
+ export const SHORTEST_PASSPHRASE = 12;
18
+ const toBase64 = (bytes) => btoa(String.fromCharCode(...bytes));
19
+ const fromBase64 = (text) => Uint8Array.from(atob(text), (letter) => letter.charCodeAt(0));
20
+ async function stretch(passphrase, salt, iterations) {
21
+ const subtle = globalThis.crypto.subtle;
22
+ const material = await subtle.importKey("raw", new TextEncoder().encode(passphrase.normalize("NFKC")), "PBKDF2", false, ["deriveKey"]);
23
+ return subtle.deriveKey({ name: "PBKDF2", hash: "SHA-256", salt, iterations }, material, { name: "AES-GCM", length: 256 }, false, ["encrypt", "decrypt"]);
24
+ }
25
+ /**
26
+ * Seal a device's key under a passphrase.
27
+ *
28
+ * @param exported - The key, as `exportSigningKey` wrote it.
29
+ * @param passphrase - What it will take to open it again.
30
+ * @param options - `iterations` is only for tests, which cannot wait for the real number.
31
+ * @returns The sealed key, safe to write to a file.
32
+ * @throws If the passphrase is too short to be worth sealing anything with.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * import { exportSigningKey, generateSigningKey } from "@biolibs/opencloning";
37
+ * import { openKey, sealKey } from "@biolibs/bionet-client";
38
+ *
39
+ * const exported = await exportSigningKey(await generateSigningKey());
40
+ * const backup = await sealKey(exported, "correct horse battery staple");
41
+ * (await openKey(backup, "correct horse battery staple")) === exported; // true
42
+ * ```
43
+ */
44
+ export async function sealKey(exported, passphrase, options = {}) {
45
+ if (passphrase.length < SHORTEST_PASSPHRASE) {
46
+ throw new Error(`A passphrase of at least ${SHORTEST_PASSPHRASE} characters. Several unrelated words work well.`);
47
+ }
48
+ const iterations = options.iterations ?? BACKUP_ROUNDS;
49
+ const salt = globalThis.crypto.getRandomValues(new Uint8Array(16));
50
+ const iv = globalThis.crypto.getRandomValues(new Uint8Array(12));
51
+ const fingerprint = await keyFingerprint((await importSigningKey(exported)).publicKey);
52
+ const sealed = await globalThis.crypto.subtle.encrypt({ name: "AES-GCM", iv }, await stretch(passphrase, salt, iterations), new TextEncoder().encode(exported));
53
+ return {
54
+ bionet_key_backup: BACKUP_VERSION, fingerprint,
55
+ kdf: { name: "PBKDF2", hash: "SHA-256", iterations, salt: toBase64(salt) },
56
+ cipher: { name: "AES-GCM", iv: toBase64(iv) },
57
+ sealed: toBase64(new Uint8Array(sealed)),
58
+ };
59
+ }
60
+ /**
61
+ * Read a sealed key, from the document or its text.
62
+ *
63
+ * @param value - What was in the file.
64
+ * @returns The sealed key.
65
+ * @throws If it is not one.
66
+ */
67
+ export function readBackup(value) {
68
+ let found = value;
69
+ if (typeof found === "string") {
70
+ try {
71
+ found = JSON.parse(found);
72
+ }
73
+ catch {
74
+ throw new Error("That is not a key backup.");
75
+ }
76
+ }
77
+ const one = found;
78
+ const short = (text, most) => typeof text === "string" && text.length > 0 && text.length <= most;
79
+ if (one === null || typeof one !== "object" || one.bionet_key_backup !== BACKUP_VERSION || !short(one.fingerprint, 100)
80
+ || one.kdf?.name !== "PBKDF2" || one.kdf.hash !== "SHA-256" || !Number.isSafeInteger(one.kdf.iterations)
81
+ || one.kdf.iterations < 1 || one.kdf.iterations > 10_000_000 || !short(one.kdf.salt, 200)
82
+ || one.cipher?.name !== "AES-GCM" || !short(one.cipher.iv, 200) || !short(one.sealed, 20_000)) {
83
+ throw new Error("That is not a key backup.");
84
+ }
85
+ return one;
86
+ }
87
+ /**
88
+ * Open a sealed key.
89
+ *
90
+ * @param backup - The sealed key, or the text of the file it was kept in.
91
+ * @param passphrase - What it was sealed under.
92
+ * @returns The key, as `exportSigningKey` wrote it.
93
+ * @throws If the passphrase is wrong, or the document has been changed.
94
+ */
95
+ export async function openKey(backup, passphrase) {
96
+ const one = readBackup(backup);
97
+ let exported;
98
+ try {
99
+ const opened = await globalThis.crypto.subtle.decrypt({ name: "AES-GCM", iv: fromBase64(one.cipher.iv) }, await stretch(passphrase, fromBase64(one.kdf.salt), one.kdf.iterations), fromBase64(one.sealed));
100
+ exported = new TextDecoder().decode(opened);
101
+ }
102
+ catch {
103
+ throw new Error("That passphrase does not open this backup.");
104
+ }
105
+ // The fingerprint on the outside is not sealed, so it is checked against what was inside.
106
+ if (await keyFingerprint((await importSigningKey(exported)).publicKey) !== one.fingerprint) {
107
+ throw new Error("This backup does not hold the key it says it does.");
108
+ }
109
+ return exported;
110
+ }
111
+ //# sourceMappingURL=backup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backup.js","sourceRoot":"","sources":["../src/backup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAExE,8CAA8C;AAC9C,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAEhC,sDAAsD;AACtD,MAAM,CAAC,MAA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AC/B,IAAI,QAAgB,CAAC;IACrB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAClD,MAAM,OAAO,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;QACvJ,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IACD,0FAA0F;IAC1F,IAAI,MAAM,cAAc,CAAC,CAAC,MAAM,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,WAAW,EAAE,CAAC;QAC3F,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * `@biolibs/bionet-client`: one device in one lab.
4
+ *
5
+ * `@biolibs/bionet` says what a lab's signed log means. This is the thing that keeps one: a device's
6
+ * key, its copy of the log, every action a member can take, and the connection to the lab's web
7
+ * peer. It works with no network and syncs when there is one.
8
+ *
9
+ * It is an application with the edges left open. Where entries are kept, where the key lives and
10
+ * what opens a socket are handed in, so the same `Lab` runs behind a desktop window, in a browser or
11
+ * in a test:
12
+ *
13
+ * - `lab.ts` — the device: `Lab`, and the plain-data snapshot a window draws
14
+ * - `link.ts` — the connection to the web peer, which is allowed to fail
15
+ * - `source.ts` — the narrow way a window reaches a lab, in this process or another
16
+ * - `backup.ts` — the device's key, sealed under a passphrase to keep somewhere else
17
+ * - `store.ts` — the interfaces for storage and key keeping, with in-memory versions
18
+ * - `sqlite.ts` — storage in a SQLite file, at `@biolibs/bionet-client/sqlite` because it needs Node
19
+ */
20
+ export * from "./lab.js";
21
+ export * from "./link.js";
22
+ export * from "./store.js";
23
+ export * from "./source.js";
24
+ export * from "./backup.js";
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * `@biolibs/bionet-client`: one device in one lab.
4
+ *
5
+ * `@biolibs/bionet` says what a lab's signed log means. This is the thing that keeps one: a device's
6
+ * key, its copy of the log, every action a member can take, and the connection to the lab's web
7
+ * peer. It works with no network and syncs when there is one.
8
+ *
9
+ * It is an application with the edges left open. Where entries are kept, where the key lives and
10
+ * what opens a socket are handed in, so the same `Lab` runs behind a desktop window, in a browser or
11
+ * in a test:
12
+ *
13
+ * - `lab.ts` — the device: `Lab`, and the plain-data snapshot a window draws
14
+ * - `link.ts` — the connection to the web peer, which is allowed to fail
15
+ * - `source.ts` — the narrow way a window reaches a lab, in this process or another
16
+ * - `backup.ts` — the device's key, sealed under a passphrase to keep somewhere else
17
+ * - `store.ts` — the interfaces for storage and key keeping, with in-memory versions
18
+ * - `sqlite.ts` — storage in a SQLite file, at `@biolibs/bionet-client/sqlite` because it needs Node
19
+ */
20
+ export * from "./lab.js";
21
+ export * from "./link.js";
22
+ export * from "./store.js";
23
+ export * from "./source.js";
24
+ export * from "./backup.js";
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}