@biolibs/bionet 1.2.0 → 1.2.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 +11 -11
- package/dist/discover.d.ts +1 -1
- package/dist/discover.js +1 -1
- package/dist/fetch.d.ts +2 -2
- package/dist/fetch.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/inventory.d.ts +2 -2
- package/dist/inventory.js +2 -2
- package/dist/model.d.ts +3 -3
- package/dist/model.js +2 -2
- package/dist/origin.d.ts +4 -4
- package/dist/origin.js +4 -4
- package/package.json +1 -1
- package/src/discover.ts +1 -1
- package/src/fetch.ts +2 -2
- package/src/index.ts +1 -1
- package/src/inventory.ts +2 -2
- package/src/model.ts +3 -3
- package/src/origin.ts +4 -4
package/README.md
CHANGED
|
@@ -33,8 +33,8 @@ of exactly the kind this is meant to avoid:
|
|
|
33
33
|
| it came from its own address | The document names the origin it was served from, so those keys belong to **that address** |
|
|
34
34
|
|
|
35
35
|
`settled()` is all three at once. What none of them is: *this lab is who it says it is.* The address
|
|
36
|
-
does that work, and only as far as you already trusted the address. If you know `
|
|
37
|
-
the
|
|
36
|
+
does that work, and only as far as you already trusted the address. If you know `wrenlab.example` is
|
|
37
|
+
the Wren lab — from a paper, a colleague, a sign on the door — then a signed inventory served from
|
|
38
38
|
there ties that key to that lab. If you do not know that, nothing here will tell you.
|
|
39
39
|
|
|
40
40
|
Two edges worth stating plainly:
|
|
@@ -66,8 +66,8 @@ import { generateSigningKey } from "@biolibs/opencloning";
|
|
|
66
66
|
const key = await generateSigningKey();
|
|
67
67
|
|
|
68
68
|
const inventory = inventoryFrom([f1, f2, f3], {
|
|
69
|
-
name: "
|
|
70
|
-
origin: "https://
|
|
69
|
+
name: "Wren lab",
|
|
70
|
+
origin: "https://wrenlab.example",
|
|
71
71
|
contact: null,
|
|
72
72
|
note: null,
|
|
73
73
|
});
|
|
@@ -75,7 +75,7 @@ const inventory = inventoryFrom([f1, f2, f3], {
|
|
|
75
75
|
console.log(inventory.parts[0].name); // "f1" — what this lab calls it
|
|
76
76
|
console.log(inventory.parts[0].checksum); // ldseguid=... — what everyone else matches on
|
|
77
77
|
|
|
78
|
-
const published = await signInventory(inventory, key, { signer: "
|
|
78
|
+
const published = await signInventory(inventory, key, { signer: "Wren lab" });
|
|
79
79
|
// write JSON.stringify(published) to /.well-known/bionet.json
|
|
80
80
|
```
|
|
81
81
|
|
|
@@ -88,7 +88,7 @@ the same molecule. Their names for it agree with nothing.
|
|
|
88
88
|
```ts
|
|
89
89
|
import { fetchInventory, settled, signingKeys } from "@biolibs/bionet";
|
|
90
90
|
|
|
91
|
-
const found = await fetchInventory("
|
|
91
|
+
const found = await fetchInventory("wrenlab.example");
|
|
92
92
|
|
|
93
93
|
console.log(found.checks[0].ok); // true — the signature holds
|
|
94
94
|
console.log(found.fromItsOwnAddress); // true — and it was served from the address it names
|
|
@@ -133,11 +133,11 @@ const inventory = inventoryFrom(parts, lab, {
|
|
|
133
133
|
});
|
|
134
134
|
|
|
135
135
|
// walking from a lab you were told about
|
|
136
|
-
const walk = await discover(["
|
|
136
|
+
const walk = await discover(["wrenlab.example"], { maxDepth: 2 });
|
|
137
137
|
|
|
138
138
|
console.log(walk.reached.map((one) => one.path.join(" → ")));
|
|
139
|
-
// [ "https://
|
|
140
|
-
// "https://
|
|
139
|
+
// [ "https://wrenlab.example",
|
|
140
|
+
// "https://wrenlab.example → https://otherlab.example" ]
|
|
141
141
|
console.log(walk.unreachable[0]?.why); // why an address did not answer, and who pointed at it
|
|
142
142
|
```
|
|
143
143
|
|
|
@@ -186,12 +186,12 @@ const needed = partsNeeded(plan.document);
|
|
|
186
186
|
console.log(needed.map((part) => part.name)); // [ "f1", "f2", "f3" ]
|
|
187
187
|
|
|
188
188
|
const sourcing = whoHas(needed, [found]);
|
|
189
|
-
console.log(sourcing[0].holders[0].lab); // "
|
|
189
|
+
console.log(sourcing[0].holders[0].lab); // "Wren lab"
|
|
190
190
|
console.log(unsourced(sourcing).map((p) => p.name)); // [ "f3" ] — nobody asked has this one
|
|
191
191
|
```
|
|
192
192
|
|
|
193
193
|
`partsNeeded` is the plan's leaves: the molecules no step in it makes, which is exactly what somebody
|
|
194
|
-
has to already have. Matching is by checksum, so a lab that calls the same molecule `
|
|
194
|
+
has to already have. Matching is by checksum, so a lab that calls the same molecule `pWren-402` is
|
|
195
195
|
found anyway. `heldButNotOffered` separates "nobody has it" from "somebody has it but is not sending
|
|
196
196
|
it", which are different problems for the person reading the plan.
|
|
197
197
|
|
package/dist/discover.d.ts
CHANGED
|
@@ -91,7 +91,7 @@ export interface DiscoverOptions extends FetchOptions {
|
|
|
91
91
|
* ```ts
|
|
92
92
|
* import { discover, partsNeeded, settledLabs, whoHas } from "@biolibs/bionet";
|
|
93
93
|
*
|
|
94
|
-
* const walk = await discover(["
|
|
94
|
+
* const walk = await discover(["wrenlab.example"], { maxDepth: 2 });
|
|
95
95
|
* walk.reached.map((one) => `${one.path.join(" → ")}`);
|
|
96
96
|
*
|
|
97
97
|
* whoHas(partsNeeded(plan.document), settledLabs(walk));
|
package/dist/discover.js
CHANGED
|
@@ -37,7 +37,7 @@ export const BY_DEFAULT = { labs: 50, depth: 2 };
|
|
|
37
37
|
* ```ts
|
|
38
38
|
* import { discover, partsNeeded, settledLabs, whoHas } from "@biolibs/bionet";
|
|
39
39
|
*
|
|
40
|
-
* const walk = await discover(["
|
|
40
|
+
* const walk = await discover(["wrenlab.example"], { maxDepth: 2 });
|
|
41
41
|
* walk.reached.map((one) => `${one.path.join(" → ")}`);
|
|
42
42
|
*
|
|
43
43
|
* whoHas(partsNeeded(plan.document), settledLabs(walk));
|
package/dist/fetch.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export interface FetchOptions {
|
|
|
21
21
|
/**
|
|
22
22
|
* Fetch a lab's inventory and check it.
|
|
23
23
|
*
|
|
24
|
-
* @param address - The lab's address, like `
|
|
24
|
+
* @param address - The lab's address, like `wrenlab.example`.
|
|
25
25
|
* @param options - What to fetch with, and how long to wait.
|
|
26
26
|
* @returns What came back, with the signatures checked and the address compared.
|
|
27
27
|
* @throws If the address is not usable, nothing answered, or what answered is not an inventory.
|
|
@@ -30,7 +30,7 @@ export interface FetchOptions {
|
|
|
30
30
|
* ```ts
|
|
31
31
|
* import { fetchInventory, settled } from "@biolibs/bionet";
|
|
32
32
|
*
|
|
33
|
-
* const found = await fetchInventory("
|
|
33
|
+
* const found = await fetchInventory("wrenlab.example");
|
|
34
34
|
* settled(found); // signed, and served from the address it claims
|
|
35
35
|
* found.signed.inventory.parts.length;
|
|
36
36
|
* ```
|
package/dist/fetch.js
CHANGED
|
@@ -14,7 +14,7 @@ const PATIENCE = 10_000;
|
|
|
14
14
|
/**
|
|
15
15
|
* Fetch a lab's inventory and check it.
|
|
16
16
|
*
|
|
17
|
-
* @param address - The lab's address, like `
|
|
17
|
+
* @param address - The lab's address, like `wrenlab.example`.
|
|
18
18
|
* @param options - What to fetch with, and how long to wait.
|
|
19
19
|
* @returns What came back, with the signatures checked and the address compared.
|
|
20
20
|
* @throws If the address is not usable, nothing answered, or what answered is not an inventory.
|
|
@@ -23,7 +23,7 @@ const PATIENCE = 10_000;
|
|
|
23
23
|
* ```ts
|
|
24
24
|
* import { fetchInventory, settled } from "@biolibs/bionet";
|
|
25
25
|
*
|
|
26
|
-
* const found = await fetchInventory("
|
|
26
|
+
* const found = await fetchInventory("wrenlab.example");
|
|
27
27
|
* settled(found); // signed, and served from the address it claims
|
|
28
28
|
* found.signed.inventory.parts.length;
|
|
29
29
|
* ```
|
package/dist/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* ```ts
|
|
29
29
|
* import { fetchInventory, partsNeeded, settled, whoHas } from "@biolibs/bionet";
|
|
30
30
|
*
|
|
31
|
-
* const found = await fetchInventory("
|
|
31
|
+
* const found = await fetchInventory("wrenlab.example");
|
|
32
32
|
* const sourcing = whoHas(partsNeeded(plan.document), settled(found) ? [found] : []);
|
|
33
33
|
*
|
|
34
34
|
* for (const { needed, holders } of sourcing) {
|
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* ```ts
|
|
29
29
|
* import { fetchInventory, partsNeeded, settled, whoHas } from "@biolibs/bionet";
|
|
30
30
|
*
|
|
31
|
-
* const found = await fetchInventory("
|
|
31
|
+
* const found = await fetchInventory("wrenlab.example");
|
|
32
32
|
* const sourcing = whoHas(partsNeeded(plan.document), settled(found) ? [found] : []);
|
|
33
33
|
*
|
|
34
34
|
* for (const { needed, holders } of sourcing) {
|
package/dist/inventory.d.ts
CHANGED
|
@@ -46,9 +46,9 @@ export interface InventoryOptions {
|
|
|
46
46
|
* import { inventoryFrom, signInventory } from "@biolibs/bionet";
|
|
47
47
|
*
|
|
48
48
|
* const inventory = inventoryFrom([pUC19, insert], {
|
|
49
|
-
* name: "
|
|
49
|
+
* name: "Wren lab", origin: "https://wrenlab.example", contact: null, note: null,
|
|
50
50
|
* });
|
|
51
|
-
* const published = await signInventory(inventory, key, { signer: "
|
|
51
|
+
* const published = await signInventory(inventory, key, { signer: "Wren lab" });
|
|
52
52
|
* ```
|
|
53
53
|
*/
|
|
54
54
|
export declare function inventoryFrom(records: readonly Dseqrecord[], lab: LabModel, options?: InventoryOptions): InventoryDocument;
|
package/dist/inventory.js
CHANGED
|
@@ -22,9 +22,9 @@ export const MOST_PEERS = 200;
|
|
|
22
22
|
* import { inventoryFrom, signInventory } from "@biolibs/bionet";
|
|
23
23
|
*
|
|
24
24
|
* const inventory = inventoryFrom([pUC19, insert], {
|
|
25
|
-
* name: "
|
|
25
|
+
* name: "Wren lab", origin: "https://wrenlab.example", contact: null, note: null,
|
|
26
26
|
* });
|
|
27
|
-
* const published = await signInventory(inventory, key, { signer: "
|
|
27
|
+
* const published = await signInventory(inventory, key, { signer: "Wren lab" });
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
30
|
export function inventoryFrom(records, lab, options = {}) {
|
package/dist/model.d.ts
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* circle, wherever you cut it open. Two labs holding the same molecule publish the same checksum
|
|
11
11
|
* without having agreed on anything.
|
|
12
12
|
*
|
|
13
|
-
* **The address is the identity.** An inventory signed by a key and served from `
|
|
14
|
-
* that key to `
|
|
13
|
+
* **The address is the identity.** An inventory signed by a key and served from `wrenlab.example` ties
|
|
14
|
+
* that key to `wrenlab.example` and to nothing else. There is no registry, no authority and nobody to
|
|
15
15
|
* ask: you get a lab's key the way you got its web address, and what you can catch afterwards is the
|
|
16
16
|
* key *changing*.
|
|
17
17
|
*
|
|
@@ -25,7 +25,7 @@ export interface LabModel {
|
|
|
25
25
|
/** What the lab calls itself. A label, not a verified name. */
|
|
26
26
|
name: string;
|
|
27
27
|
/**
|
|
28
|
-
* The web address the inventory is published at, as an origin like `https://
|
|
28
|
+
* The web address the inventory is published at, as an origin like `https://wrenlab.example`.
|
|
29
29
|
*
|
|
30
30
|
* Fetching checks this against where the document actually came from. A document claiming an origin
|
|
31
31
|
* it was not served from is refused, because that claim is the whole of the binding.
|
package/dist/model.js
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* circle, wherever you cut it open. Two labs holding the same molecule publish the same checksum
|
|
11
11
|
* without having agreed on anything.
|
|
12
12
|
*
|
|
13
|
-
* **The address is the identity.** An inventory signed by a key and served from `
|
|
14
|
-
* that key to `
|
|
13
|
+
* **The address is the identity.** An inventory signed by a key and served from `wrenlab.example` ties
|
|
14
|
+
* that key to `wrenlab.example` and to nothing else. There is no registry, no authority and nobody to
|
|
15
15
|
* ask: you get a lab's key the way you got its web address, and what you can catch afterwards is the
|
|
16
16
|
* key *changing*.
|
|
17
17
|
*
|
package/dist/origin.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* A lab publishes at a fixed path on its own web address, the way a site publishes other well-known
|
|
5
5
|
* files. Then the address does the work an authority would otherwise have to do: if you already know
|
|
6
|
-
* that `
|
|
7
|
-
* it is written on their door — then an inventory served from `https://
|
|
6
|
+
* that `wrenlab.example` is the Wren lab — because you read it in a paper, or a colleague told you, or
|
|
7
|
+
* it is written on their door — then an inventory served from `https://wrenlab.example` and signed by
|
|
8
8
|
* a key ties that key to that lab, as firmly as you trust the address and the connection.
|
|
9
9
|
*
|
|
10
10
|
* That is the whole of it, and it is worth being exact about the edges:
|
|
@@ -21,11 +21,11 @@ export declare const INVENTORY_PATH = "/.well-known/bionet.json";
|
|
|
21
21
|
/**
|
|
22
22
|
* Read what somebody typed as the address of a lab.
|
|
23
23
|
*
|
|
24
|
-
* Accepts `
|
|
24
|
+
* Accepts `wrenlab.example`, `https://wrenlab.example`, or an address with a path on it, and gives
|
|
25
25
|
* back the origin alone, which is all that identifies the lab.
|
|
26
26
|
*
|
|
27
27
|
* @param address - What they typed.
|
|
28
|
-
* @returns The origin, like `https://
|
|
28
|
+
* @returns The origin, like `https://wrenlab.example`.
|
|
29
29
|
* @throws If it is not an address, or is one whose connection would prove nothing.
|
|
30
30
|
*/
|
|
31
31
|
export declare function labOrigin(address: string): string;
|
package/dist/origin.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* A lab publishes at a fixed path on its own web address, the way a site publishes other well-known
|
|
5
5
|
* files. Then the address does the work an authority would otherwise have to do: if you already know
|
|
6
|
-
* that `
|
|
7
|
-
* it is written on their door — then an inventory served from `https://
|
|
6
|
+
* that `wrenlab.example` is the Wren lab — because you read it in a paper, or a colleague told you, or
|
|
7
|
+
* it is written on their door — then an inventory served from `https://wrenlab.example` and signed by
|
|
8
8
|
* a key ties that key to that lab, as firmly as you trust the address and the connection.
|
|
9
9
|
*
|
|
10
10
|
* That is the whole of it, and it is worth being exact about the edges:
|
|
@@ -23,11 +23,11 @@ const loopback = (host) => host === "localhost" || host === "127.0.0.1" || host
|
|
|
23
23
|
/**
|
|
24
24
|
* Read what somebody typed as the address of a lab.
|
|
25
25
|
*
|
|
26
|
-
* Accepts `
|
|
26
|
+
* Accepts `wrenlab.example`, `https://wrenlab.example`, or an address with a path on it, and gives
|
|
27
27
|
* back the origin alone, which is all that identifies the lab.
|
|
28
28
|
*
|
|
29
29
|
* @param address - What they typed.
|
|
30
|
-
* @returns The origin, like `https://
|
|
30
|
+
* @returns The origin, like `https://wrenlab.example`.
|
|
31
31
|
* @throws If it is not an address, or is one whose connection would prove nothing.
|
|
32
32
|
*/
|
|
33
33
|
export function labOrigin(address) {
|
package/package.json
CHANGED
package/src/discover.ts
CHANGED
|
@@ -106,7 +106,7 @@ interface Pending {
|
|
|
106
106
|
* ```ts
|
|
107
107
|
* import { discover, partsNeeded, settledLabs, whoHas } from "@biolibs/bionet";
|
|
108
108
|
*
|
|
109
|
-
* const walk = await discover(["
|
|
109
|
+
* const walk = await discover(["wrenlab.example"], { maxDepth: 2 });
|
|
110
110
|
* walk.reached.map((one) => `${one.path.join(" → ")}`);
|
|
111
111
|
*
|
|
112
112
|
* whoHas(partsNeeded(plan.document), settledLabs(walk));
|
package/src/fetch.ts
CHANGED
|
@@ -38,7 +38,7 @@ export interface FetchOptions {
|
|
|
38
38
|
/**
|
|
39
39
|
* Fetch a lab's inventory and check it.
|
|
40
40
|
*
|
|
41
|
-
* @param address - The lab's address, like `
|
|
41
|
+
* @param address - The lab's address, like `wrenlab.example`.
|
|
42
42
|
* @param options - What to fetch with, and how long to wait.
|
|
43
43
|
* @returns What came back, with the signatures checked and the address compared.
|
|
44
44
|
* @throws If the address is not usable, nothing answered, or what answered is not an inventory.
|
|
@@ -47,7 +47,7 @@ export interface FetchOptions {
|
|
|
47
47
|
* ```ts
|
|
48
48
|
* import { fetchInventory, settled } from "@biolibs/bionet";
|
|
49
49
|
*
|
|
50
|
-
* const found = await fetchInventory("
|
|
50
|
+
* const found = await fetchInventory("wrenlab.example");
|
|
51
51
|
* settled(found); // signed, and served from the address it claims
|
|
52
52
|
* found.signed.inventory.parts.length;
|
|
53
53
|
* ```
|
package/src/index.ts
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* ```ts
|
|
29
29
|
* import { fetchInventory, partsNeeded, settled, whoHas } from "@biolibs/bionet";
|
|
30
30
|
*
|
|
31
|
-
* const found = await fetchInventory("
|
|
31
|
+
* const found = await fetchInventory("wrenlab.example");
|
|
32
32
|
* const sourcing = whoHas(partsNeeded(plan.document), settled(found) ? [found] : []);
|
|
33
33
|
*
|
|
34
34
|
* for (const { needed, holders } of sourcing) {
|
package/src/inventory.ts
CHANGED
|
@@ -54,9 +54,9 @@ export interface InventoryOptions {
|
|
|
54
54
|
* import { inventoryFrom, signInventory } from "@biolibs/bionet";
|
|
55
55
|
*
|
|
56
56
|
* const inventory = inventoryFrom([pUC19, insert], {
|
|
57
|
-
* name: "
|
|
57
|
+
* name: "Wren lab", origin: "https://wrenlab.example", contact: null, note: null,
|
|
58
58
|
* });
|
|
59
|
-
* const published = await signInventory(inventory, key, { signer: "
|
|
59
|
+
* const published = await signInventory(inventory, key, { signer: "Wren lab" });
|
|
60
60
|
* ```
|
|
61
61
|
*/
|
|
62
62
|
export function inventoryFrom(records: readonly Dseqrecord[], lab: LabModel,
|
package/src/model.ts
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* circle, wherever you cut it open. Two labs holding the same molecule publish the same checksum
|
|
11
11
|
* without having agreed on anything.
|
|
12
12
|
*
|
|
13
|
-
* **The address is the identity.** An inventory signed by a key and served from `
|
|
14
|
-
* that key to `
|
|
13
|
+
* **The address is the identity.** An inventory signed by a key and served from `wrenlab.example` ties
|
|
14
|
+
* that key to `wrenlab.example` and to nothing else. There is no registry, no authority and nobody to
|
|
15
15
|
* ask: you get a lab's key the way you got its web address, and what you can catch afterwards is the
|
|
16
16
|
* key *changing*.
|
|
17
17
|
*
|
|
@@ -27,7 +27,7 @@ export interface LabModel {
|
|
|
27
27
|
/** What the lab calls itself. A label, not a verified name. */
|
|
28
28
|
name: string;
|
|
29
29
|
/**
|
|
30
|
-
* The web address the inventory is published at, as an origin like `https://
|
|
30
|
+
* The web address the inventory is published at, as an origin like `https://wrenlab.example`.
|
|
31
31
|
*
|
|
32
32
|
* Fetching checks this against where the document actually came from. A document claiming an origin
|
|
33
33
|
* it was not served from is refused, because that claim is the whole of the binding.
|
package/src/origin.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* A lab publishes at a fixed path on its own web address, the way a site publishes other well-known
|
|
5
5
|
* files. Then the address does the work an authority would otherwise have to do: if you already know
|
|
6
|
-
* that `
|
|
7
|
-
* it is written on their door — then an inventory served from `https://
|
|
6
|
+
* that `wrenlab.example` is the Wren lab — because you read it in a paper, or a colleague told you, or
|
|
7
|
+
* it is written on their door — then an inventory served from `https://wrenlab.example` and signed by
|
|
8
8
|
* a key ties that key to that lab, as firmly as you trust the address and the connection.
|
|
9
9
|
*
|
|
10
10
|
* That is the whole of it, and it is worth being exact about the edges:
|
|
@@ -27,11 +27,11 @@ const loopback = (host: string): boolean =>
|
|
|
27
27
|
/**
|
|
28
28
|
* Read what somebody typed as the address of a lab.
|
|
29
29
|
*
|
|
30
|
-
* Accepts `
|
|
30
|
+
* Accepts `wrenlab.example`, `https://wrenlab.example`, or an address with a path on it, and gives
|
|
31
31
|
* back the origin alone, which is all that identifies the lab.
|
|
32
32
|
*
|
|
33
33
|
* @param address - What they typed.
|
|
34
|
-
* @returns The origin, like `https://
|
|
34
|
+
* @returns The origin, like `https://wrenlab.example`.
|
|
35
35
|
* @throws If it is not an address, or is one whose connection would prove nothing.
|
|
36
36
|
*/
|
|
37
37
|
export function labOrigin(address: string): string {
|