@biolibs/bionet 0.0.0-stage → 1.1.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/LICENSE +21 -0
- package/README.md +230 -2
- package/dist/discover.d.ts +121 -0
- package/dist/discover.d.ts.map +1 -0
- package/dist/discover.js +143 -0
- package/dist/discover.js.map +1 -0
- package/dist/fetch.d.ts +60 -0
- package/dist/fetch.d.ts.map +1 -0
- package/dist/fetch.js +85 -0
- package/dist/fetch.js.map +1 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/inventory.d.ts +103 -0
- package/dist/inventory.d.ts.map +1 -0
- package/dist/inventory.js +157 -0
- package/dist/inventory.js.map +1 -0
- package/dist/match.d.ts +88 -0
- package/dist/match.d.ts.map +1 -0
- package/dist/match.js +92 -0
- package/dist/match.js.map +1 -0
- package/dist/model.d.ts +114 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +23 -0
- package/dist/model.js.map +1 -0
- package/dist/origin.d.ts +51 -0
- package/dist/origin.d.ts.map +1 -0
- package/dist/origin.js +77 -0
- package/dist/origin.js.map +1 -0
- package/dist/trust.d.ts +65 -0
- package/dist/trust.d.ts.map +1 -0
- package/dist/trust.js +59 -0
- package/dist/trust.js.map +1 -0
- package/package.json +47 -4
- package/src/discover.ts +214 -0
- package/src/fetch.ts +107 -0
- package/src/index.ts +43 -0
- package/src/inventory.ts +191 -0
- package/src/match.ts +128 -0
- package/src/model.ts +119 -0
- package/src/origin.ts +79 -0
- package/src/trust.ts +88 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Matthew Stewart
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,231 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @biolibs/bionet
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Labs publishing what they hold, so that a cloning plan can be **acted on** and not just believed.
|
|
4
|
+
|
|
5
|
+
[`@biolibs/opencloning`](../opencloning) lets a lab send a plan that the receiving end can replay, and
|
|
6
|
+
sign it so the plan is attached to a key. Both of those are about the document. Neither of them gets
|
|
7
|
+
anybody a plasmid. This package is the other half: a lab writes down what it has, signs the list, and
|
|
8
|
+
publishes it at a fixed path on its own web address. Then a plan's starting parts can be looked up.
|
|
9
|
+
|
|
10
|
+
- **Write an inventory** from the molecules a lab holds
|
|
11
|
+
- **Sign it**, and let another lab countersign
|
|
12
|
+
- **Publish it** at `/.well-known/bionet.json`
|
|
13
|
+
- **Fetch one** and find out three separate things: that it is an inventory, that its signatures hold,
|
|
14
|
+
and that it came from the address it claims
|
|
15
|
+
- **Remember** which key answered last time, so a key that changes gets noticed
|
|
16
|
+
- **Find labs you were never told about**, by walking the pointers from ones you were
|
|
17
|
+
- **Ask who has** the parts a plan starts from, matched by checksum
|
|
18
|
+
|
|
19
|
+
> **This is not a port.** Every other package in biolibs is measured against a Python library case by
|
|
20
|
+
> case, and says so. This one has no upstream: there is nothing to be at parity with. It is a small,
|
|
21
|
+
> deliberate design, and the paragraphs below are as careful about what it does not establish as about
|
|
22
|
+
> what it does.
|
|
23
|
+
|
|
24
|
+
## What a fetched inventory actually establishes
|
|
25
|
+
|
|
26
|
+
Three things, kept apart on purpose, because flattening them into one "verified" badge would be a lie
|
|
27
|
+
of exactly the kind this is meant to avoid:
|
|
28
|
+
|
|
29
|
+
| | What it means |
|
|
30
|
+
|---|---|
|
|
31
|
+
| it parsed | Somebody published a document of the right shape at that address |
|
|
32
|
+
| its signatures hold | Whoever holds those keys published **this** list — not a word of it has changed since |
|
|
33
|
+
| it came from its own address | The document names the origin it was served from, so those keys belong to **that address** |
|
|
34
|
+
|
|
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 `endylab.example` is
|
|
37
|
+
the Endy lab — from a paper, a colleague, a sign on the door — then a signed inventory served from
|
|
38
|
+
there ties that key to that lab. If you do not know that, nothing here will tell you.
|
|
39
|
+
|
|
40
|
+
Two edges worth stating plainly:
|
|
41
|
+
|
|
42
|
+
- **https or nothing**, apart from a machine talking to itself. Over plain http anything in the middle
|
|
43
|
+
can swap the document, and the signature on the substitute will verify perfectly.
|
|
44
|
+
- **First sight is a leap of faith.** You cannot tell a lab's real key from a convincing stand-in on
|
|
45
|
+
the first visit. What you can tell is a key *changing* — which is what `trust.ts` is for, and why it
|
|
46
|
+
is worth writing down the first one.
|
|
47
|
+
|
|
48
|
+
## Install
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm install @biolibs/bionet
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
```mermaid
|
|
55
|
+
graph BT
|
|
56
|
+
bionet["@biolibs/bionet"] --> opencloning["@biolibs/opencloning<br/><i>plans, and the signing</i>"]
|
|
57
|
+
bionet --> dseqrecord["@biolibs/dseqrecord"]
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Publishing what a lab holds
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { inventoryFrom, signInventory } from "@biolibs/bionet";
|
|
64
|
+
import { generateSigningKey } from "@biolibs/opencloning";
|
|
65
|
+
|
|
66
|
+
const key = await generateSigningKey();
|
|
67
|
+
|
|
68
|
+
const inventory = inventoryFrom([f1, f2, f3], {
|
|
69
|
+
name: "Endy lab",
|
|
70
|
+
origin: "https://endylab.example",
|
|
71
|
+
contact: null,
|
|
72
|
+
note: null,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
console.log(inventory.parts[0].name); // "f1" — what this lab calls it
|
|
76
|
+
console.log(inventory.parts[0].checksum); // ldseguid=... — what everyone else matches on
|
|
77
|
+
|
|
78
|
+
const published = await signInventory(inventory, key, { signer: "Endy lab" });
|
|
79
|
+
// write JSON.stringify(published) to /.well-known/bionet.json
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
A part is listed by its SEGUID, which is the same whichever strand the molecule was written from and,
|
|
83
|
+
for a circle, wherever it was cut open. Two labs that have never spoken publish the same checksum for
|
|
84
|
+
the same molecule. Their names for it agree with nothing.
|
|
85
|
+
|
|
86
|
+
## Reading somebody else's
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { fetchInventory, settled, signingKeys } from "@biolibs/bionet";
|
|
90
|
+
|
|
91
|
+
const found = await fetchInventory("endylab.example");
|
|
92
|
+
|
|
93
|
+
console.log(found.checks[0].ok); // true — the signature holds
|
|
94
|
+
console.log(found.fromItsOwnAddress); // true — and it was served from the address it names
|
|
95
|
+
console.log(settled(found)); // true — both of those
|
|
96
|
+
console.log(signingKeys(found)); // [ "2f3f-fe1a-3d7d-c3b4" ]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
What comes back is the document **exactly as it arrived**, never a tidied copy: the signature covers
|
|
100
|
+
the bytes the lab wrote, so trimming a long note or filling in a missing field would leave a document
|
|
101
|
+
that no longer matches its own signature. Anything out of bounds is refused instead of repaired.
|
|
102
|
+
|
|
103
|
+
## Noticing when a key changes
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import { labMemory, remember } from "@biolibs/bionet";
|
|
107
|
+
|
|
108
|
+
const memory = labMemory(); // a browser would keep this in local storage
|
|
109
|
+
|
|
110
|
+
console.log(remember(memory, found.origin, signingKeys(found)).how); // "new" — first visit, a leap
|
|
111
|
+
console.log(remember(memory, found.origin, signingKeys(found)).how); // "known"
|
|
112
|
+
|
|
113
|
+
// a month later, a different key answers for the same address
|
|
114
|
+
console.log(remember(memory, found.origin, ["9999-aaaa-bbbb-cccc"]).how); // "changed"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
`"changed"` is the only one of the three that is evidence of anything. It may be a lab that rotated its
|
|
118
|
+
key, or it may be somebody standing where the lab used to be; only the lab can tell you which. The
|
|
119
|
+
point is that the question gets asked rather than passed over.
|
|
120
|
+
|
|
121
|
+
## How labs find each other
|
|
122
|
+
|
|
123
|
+
There is no index of labs, and this does not build one. A lab is found the way a page was found on
|
|
124
|
+
the early web: somebody you already know points at it. An inventory can therefore carry pointers to
|
|
125
|
+
other labs, and `discover` walks them.
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
import { discover, peer, settledLabs } from "@biolibs/bionet";
|
|
129
|
+
|
|
130
|
+
// pointing at somebody, in your own inventory
|
|
131
|
+
const inventory = inventoryFrom(parts, lab, {
|
|
132
|
+
peers: [peer("otherlab.example", { name: "Other lab", key: "2f3f-fe1a-3d7d-c3b4" })],
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// walking from a lab you were told about
|
|
136
|
+
const walk = await discover(["endylab.example"], { maxDepth: 2 });
|
|
137
|
+
|
|
138
|
+
console.log(walk.reached.map((one) => one.path.join(" → ")));
|
|
139
|
+
// [ "https://endylab.example",
|
|
140
|
+
// "https://endylab.example → https://otherlab.example" ]
|
|
141
|
+
console.log(walk.unreachable[0]?.why); // why an address did not answer, and who pointed at it
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
So the answer to "how does a new lab get found" is: **publish, and tell one person.** Put a signed
|
|
145
|
+
inventory at `/.well-known/bionet.json`, give the address to a lab that already has one, and when
|
|
146
|
+
they add you to their `peers` everyone who walks through them reaches you. Nothing can automate that
|
|
147
|
+
first introduction, and a design that claimed to would be inventing an authority.
|
|
148
|
+
|
|
149
|
+
Three consequences, stated rather than glossed:
|
|
150
|
+
|
|
151
|
+
- **What you find is what your seeds could reach.** There is no view of the whole network and no way
|
|
152
|
+
to know what you are missing. Two people starting from different labs find different sets, and
|
|
153
|
+
neither is "the network" — which is why `Discovery` records the `path` by which each lab was
|
|
154
|
+
reached, so a person can see how they came to be looking at it.
|
|
155
|
+
- **A pointer is not an endorsement.** It says this address exists and publishes an inventory. It
|
|
156
|
+
says nothing about what that lab holds or who they are.
|
|
157
|
+
- **Only a lab that checks out can introduce anyone.** If a document's signature fails, or it was
|
|
158
|
+
served from an address it does not claim, it is reported and then its pointers are discarded —
|
|
159
|
+
otherwise whoever could answer for one address could fill your walk with addresses of their
|
|
160
|
+
choosing.
|
|
161
|
+
|
|
162
|
+
A pointer may record the key the referring lab saw. A walk compares it with the key actually
|
|
163
|
+
answering and reports `agrees`, `differs` or `unsaid`:
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
import { introducedDifferently } from "@biolibs/bionet";
|
|
167
|
+
|
|
168
|
+
for (const one of introducedDifferently(walk)) {
|
|
169
|
+
console.log(one.found.origin, "is not answering with the key", one.introducedBy, "recorded");
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Nothing is concluded from a disagreement. It is surfaced because it is the one contradiction a walk
|
|
174
|
+
can notice without anybody being in charge: two parties describing the same address differently. One
|
|
175
|
+
of them is looking at something the other is not, and only they can say which.
|
|
176
|
+
|
|
177
|
+
Walks are bounded — 50 labs and 2 hops by default, `stoppedEarly` when it ran into that — and an
|
|
178
|
+
address is visited once however many labs point at it, so a cycle is walked but not gone round.
|
|
179
|
+
|
|
180
|
+
## Asking who has the parts
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
import { partsNeeded, unsourced, whoHas } from "@biolibs/bionet";
|
|
184
|
+
|
|
185
|
+
const needed = partsNeeded(plan.document);
|
|
186
|
+
console.log(needed.map((part) => part.name)); // [ "f1", "f2", "f3" ]
|
|
187
|
+
|
|
188
|
+
const sourcing = whoHas(needed, [found]);
|
|
189
|
+
console.log(sourcing[0].holders[0].lab); // "Endy lab"
|
|
190
|
+
console.log(unsourced(sourcing).map((p) => p.name)); // [ "f3" ] — nobody asked has this one
|
|
191
|
+
```
|
|
192
|
+
|
|
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 `pEndy-402` is
|
|
195
|
+
found anyway. `heldButNotOffered` separates "nobody has it" from "somebody has it but is not sending
|
|
196
|
+
it", which are different problems for the person reading the plan.
|
|
197
|
+
|
|
198
|
+
Inventories whose signatures do not hold are yours to filter out before you call `whoHas` — it matches
|
|
199
|
+
what it is given and claims nothing about whether the labs are to be believed.
|
|
200
|
+
|
|
201
|
+
## Testing
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
npm test # the whole workspace
|
|
205
|
+
npx vitest run packages/bionet/test
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
| File | What it checks |
|
|
209
|
+
|---|---|
|
|
210
|
+
| `test/bionet.test.ts` | inventories, signing, addresses, fetching, remembering, matching |
|
|
211
|
+
| `test/discover.test.ts` | walking the network, and everything a walk refuses to do |
|
|
212
|
+
| `test/readme.test.ts` | every code block in this file |
|
|
213
|
+
|
|
214
|
+
## Things to know
|
|
215
|
+
|
|
216
|
+
- **A signature over an inventory cannot be mistaken for a signature over a plan.** Each is made under
|
|
217
|
+
its own domain string, and the test for it signs one document under both domains to prove the
|
|
218
|
+
crossover fails.
|
|
219
|
+
- **`whoHas` matches by checksum only.** A lab that lists a molecule under a different name is still
|
|
220
|
+
found; a lab that lists the right name with the wrong molecule is not.
|
|
221
|
+
- **An unsigned inventory is not a broken one**, it is one that claims nothing. It parses, it may be
|
|
222
|
+
perfectly accurate, and `settled()` is false.
|
|
223
|
+
- **An inventory written before there were peers is still valid.** A missing list of pointers reads
|
|
224
|
+
as an empty one, and nothing adds the field to a document it did not write — the signature covers
|
|
225
|
+
the document as the lab wrote it.
|
|
226
|
+
- **Nothing here fetches a part.** Finding out who has a plasmid is as far as software goes; the rest
|
|
227
|
+
is an email and a padded envelope.
|
|
228
|
+
|
|
229
|
+
## License
|
|
230
|
+
|
|
231
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finding labs you were never told about, by walking from ones you were.
|
|
3
|
+
*
|
|
4
|
+
* There is no index of labs and nothing here builds one. A lab is found the way a page was found on
|
|
5
|
+
* the early web: somebody you already know points at it. So discovery is a walk — start from
|
|
6
|
+
* addresses a person gave you, fetch each lab's inventory, follow the labs it points at, and stop
|
|
7
|
+
* when you run out of new ones or hit the bounds you set.
|
|
8
|
+
*
|
|
9
|
+
* Three things about that are worth being plain about, because they are properties of the design and
|
|
10
|
+
* not gaps in the implementation.
|
|
11
|
+
*
|
|
12
|
+
* **What you find is what your seeds could reach.** There is no view of the whole network and no way
|
|
13
|
+
* to know what you are missing. Two people starting from different labs will find different sets, and
|
|
14
|
+
* neither is the network. `Discovery` therefore records the path by which each lab was reached, so a
|
|
15
|
+
* person can see *how* they came to be looking at it.
|
|
16
|
+
*
|
|
17
|
+
* **A pointer is not an endorsement.** A lab pointing at another says only that the address exists.
|
|
18
|
+
* Nothing here treats being pointed at as evidence about what that lab holds or who they are.
|
|
19
|
+
*
|
|
20
|
+
* **Only a lab that checks out can introduce anyone.** A document whose signature fails, or that was
|
|
21
|
+
* served from an address it does not claim, is reported and then its pointers are dropped on the
|
|
22
|
+
* floor. Otherwise anyone able to answer for one address could fill a crawl with addresses of their
|
|
23
|
+
* choosing, and the bounds below would be the only thing standing in the way.
|
|
24
|
+
*/
|
|
25
|
+
import { type FetchOptions, type FetchedInventory } from "./fetch.js";
|
|
26
|
+
/** How far a crawl goes unless told otherwise. */
|
|
27
|
+
export declare const BY_DEFAULT: {
|
|
28
|
+
labs: number;
|
|
29
|
+
depth: number;
|
|
30
|
+
};
|
|
31
|
+
/** Whether a lab's key is what the lab that pointed at it said it would be. */
|
|
32
|
+
export type AsIntroduced =
|
|
33
|
+
/** Nobody said, either because this was a seed or because the pointer carried no key. */
|
|
34
|
+
"unsaid"
|
|
35
|
+
/** The key answering is the one the referring lab recorded. */
|
|
36
|
+
| "agrees"
|
|
37
|
+
/** A different key is answering than the referring lab recorded. */
|
|
38
|
+
| "differs";
|
|
39
|
+
/** A lab the walk reached. */
|
|
40
|
+
export interface Reached {
|
|
41
|
+
/** Its inventory, fetched and checked. */
|
|
42
|
+
found: FetchedInventory;
|
|
43
|
+
/** Whether its signatures hold and it came from the address it claims. */
|
|
44
|
+
settled: boolean;
|
|
45
|
+
/** How many pointers from a seed: 0 for a seed itself. */
|
|
46
|
+
depth: number;
|
|
47
|
+
/** The addresses walked to get here, starting at the seed and ending at this lab. */
|
|
48
|
+
path: string[];
|
|
49
|
+
/** The lab that pointed at this one, or null for a seed. */
|
|
50
|
+
introducedBy: string | null;
|
|
51
|
+
/** Whether the key answering is the one the referring lab recorded. */
|
|
52
|
+
asIntroduced: AsIntroduced;
|
|
53
|
+
}
|
|
54
|
+
/** A lab the walk could not reach. */
|
|
55
|
+
export interface Unreachable {
|
|
56
|
+
/** The address that was tried. */
|
|
57
|
+
origin: string;
|
|
58
|
+
/** How many pointers from a seed. */
|
|
59
|
+
depth: number;
|
|
60
|
+
/** The lab that pointed at it, or null for a seed. */
|
|
61
|
+
introducedBy: string | null;
|
|
62
|
+
/** What went wrong, in the words the attempt produced. */
|
|
63
|
+
why: string;
|
|
64
|
+
}
|
|
65
|
+
/** What a walk came to. */
|
|
66
|
+
export interface Discovery {
|
|
67
|
+
/** The labs reached, in the order they were reached. */
|
|
68
|
+
reached: Reached[];
|
|
69
|
+
/** The addresses that were tried and did not answer usefully. */
|
|
70
|
+
unreachable: Unreachable[];
|
|
71
|
+
/** Whether the walk stopped at its bounds with addresses still unvisited. */
|
|
72
|
+
stoppedEarly: boolean;
|
|
73
|
+
}
|
|
74
|
+
/** How far to walk, and what to walk with. */
|
|
75
|
+
export interface DiscoverOptions extends FetchOptions {
|
|
76
|
+
/** The most labs to fetch. Defaults to 50. */
|
|
77
|
+
maxLabs?: number;
|
|
78
|
+
/** How many pointers from a seed to follow. 0 fetches the seeds only. Defaults to 2. */
|
|
79
|
+
maxDepth?: number;
|
|
80
|
+
/** Called as each lab is reached, for anything that wants to show a walk in progress. */
|
|
81
|
+
onReached?: (one: Reached) => void;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Walk the network from labs you already know.
|
|
85
|
+
*
|
|
86
|
+
* @param seeds - Addresses to start from, which somebody told you.
|
|
87
|
+
* @param options - How far to walk, and what to fetch with.
|
|
88
|
+
* @returns Every lab reached, how it was reached, and what could not be.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* import { discover, partsNeeded, settledLabs, whoHas } from "@biolibs/bionet";
|
|
93
|
+
*
|
|
94
|
+
* const walk = await discover(["endylab.example"], { maxDepth: 2 });
|
|
95
|
+
* walk.reached.map((one) => `${one.path.join(" → ")}`);
|
|
96
|
+
*
|
|
97
|
+
* whoHas(partsNeeded(plan.document), settledLabs(walk));
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare function discover(seeds: readonly string[], options?: DiscoverOptions): Promise<Discovery>;
|
|
101
|
+
/**
|
|
102
|
+
* The labs from a walk whose signatures hold and which came from their own address.
|
|
103
|
+
*
|
|
104
|
+
* These are the ones worth matching parts against. The rest are in `reached` with `settled` false, so
|
|
105
|
+
* that a walk can say "this address answered and did not check out" rather than quietly skipping it.
|
|
106
|
+
*
|
|
107
|
+
* @param discovery - What a walk came to.
|
|
108
|
+
* @returns Their inventories, in the order they were reached.
|
|
109
|
+
*/
|
|
110
|
+
export declare function settledLabs(discovery: Discovery): FetchedInventory[];
|
|
111
|
+
/**
|
|
112
|
+
* The labs a walk reached whose key is not the one that introduced them.
|
|
113
|
+
*
|
|
114
|
+
* Nothing is concluded from this. It is surfaced because it is the one disagreement a walk can notice
|
|
115
|
+
* without an authority: two parties describing the same address differently.
|
|
116
|
+
*
|
|
117
|
+
* @param discovery - What a walk came to.
|
|
118
|
+
* @returns Those labs.
|
|
119
|
+
*/
|
|
120
|
+
export declare function introducedDifferently(discovery: Discovery): Reached[];
|
|
121
|
+
//# sourceMappingURL=discover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../src/discover.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAwC,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAG5G,kDAAkD;AAClD,eAAO,MAAM,UAAU;;;CAAyB,CAAC;AAEjD,+EAA+E;AAC/E,MAAM,MAAM,YAAY;AACtB,yFAAyF;AACvF,QAAQ;AACV,+DAA+D;GAC7D,QAAQ;AACV,oEAAoE;GAClE,SAAS,CAAC;AAEd,8BAA8B;AAC9B,MAAM,WAAW,OAAO;IACtB,0CAA0C;IAC1C,KAAK,EAAE,gBAAgB,CAAC;IACxB,0EAA0E;IAC1E,OAAO,EAAE,OAAO,CAAC;IACj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0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finding labs you were never told about, by walking from ones you were.
|
|
3
|
+
*
|
|
4
|
+
* There is no index of labs and nothing here builds one. A lab is found the way a page was found on
|
|
5
|
+
* the early web: somebody you already know points at it. So discovery is a walk — start from
|
|
6
|
+
* addresses a person gave you, fetch each lab's inventory, follow the labs it points at, and stop
|
|
7
|
+
* when you run out of new ones or hit the bounds you set.
|
|
8
|
+
*
|
|
9
|
+
* Three things about that are worth being plain about, because they are properties of the design and
|
|
10
|
+
* not gaps in the implementation.
|
|
11
|
+
*
|
|
12
|
+
* **What you find is what your seeds could reach.** There is no view of the whole network and no way
|
|
13
|
+
* to know what you are missing. Two people starting from different labs will find different sets, and
|
|
14
|
+
* neither is the network. `Discovery` therefore records the path by which each lab was reached, so a
|
|
15
|
+
* person can see *how* they came to be looking at it.
|
|
16
|
+
*
|
|
17
|
+
* **A pointer is not an endorsement.** A lab pointing at another says only that the address exists.
|
|
18
|
+
* Nothing here treats being pointed at as evidence about what that lab holds or who they are.
|
|
19
|
+
*
|
|
20
|
+
* **Only a lab that checks out can introduce anyone.** A document whose signature fails, or that was
|
|
21
|
+
* served from an address it does not claim, is reported and then its pointers are dropped on the
|
|
22
|
+
* floor. Otherwise anyone able to answer for one address could fill a crawl with addresses of their
|
|
23
|
+
* choosing, and the bounds below would be the only thing standing in the way.
|
|
24
|
+
*/
|
|
25
|
+
import { fetchInventory, settled, signingKeys } from "./fetch.js";
|
|
26
|
+
import { labOrigin } from "./origin.js";
|
|
27
|
+
/** How far a crawl goes unless told otherwise. */
|
|
28
|
+
export const BY_DEFAULT = { labs: 50, depth: 2 };
|
|
29
|
+
/**
|
|
30
|
+
* Walk the network from labs you already know.
|
|
31
|
+
*
|
|
32
|
+
* @param seeds - Addresses to start from, which somebody told you.
|
|
33
|
+
* @param options - How far to walk, and what to fetch with.
|
|
34
|
+
* @returns Every lab reached, how it was reached, and what could not be.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { discover, partsNeeded, settledLabs, whoHas } from "@biolibs/bionet";
|
|
39
|
+
*
|
|
40
|
+
* const walk = await discover(["endylab.example"], { maxDepth: 2 });
|
|
41
|
+
* walk.reached.map((one) => `${one.path.join(" → ")}`);
|
|
42
|
+
*
|
|
43
|
+
* whoHas(partsNeeded(plan.document), settledLabs(walk));
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export async function discover(seeds, options = {}) {
|
|
47
|
+
const mostLabs = options.maxLabs ?? BY_DEFAULT.labs;
|
|
48
|
+
const deepest = options.maxDepth ?? BY_DEFAULT.depth;
|
|
49
|
+
const reached = [];
|
|
50
|
+
const unreachable = [];
|
|
51
|
+
const seen = new Set();
|
|
52
|
+
const queue = [];
|
|
53
|
+
for (const seed of seeds) {
|
|
54
|
+
try {
|
|
55
|
+
const origin = labOrigin(seed);
|
|
56
|
+
if (seen.has(origin))
|
|
57
|
+
continue;
|
|
58
|
+
seen.add(origin);
|
|
59
|
+
queue.push({ origin, depth: 0, path: [origin], introducedBy: null, expectedKey: null });
|
|
60
|
+
}
|
|
61
|
+
catch (cause) {
|
|
62
|
+
unreachable.push({ origin: seed, depth: 0, introducedBy: null, why: reason(cause) });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
let fetched = 0;
|
|
66
|
+
while (queue.length > 0) {
|
|
67
|
+
if (fetched >= mostLabs)
|
|
68
|
+
return { reached, unreachable, stoppedEarly: true };
|
|
69
|
+
const next = queue.shift();
|
|
70
|
+
fetched += 1;
|
|
71
|
+
let found;
|
|
72
|
+
try {
|
|
73
|
+
found = await fetchInventory(next.origin, options);
|
|
74
|
+
}
|
|
75
|
+
catch (cause) {
|
|
76
|
+
unreachable.push({ origin: next.origin, depth: next.depth, introducedBy: next.introducedBy, why: reason(cause) });
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const keys = signingKeys(found);
|
|
80
|
+
const one = {
|
|
81
|
+
found,
|
|
82
|
+
settled: settled(found),
|
|
83
|
+
depth: next.depth,
|
|
84
|
+
path: next.path,
|
|
85
|
+
introducedBy: next.introducedBy,
|
|
86
|
+
asIntroduced: next.expectedKey === null ? "unsaid"
|
|
87
|
+
: keys.includes(next.expectedKey) ? "agrees" : "differs",
|
|
88
|
+
};
|
|
89
|
+
reached.push(one);
|
|
90
|
+
options.onReached?.(one);
|
|
91
|
+
// A lab that does not check out does not get to say who else exists.
|
|
92
|
+
if (!one.settled || next.depth >= deepest)
|
|
93
|
+
continue;
|
|
94
|
+
for (const pointer of found.signed.inventory.peers ?? []) {
|
|
95
|
+
let origin;
|
|
96
|
+
try {
|
|
97
|
+
origin = labOrigin(pointer.origin);
|
|
98
|
+
}
|
|
99
|
+
catch (cause) {
|
|
100
|
+
unreachable.push({ origin: pointer.origin, depth: next.depth + 1, introducedBy: next.origin, why: reason(cause) });
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (seen.has(origin))
|
|
104
|
+
continue;
|
|
105
|
+
seen.add(origin);
|
|
106
|
+
queue.push({
|
|
107
|
+
origin,
|
|
108
|
+
depth: next.depth + 1,
|
|
109
|
+
path: [...next.path, origin],
|
|
110
|
+
introducedBy: next.origin,
|
|
111
|
+
expectedKey: pointer.key,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return { reached, unreachable, stoppedEarly: false };
|
|
116
|
+
}
|
|
117
|
+
/** @param cause - Whatever was thrown. @returns Something a person can read. */
|
|
118
|
+
const reason = (cause) => (cause instanceof Error ? cause.message : String(cause));
|
|
119
|
+
/**
|
|
120
|
+
* The labs from a walk whose signatures hold and which came from their own address.
|
|
121
|
+
*
|
|
122
|
+
* These are the ones worth matching parts against. The rest are in `reached` with `settled` false, so
|
|
123
|
+
* that a walk can say "this address answered and did not check out" rather than quietly skipping it.
|
|
124
|
+
*
|
|
125
|
+
* @param discovery - What a walk came to.
|
|
126
|
+
* @returns Their inventories, in the order they were reached.
|
|
127
|
+
*/
|
|
128
|
+
export function settledLabs(discovery) {
|
|
129
|
+
return discovery.reached.filter((one) => one.settled).map((one) => one.found);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The labs a walk reached whose key is not the one that introduced them.
|
|
133
|
+
*
|
|
134
|
+
* Nothing is concluded from this. It is surfaced because it is the one disagreement a walk can notice
|
|
135
|
+
* without an authority: two parties describing the same address differently.
|
|
136
|
+
*
|
|
137
|
+
* @param discovery - What a walk came to.
|
|
138
|
+
* @returns Those labs.
|
|
139
|
+
*/
|
|
140
|
+
export function introducedDifferently(discovery) {
|
|
141
|
+
return discovery.reached.filter((one) => one.asIntroduced === "differs");
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=discover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover.js","sourceRoot":"","sources":["../src/discover.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,EAA4C,MAAM,YAAY,CAAC;AAC5G,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,kDAAkD;AAClD,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AAqEjD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,KAAwB,EAAE,UAA2B,EAAE;IACpF,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC;IACpD,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,IAAI,UAAU,CAAC,KAAK,CAAC;IAErD,MAAM,OAAO,GAAc,EAAE,CAAC;IAC9B,MAAM,WAAW,GAAkB,EAAE,CAAC;IACtC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,KAAK,GAA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M,CAAC;gBAAE,SAAS;YAC/B,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACjB,KAAK,CAAC,IAAI,CAAC;gBACT,MAAM;gBACN,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC;gBACrB,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC;gBAC5B,YAAY,EAAE,IAAI,CAAC,MAAM;gBACzB,WAAW,EAAE,OAAO,CAAC,GAAG;aACzB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;AACvD,CAAC;AAED,gFAAgF;AAChF,MAAM,MAAM,GAAG,CAAC,KAAc,EAAU,EAAE,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAEpG;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,SAAoB;IAC9C,OAAO,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAChF,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CAAC,SAAoB;IACxD,OAAO,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC;AAC3E,CAAC"}
|
package/dist/fetch.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { SignedInventory } from "./model.js";
|
|
2
|
+
import type { SignatureCheck } from "@biolibs/opencloning";
|
|
3
|
+
/** An inventory, fetched. */
|
|
4
|
+
export interface FetchedInventory {
|
|
5
|
+
/** Where it was actually fetched from. */
|
|
6
|
+
origin: string;
|
|
7
|
+
/** The inventory and its signatures, exactly as served. */
|
|
8
|
+
signed: SignedInventory;
|
|
9
|
+
/** One check per signature. */
|
|
10
|
+
checks: SignatureCheck[];
|
|
11
|
+
/** Whether the document was served from the origin it names. */
|
|
12
|
+
fromItsOwnAddress: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** How to fetch. */
|
|
15
|
+
export interface FetchOptions {
|
|
16
|
+
/** Something to fetch with. Defaults to the runtime's own `fetch`. */
|
|
17
|
+
fetch?: typeof globalThis.fetch;
|
|
18
|
+
/** How long to wait, in milliseconds. */
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Fetch a lab's inventory and check it.
|
|
23
|
+
*
|
|
24
|
+
* @param address - The lab's address, like `endylab.example`.
|
|
25
|
+
* @param options - What to fetch with, and how long to wait.
|
|
26
|
+
* @returns What came back, with the signatures checked and the address compared.
|
|
27
|
+
* @throws If the address is not usable, nothing answered, or what answered is not an inventory.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { fetchInventory, settled } from "@biolibs/bionet";
|
|
32
|
+
*
|
|
33
|
+
* const found = await fetchInventory("endylab.example");
|
|
34
|
+
* settled(found); // signed, and served from the address it claims
|
|
35
|
+
* found.signed.inventory.parts.length;
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function fetchInventory(address: string, options?: FetchOptions): Promise<FetchedInventory>;
|
|
39
|
+
/**
|
|
40
|
+
* The fingerprints of the keys whose signatures held.
|
|
41
|
+
*
|
|
42
|
+
* These, not the lab's name, are what a lab is recognised by from one visit to the next.
|
|
43
|
+
*
|
|
44
|
+
* @param found - A fetched inventory.
|
|
45
|
+
* @returns The fingerprints, sorted, with duplicates dropped.
|
|
46
|
+
*/
|
|
47
|
+
export declare function signingKeys(found: FetchedInventory): string[];
|
|
48
|
+
/**
|
|
49
|
+
* Whether everything a fetch can settle came out right: at least one signature holds, and the document
|
|
50
|
+
* was served from the address it claims.
|
|
51
|
+
*
|
|
52
|
+
* This is not "this lab is who it says it is". It is "this document is internally consistent and came
|
|
53
|
+
* from the address you asked for". Whether that address is the lab you mean is something you knew
|
|
54
|
+
* before you typed it, or do not know at all.
|
|
55
|
+
*
|
|
56
|
+
* @param found - A fetched inventory.
|
|
57
|
+
* @returns Whether it is consistent and from its own address.
|
|
58
|
+
*/
|
|
59
|
+
export declare function settled(found: FetchedInventory): boolean;
|
|
60
|
+
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAK3D,6BAA6B;AAC7B,MAAM,WAAW,gBAAgB;IAC/B,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,MAAM,EAAE,eAAe,CAAC;IACxB,+BAA+B;IAC/B,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,gEAAgE;IAChE,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED,oBAAoB;AACpB,MAAM,WAAW,YAAY;IAC3B,sEAAsE;IACtE,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAyB3G;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,EAAE,CAE7D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAExD"}
|