@serfab/cadre-core 1.13.0 → 1.15.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 +293 -274
- package/dist/cadre-invite-protocol.d.ts +383 -0
- package/dist/cadre-invite-protocol.js +774 -0
- package/dist/cadre-invite-protocol.js.map +1 -0
- package/dist/cadre-join-request.d.ts +42 -0
- package/dist/cadre-join-request.js +144 -0
- package/dist/cadre-join-request.js.map +1 -0
- package/dist/cadre-node.d.ts +849 -210
- package/dist/cadre-node.js +1574 -374
- package/dist/cadre-node.js.map +1 -1
- package/dist/claim-proof.d.ts +45 -0
- package/dist/claim-proof.js +132 -0
- package/dist/claim-proof.js.map +1 -0
- package/dist/control-authorization.d.ts +80 -19
- package/dist/control-authorization.js +55 -13
- package/dist/control-authorization.js.map +1 -1
- package/dist/control-cohort.js +1 -1
- package/dist/control-cohort.js.map +1 -1
- package/dist/control-database.d.ts +605 -108
- package/dist/control-database.js +1299 -280
- package/dist/control-database.js.map +1 -1
- package/dist/control-protocol-guard.d.ts +142 -0
- package/dist/control-protocol-guard.js +293 -0
- package/dist/control-protocol-guard.js.map +1 -0
- package/dist/control-schema.d.ts +1 -1
- package/dist/control-schema.js +817 -1067
- package/dist/control-schema.js.map +1 -1
- package/dist/control-stream.d.ts +4 -0
- package/dist/control-stream.js +22 -7
- package/dist/control-stream.js.map +1 -1
- package/dist/delegate-admission.d.ts +1 -1
- package/dist/delegate-admission.js +1 -1
- package/dist/device-token.d.ts +11 -9
- package/dist/device-token.js +14 -12
- package/dist/device-token.js.map +1 -1
- package/dist/ed25519-key.d.ts +22 -9
- package/dist/ed25519-key.js +47 -10
- package/dist/ed25519-key.js.map +1 -1
- package/dist/fetch-impl.d.ts +12 -0
- package/dist/fetch-impl.js +23 -0
- package/dist/fetch-impl.js.map +1 -0
- package/dist/file-durable-slot.js +2 -1
- package/dist/file-durable-slot.js.map +1 -1
- package/dist/file-safe-name.d.ts +25 -0
- package/dist/file-safe-name.js +29 -0
- package/dist/file-safe-name.js.map +1 -0
- package/dist/formation-approval.js +5 -11
- package/dist/formation-approval.js.map +1 -1
- package/dist/fs-atomic.d.ts +0 -19
- package/dist/fs-atomic.js +3 -24
- package/dist/fs-atomic.js.map +1 -1
- package/dist/index.d.ts +22 -10
- package/dist/index.js +54 -11
- package/dist/index.js.map +1 -1
- package/dist/invitation-bootstrap.d.ts +50 -12
- package/dist/invitation-bootstrap.js +76 -13
- package/dist/invitation-bootstrap.js.map +1 -1
- package/dist/joined-strand-store.d.ts +7 -0
- package/dist/joined-strand-store.js +9 -0
- package/dist/joined-strand-store.js.map +1 -1
- package/dist/key-store-file.js +2 -1
- package/dist/key-store-file.js.map +1 -1
- package/dist/link-budget.d.ts +25 -33
- package/dist/link-budget.js +25 -35
- package/dist/link-budget.js.map +1 -1
- package/dist/machine-removal.d.ts +78 -0
- package/dist/machine-removal.js +166 -0
- package/dist/machine-removal.js.map +1 -0
- package/dist/membership-connection-gater.d.ts +191 -151
- package/dist/membership-connection-gater.js +236 -173
- package/dist/membership-connection-gater.js.map +1 -1
- package/dist/node-claim-payload.d.ts +74 -0
- package/dist/node-claim-payload.js +224 -0
- package/dist/node-claim-payload.js.map +1 -0
- package/dist/node-default-transports.d.ts +27 -0
- package/dist/node-default-transports.js +35 -0
- package/dist/node-default-transports.js.map +1 -0
- package/dist/node-transports.d.ts +30 -0
- package/dist/node-transports.js +40 -0
- package/dist/node-transports.js.map +1 -0
- package/dist/owner-anchor-sync.d.ts +22 -0
- package/dist/owner-anchor-sync.js +143 -0
- package/dist/owner-anchor-sync.js.map +1 -0
- package/dist/peer-authorization.d.ts +113 -18
- package/dist/peer-authorization.js +225 -29
- package/dist/peer-authorization.js.map +1 -1
- package/dist/peer-dial.d.ts +143 -27
- package/dist/peer-dial.js +276 -31
- package/dist/peer-dial.js.map +1 -1
- package/dist/peer-join-backfill.d.ts +26 -2
- package/dist/peer-join-backfill.js +60 -12
- package/dist/peer-join-backfill.js.map +1 -1
- package/dist/peer-record.d.ts +17 -52
- package/dist/peer-record.js +20 -58
- package/dist/peer-record.js.map +1 -1
- package/dist/pending-join-runner.d.ts +66 -58
- package/dist/pending-join-runner.js +136 -145
- package/dist/pending-join-runner.js.map +1 -1
- package/dist/primary-lan-address.d.ts +8 -0
- package/dist/primary-lan-address.js +46 -0
- package/dist/primary-lan-address.js.map +1 -0
- package/dist/provider/client.d.ts +131 -0
- package/dist/provider/client.js +226 -0
- package/dist/provider/client.js.map +1 -0
- package/dist/provider/descriptor.d.ts +41 -0
- package/dist/provider/descriptor.js +103 -0
- package/dist/provider/descriptor.js.map +1 -0
- package/dist/provider/index.d.ts +9 -0
- package/dist/provider/index.js +10 -0
- package/dist/provider/index.js.map +1 -0
- package/dist/provider/oauth.d.ts +125 -0
- package/dist/provider/oauth.js +199 -0
- package/dist/provider/oauth.js.map +1 -0
- package/dist/provider/rent-node.d.ts +101 -0
- package/dist/provider/rent-node.js +220 -0
- package/dist/provider/rent-node.js.map +1 -0
- package/dist/push-fanout.d.ts +8 -2
- package/dist/push-fanout.js +8 -2
- package/dist/push-fanout.js.map +1 -1
- package/dist/relay-addrs.d.ts +9 -4
- package/dist/relay-addrs.js +9 -4
- package/dist/relay-addrs.js.map +1 -1
- package/dist/relay-reservation.d.ts +51 -16
- package/dist/relay-reservation.js +107 -24
- package/dist/relay-reservation.js.map +1 -1
- package/dist/seed-bootstrap.d.ts +165 -123
- package/dist/seed-bootstrap.js +313 -275
- package/dist/seed-bootstrap.js.map +1 -1
- package/dist/seed-trust-policy.d.ts +98 -37
- package/dist/seed-trust-policy.js +188 -2
- package/dist/seed-trust-policy.js.map +1 -1
- package/dist/strand-addr-protocol.d.ts +24 -26
- package/dist/strand-addr-protocol.js +19 -26
- package/dist/strand-addr-protocol.js.map +1 -1
- package/dist/strand-commit-durability.d.ts +54 -0
- package/dist/strand-commit-durability.js +74 -0
- package/dist/strand-commit-durability.js.map +1 -0
- package/dist/strand-database.d.ts +23 -8
- package/dist/strand-database.js +41 -13
- package/dist/strand-database.js.map +1 -1
- package/dist/strand-first-sync-gate.d.ts +7 -1
- package/dist/strand-first-sync-gate.js +7 -1
- package/dist/strand-first-sync-gate.js.map +1 -1
- package/dist/strand-formation-protocol.js +5 -2
- package/dist/strand-formation-protocol.js.map +1 -1
- package/dist/strand-fret-addrs.d.ts +19 -1
- package/dist/strand-fret-addrs.js +27 -9
- package/dist/strand-fret-addrs.js.map +1 -1
- package/dist/strand-instance-manager.d.ts +81 -19
- package/dist/strand-instance-manager.js +216 -105
- package/dist/strand-instance-manager.js.map +1 -1
- package/dist/strand-move.d.ts +124 -0
- package/dist/strand-move.js +438 -0
- package/dist/strand-move.js.map +1 -0
- package/dist/strand-network-config.js +7 -6
- package/dist/strand-network-config.js.map +1 -1
- package/dist/strand-peer-redial.d.ts +113 -0
- package/dist/strand-peer-redial.js +236 -0
- package/dist/strand-peer-redial.js.map +1 -0
- package/dist/strand-revocation-enforcer.d.ts +11 -11
- package/dist/strand-revocation-enforcer.js +11 -11
- package/dist/strand-wake-protocol.d.ts +13 -16
- package/dist/strand-wake-protocol.js +23 -27
- package/dist/strand-wake-protocol.js.map +1 -1
- package/dist/trusted-owner-store.d.ts +35 -5
- package/dist/trusted-owner-store.js +50 -8
- package/dist/trusted-owner-store.js.map +1 -1
- package/dist/types.d.ts +512 -89
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -1
- package/package.json +19 -10
- package/src/cadre-invite-protocol.ts +1052 -0
- package/src/cadre-join-request.ts +167 -0
- package/src/cadre-node.ts +1703 -386
- package/src/claim-proof.ts +147 -0
- package/src/control-authorization.ts +203 -117
- package/src/control-cohort.ts +1 -1
- package/src/control-database.ts +4663 -3453
- package/src/control-protocol-guard.ts +348 -0
- package/src/control-schema.ts +828 -1078
- package/src/control-stream.ts +26 -7
- package/src/delegate-admission.ts +1 -1
- package/src/device-token.ts +14 -10
- package/src/ed25519-key.ts +47 -10
- package/src/fetch-impl.ts +23 -0
- package/src/file-durable-slot.ts +64 -63
- package/src/file-safe-name.ts +32 -0
- package/src/formation-approval.ts +604 -610
- package/src/fs-atomic.ts +92 -117
- package/src/index.ts +789 -648
- package/src/invitation-bootstrap.ts +91 -13
- package/src/joined-strand-store.ts +508 -498
- package/src/key-store-file.ts +142 -141
- package/src/link-budget.ts +25 -36
- package/src/machine-removal.ts +216 -0
- package/src/membership-connection-gater.ts +259 -191
- package/src/node-claim-payload.ts +259 -0
- package/src/node-default-transports.ts +38 -0
- package/src/node-transports.ts +49 -0
- package/src/owner-anchor-sync.ts +171 -0
- package/src/peer-authorization.ts +258 -29
- package/src/peer-dial.ts +604 -315
- package/src/peer-join-backfill.ts +62 -11
- package/src/peer-record.ts +159 -197
- package/src/pending-join-runner.ts +729 -735
- package/src/primary-lan-address.ts +47 -0
- package/src/provider/client.ts +326 -0
- package/src/provider/descriptor.ts +129 -0
- package/src/provider/index.ts +59 -0
- package/src/provider/oauth.ts +285 -0
- package/src/provider/rent-node.ts +275 -0
- package/src/push-fanout.ts +8 -2
- package/src/relay-addrs.ts +9 -4
- package/src/relay-reservation.ts +1211 -1121
- package/src/seed-bootstrap.ts +1502 -1448
- package/src/seed-trust-policy.ts +353 -140
- package/src/strand-addr-protocol.ts +26 -35
- package/src/strand-commit-durability.ts +116 -0
- package/src/strand-database.ts +46 -14
- package/src/strand-first-sync-gate.ts +7 -1
- package/src/strand-formation-protocol.ts +1039 -1036
- package/src/strand-fret-addrs.ts +179 -145
- package/src/strand-instance-manager.ts +2026 -1883
- package/src/strand-move.ts +585 -0
- package/src/strand-network-config.ts +7 -6
- package/src/strand-peer-redial.ts +307 -0
- package/src/strand-revocation-enforcer.ts +11 -11
- package/src/strand-wake-protocol.ts +23 -30
- package/src/trusted-owner-store.ts +242 -171
- package/src/types.ts +2687 -2242
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rent a node from a hosting provider and add it to this node's cadre, by whichever of the two
|
|
3
|
+
* join paths fits (`docs/architecture.md` → "Renting a node from an app"):
|
|
4
|
+
*
|
|
5
|
+
* - **invitation**, when the cadre has a member the container can reach from the provider's
|
|
6
|
+
* network (`CadreNode.invitationReach()` reads `anywhere`): mint a single-use, non-owner
|
|
7
|
+
* invitation and create the container with it; the container joins by itself and the app
|
|
8
|
+
* watches `getContainer(id).join`.
|
|
9
|
+
* - **claim**, otherwise (a phone that is the cadre's only member, or members reachable only on
|
|
10
|
+
* their LAN, which the provider's container is never on): create the container, poll for its
|
|
11
|
+
* node code, and claim it from this node.
|
|
12
|
+
*
|
|
13
|
+
* Nothing here persists anything: which container belongs to which cadre is the app's record,
|
|
14
|
+
* and {@link finishRental} is how an app resumes a rental it was killed in the middle of. The
|
|
15
|
+
* node code carries the claim secret, so neither the code nor the decoded payload is ever
|
|
16
|
+
* logged, only the container id and the peer id.
|
|
17
|
+
*/
|
|
18
|
+
import debug from 'debug';
|
|
19
|
+
import { decodeNodeClaimPayload } from '../node-claim-payload.js';
|
|
20
|
+
import { ProviderApiError } from './client.js';
|
|
21
|
+
const log = debug('sereus:cadre:provider-rent');
|
|
22
|
+
export class RentNodeError extends Error {
|
|
23
|
+
constructor(code, containerId) {
|
|
24
|
+
super(`rentNode: ${code}${containerId ? ` (container ${containerId})` : ''}`);
|
|
25
|
+
this.code = code;
|
|
26
|
+
this.containerId = containerId;
|
|
27
|
+
this.name = 'RentNodeError';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The provider's enrolment window is 60 s and an image pull can precede it. Bounds the
|
|
32
|
+
* container's start, not an exchange over the link, so it is not derived from the link budget.
|
|
33
|
+
*/
|
|
34
|
+
// eslint-disable-next-line no-restricted-syntax -- link-independent: bounds the container's start (an image pull plus the provider's 60 s enrolment window), not an exchange over the link
|
|
35
|
+
export const DEFAULT_NODE_CODE_DEADLINE_MS = 120000;
|
|
36
|
+
export const NODE_CODE_POLL_MS = 2000;
|
|
37
|
+
/** Lifetime of the invitation a rental mints: long enough for the container to start and redeem, short enough to limit a leaked bundle. */
|
|
38
|
+
export const RENTAL_INVITATION_TTL_MS = 15 * 60000;
|
|
39
|
+
/**
|
|
40
|
+
* Rent a node and add it to `node`'s cadre; see the module doc for the path choice.
|
|
41
|
+
*
|
|
42
|
+
* The claim path's `claimNode` can take up to the per-peer dial limit plus the seed request
|
|
43
|
+
* when no address answers (its doc: 114.5 s at the default link); no timeout is added on top
|
|
44
|
+
* of it, and `onProgress('claiming')` is the app's cue to show a slow hint. Two calls at once
|
|
45
|
+
* on one node both mint or both create; serializing them is the app's.
|
|
46
|
+
*
|
|
47
|
+
* @throws {RentNodeError} `not-an-owner`, or `node-not-ready` once the container exists.
|
|
48
|
+
* @throws {ProviderApiError} when the provider refused a request (a lapsed subscription is `403 QUOTA_EXCEEDED`).
|
|
49
|
+
* @throws {ClaimRefusedError} or {PeerUnreachableError} from `claimNode`, as it throws them.
|
|
50
|
+
*/
|
|
51
|
+
export async function rentNode(node, client, options = {}) {
|
|
52
|
+
await requireOwner(node);
|
|
53
|
+
const reach = await node.invitationReach();
|
|
54
|
+
log('renting a node for party %s; invitation reach %s → %s path', node.partyId, reach, reach === 'anywhere' ? 'invitation' : 'claim');
|
|
55
|
+
return reach === 'anywhere'
|
|
56
|
+
? await rentByInvitation(node, client, options)
|
|
57
|
+
: await rentByClaim(node, client, options);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Resume a rental: for an app that was killed mid-flow or hit the node-code deadline.
|
|
61
|
+
*
|
|
62
|
+
* - a `stopped` or `error` container → `RentNodeError('container-gone')`;
|
|
63
|
+
* - a claim container not yet claimed → the code, then `claimNode`, as {@link rentNode} would;
|
|
64
|
+
* - a claim container claimed into this cadre → done. The provider withholds the code once a
|
|
65
|
+
* claim is folded, so the claim is not re-run; one claimed by another cadre's owner →
|
|
66
|
+
* `RentNodeError('claimed-by-another')`;
|
|
67
|
+
* - an invitation container → done while `pending` or `accepted` (the app watches `join`), or
|
|
68
|
+
* the failed outcome, after which the app deletes the container and rents again (the claim
|
|
69
|
+
* path is chosen then if the member that answered is gone).
|
|
70
|
+
*/
|
|
71
|
+
export async function finishRental(node, client, containerId, options = {}) {
|
|
72
|
+
await requireOwner(node);
|
|
73
|
+
const report = await client.getContainer(containerId);
|
|
74
|
+
const kind = joinKindOf(report, containerId);
|
|
75
|
+
if (kind === 'claim') {
|
|
76
|
+
return await finishClaim(node, client, report, options);
|
|
77
|
+
}
|
|
78
|
+
const join = report.join;
|
|
79
|
+
if (join?.kind === 'invitation' && join.state === 'failed') {
|
|
80
|
+
return { containerId, outcome: 'failed', error: join.error, retryable: join.retryable };
|
|
81
|
+
}
|
|
82
|
+
return invitationResult(report.container);
|
|
83
|
+
}
|
|
84
|
+
async function requireOwner(node) {
|
|
85
|
+
if (!await node.isOwner())
|
|
86
|
+
throw new RentNodeError('not-an-owner');
|
|
87
|
+
}
|
|
88
|
+
async function rentByInvitation(node, client, options) {
|
|
89
|
+
report(options, 'inviting');
|
|
90
|
+
const { invitation, encoded } = await node.createCadreInvitation({ grantsOwner: false, uses: 1, expiresInMs: RENTAL_INVITATION_TTL_MS });
|
|
91
|
+
report(options, 'creating');
|
|
92
|
+
let container;
|
|
93
|
+
try {
|
|
94
|
+
container = await client.createContainer({ join: { kind: 'invitation', invitation: encoded }, profile: options.profile ?? 'storage' });
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
await withdrawQuietly(node, invitation.invite.key);
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
log('container %s created with an invitation; it joins by itself', container.id);
|
|
101
|
+
report(options, 'done');
|
|
102
|
+
return invitationResult(container);
|
|
103
|
+
}
|
|
104
|
+
/** A create that failed leaves no live invitation behind; a withdrawal that fails too is logged, and the create's error is what the caller sees. */
|
|
105
|
+
async function withdrawQuietly(node, key) {
|
|
106
|
+
try {
|
|
107
|
+
await node.withdrawCadreInvitation(key);
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
log('withdrawing invitation %s after a failed create failed too: %o', key, error);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async function rentByClaim(node, client, options) {
|
|
114
|
+
report(options, 'creating');
|
|
115
|
+
const container = await client.createContainer({ join: { kind: 'claim' }, profile: options.profile ?? 'storage' });
|
|
116
|
+
log('container %s created for a claim', container.id);
|
|
117
|
+
return await claimContainer(node, client, container.id, options);
|
|
118
|
+
}
|
|
119
|
+
/** Poll for the node code, then claim; the second half of the claim path, shared with {@link finishRental}. */
|
|
120
|
+
async function claimContainer(node, client, containerId, options) {
|
|
121
|
+
report(options, 'waiting-for-code');
|
|
122
|
+
const { code, peerId } = await awaitNodeCode(client, containerId, options);
|
|
123
|
+
report(options, 'claiming');
|
|
124
|
+
// The claim is the owner's signature; the app asked the user before calling.
|
|
125
|
+
await node.claimNode(decodeNodeClaimPayload(code));
|
|
126
|
+
log('container %s claimed; its node is %s', containerId, peerId);
|
|
127
|
+
report(options, 'done');
|
|
128
|
+
return { containerId, join: 'claim', peerId };
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* `getNodeCode` every poll interval until it answers or the deadline passes. A container that
|
|
132
|
+
* dies meanwhile (`409 CONTAINER_GONE`) is `container-gone`, the same code `finishRental` gives
|
|
133
|
+
* one found dead, so an app handles both at one site.
|
|
134
|
+
*/
|
|
135
|
+
async function awaitNodeCode(client, containerId, options) {
|
|
136
|
+
const deadline = Date.now() + (options.nodeCodeDeadlineMs ?? DEFAULT_NODE_CODE_DEADLINE_MS);
|
|
137
|
+
const poll = options.nodeCodePollMs ?? NODE_CODE_POLL_MS;
|
|
138
|
+
for (;;) {
|
|
139
|
+
const answer = await requestNodeCode(client, containerId);
|
|
140
|
+
if (!('notReady' in answer))
|
|
141
|
+
return answer;
|
|
142
|
+
if (Date.now() >= deadline) {
|
|
143
|
+
log('container %s has no node code by the deadline', containerId);
|
|
144
|
+
throw new RentNodeError('node-not-ready', containerId);
|
|
145
|
+
}
|
|
146
|
+
await sleep(poll);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
async function requestNodeCode(client, containerId) {
|
|
150
|
+
try {
|
|
151
|
+
return await client.getNodeCode(containerId);
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
if (error instanceof ProviderApiError && error.code === 'CONTAINER_GONE')
|
|
155
|
+
throw new RentNodeError('container-gone', containerId);
|
|
156
|
+
throw error;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
async function finishClaim(node, client, report, options) {
|
|
160
|
+
const { container, join } = report;
|
|
161
|
+
if (join?.kind === 'claim' && join.state === 'claimed')
|
|
162
|
+
return judgeClaimed(node, report);
|
|
163
|
+
try {
|
|
164
|
+
return await claimContainer(node, client, container.id, options);
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
// The node was claimed between the read and the code request; judge the fresh record.
|
|
168
|
+
if (error instanceof ProviderApiError && error.code === 'ALREADY_CLAIMED') {
|
|
169
|
+
return judgeClaimed(node, await client.getContainer(container.id));
|
|
170
|
+
}
|
|
171
|
+
throw error;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* A claimed container is this cadre's when the claim named this party.
|
|
176
|
+
*
|
|
177
|
+
* NOTE: the row `claimNode` writes after the node accepts is not re-run here, because the
|
|
178
|
+
* provider withholds the code once the claim is folded. An app killed between the node
|
|
179
|
+
* accepting and that one local insert has a node that belongs to this owner with no row for it
|
|
180
|
+
* on this machine, the window the React Native app's accepted tradeoff for cadre-host claims
|
|
181
|
+
* names; the remedy is to delete the container and rent again. Revisit if a device run sees it.
|
|
182
|
+
*/
|
|
183
|
+
function judgeClaimed(node, report) {
|
|
184
|
+
const { container, join } = report;
|
|
185
|
+
if (join?.kind !== 'claim' || join.state !== 'claimed')
|
|
186
|
+
throw new RentNodeError('container-gone', container.id);
|
|
187
|
+
if (join.partyId !== node.partyId) {
|
|
188
|
+
log('container %s was claimed into another party', container.id);
|
|
189
|
+
throw new RentNodeError('claimed-by-another', container.id);
|
|
190
|
+
}
|
|
191
|
+
return { containerId: container.id, join: 'claim', ...(container.peerId ? { peerId: container.peerId } : {}) };
|
|
192
|
+
}
|
|
193
|
+
/** Which path a container is on; refuses one that is gone or was never a rental. */
|
|
194
|
+
function joinKindOf(report, containerId) {
|
|
195
|
+
const { container, join } = report;
|
|
196
|
+
if (container.status === 'stopped' || container.status === 'error')
|
|
197
|
+
throw new RentNodeError('container-gone', containerId);
|
|
198
|
+
// The join state is folded from the node's first `/status` read, so a container still
|
|
199
|
+
// starting carries only the kind it was created with.
|
|
200
|
+
const kind = join?.kind ?? container.join?.kind;
|
|
201
|
+
if (kind === undefined)
|
|
202
|
+
throw new RentNodeError('not-a-rental', containerId);
|
|
203
|
+
return kind;
|
|
204
|
+
}
|
|
205
|
+
function invitationResult(container) {
|
|
206
|
+
return { containerId: container.id, join: 'invitation', ...(container.peerId ? { peerId: container.peerId } : {}) };
|
|
207
|
+
}
|
|
208
|
+
function report(options, step) {
|
|
209
|
+
try {
|
|
210
|
+
options.onProgress?.(step);
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
log('onProgress(%s) threw; ignored: %o', step, error);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
function sleep(ms) {
|
|
217
|
+
// A plain timer, not an unref'd one: a Node process renting from a script must stay up for it.
|
|
218
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=rent-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rent-node.js","sourceRoot":"","sources":["../../src/provider/rent-node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAyD,MAAM,aAAa,CAAC;AAEtG,MAAM,GAAG,GAAG,K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AAE,CAAC;AACrH,CAAC;AAED,SAAS,MAAM,CAAC,OAAwB,EAAE,IAAkB;IAC3D,IAAI,CAAC;QACJ,OAAO,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,GAAG,CAAC,mCAAmC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACvD,CAAC;AACF,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACxB,+FAA+F;IAC/F,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC1D,CAAC"}
|
package/dist/push-fanout.d.ts
CHANGED
|
@@ -117,12 +117,18 @@ export declare class PushFanoutService {
|
|
|
117
117
|
* to a platform push only when the dial cannot reach the (suspended) peer.
|
|
118
118
|
*
|
|
119
119
|
* A resolved {@link WakeAck} means the control path REACHED the peer — even an
|
|
120
|
-
* ack with `accepted:false` (the receiver declined, e.g.
|
|
121
|
-
*
|
|
120
|
+
* ack with `accepted:false` (the receiver declined, e.g. an unknown strand)
|
|
121
|
+
* counts as reached, so we do NOT also send a platform push (that would
|
|
122
122
|
* double-wake). Only a dial/transport REJECTION means the phone is suspended
|
|
123
123
|
* and unreachable over the control network, which is the one case that falls
|
|
124
124
|
* through to FCM/APNs.
|
|
125
125
|
*
|
|
126
|
+
* A receiver that does not yet count this node as an authorized member (its copy
|
|
127
|
+
* of our `CadrePeer` row has not replicated) resets the wake stream in its protocol
|
|
128
|
+
* guard without replying, which reads here as a rejection, so that peer gets the
|
|
129
|
+
* platform push. Deliberate: the reset carries nothing that would tell it apart
|
|
130
|
+
* from a transport fault, and the platform push wakes the peer by its own path.
|
|
131
|
+
*
|
|
126
132
|
* NOTE: the platform push waits for the whole direct dial to fail, up to
|
|
127
133
|
* `DEFAULT_WAKE_DIAL_BUDGET_MS` (57 s at the default declared link). A suspended
|
|
128
134
|
* phone typically fails its relay address fast and spends the rest on its direct
|
package/dist/push-fanout.js
CHANGED
|
@@ -127,12 +127,18 @@ export class PushFanoutService {
|
|
|
127
127
|
* to a platform push only when the dial cannot reach the (suspended) peer.
|
|
128
128
|
*
|
|
129
129
|
* A resolved {@link WakeAck} means the control path REACHED the peer — even an
|
|
130
|
-
* ack with `accepted:false` (the receiver declined, e.g.
|
|
131
|
-
*
|
|
130
|
+
* ack with `accepted:false` (the receiver declined, e.g. an unknown strand)
|
|
131
|
+
* counts as reached, so we do NOT also send a platform push (that would
|
|
132
132
|
* double-wake). Only a dial/transport REJECTION means the phone is suspended
|
|
133
133
|
* and unreachable over the control network, which is the one case that falls
|
|
134
134
|
* through to FCM/APNs.
|
|
135
135
|
*
|
|
136
|
+
* A receiver that does not yet count this node as an authorized member (its copy
|
|
137
|
+
* of our `CadrePeer` row has not replicated) resets the wake stream in its protocol
|
|
138
|
+
* guard without replying, which reads here as a rejection, so that peer gets the
|
|
139
|
+
* platform push. Deliberate: the reset carries nothing that would tell it apart
|
|
140
|
+
* from a transport fault, and the platform push wakes the peer by its own path.
|
|
141
|
+
*
|
|
136
142
|
* NOTE: the platform push waits for the whole direct dial to fail, up to
|
|
137
143
|
* `DEFAULT_WAKE_DIAL_BUDGET_MS` (57 s at the default declared link). A suspended
|
|
138
144
|
* phone typically fails its relay address fast and spends the rest on its direct
|
package/dist/push-fanout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push-fanout.js","sourceRoot":"","sources":["../src/push-fanout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,MAAM,GAAG,GAAG,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAE9C,8DAA8D;AAC9D,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,GAAG,KAAM,CA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E,CAAC;CACF;AAED,+DAA+D;AAC/D,SAAS,WAAW,CAAC,MAAc,EAAE,QAAgB;IACnD,OAAO,GAAG,MAAM,IAAI,QAAQ,EAAE,CAAC;AACjC,CAAC"}
|
package/dist/relay-addrs.d.ts
CHANGED
|
@@ -50,7 +50,10 @@
|
|
|
50
50
|
* only once the relay-hop protocol id is in that peer's peer-store protocol list,
|
|
51
51
|
* and that list is written exclusively by IDENTIFY — which `@optimystic/db-p2p`
|
|
52
52
|
* namespaces per network, so a cadre node and a stock relay never identify each
|
|
53
|
-
* other.
|
|
53
|
+
* other. A node with configured relays is built with that discovery switched off
|
|
54
|
+
* altogether when it has a transport list to wrap (`node-transports.ts`), because it
|
|
55
|
+
* CAN reach a relay-capable peer in its own namespace and take the configured relay's
|
|
56
|
+
* slot. See `relay-reservation.ts`'s module doc and `docs/architecture.md`.
|
|
54
57
|
*/
|
|
55
58
|
import type { NetworkConfig } from './types.js';
|
|
56
59
|
import type { RelayReservationState } from './relay-reservation.js';
|
|
@@ -136,9 +139,11 @@ export interface ListenTransportOptions {
|
|
|
136
139
|
*
|
|
137
140
|
* - **WebSocket is DERIVED.** It is the one non-TCP transport the shipped configs need
|
|
138
141
|
* (the React Native reference app's companion drone; `cadre start --ws-port`), and
|
|
139
|
-
* `@optimystic/db-p2p` already knows how to add it
|
|
140
|
-
*
|
|
141
|
-
* (
|
|
142
|
+
* `@optimystic/db-p2p` already knows how to add it, so `cadre-core` flips db-p2p's own
|
|
143
|
+
* switch ({@link WS_TRANSPORT_SWITCH_PORT}). A node with configured relays is the one
|
|
144
|
+
* case where cadre passes the transport list itself (`node-transports.ts`, to switch
|
|
145
|
+
* relay discovery off); when the embedder gave none, that list comes from
|
|
146
|
+
* `network.defaultTransports`, which reads the same switch.
|
|
142
147
|
* - **Everything else is REFUSED.** Deriving `/quic-v1`, `/webrtc` or `/webtransport`
|
|
143
148
|
* would mean importing transport packages into every `cadre-core` consumer including
|
|
144
149
|
* the React Native and browser bundles (against the cross-platform rule in
|
package/dist/relay-addrs.js
CHANGED
|
@@ -50,7 +50,10 @@
|
|
|
50
50
|
* only once the relay-hop protocol id is in that peer's peer-store protocol list,
|
|
51
51
|
* and that list is written exclusively by IDENTIFY — which `@optimystic/db-p2p`
|
|
52
52
|
* namespaces per network, so a cadre node and a stock relay never identify each
|
|
53
|
-
* other.
|
|
53
|
+
* other. A node with configured relays is built with that discovery switched off
|
|
54
|
+
* altogether when it has a transport list to wrap (`node-transports.ts`), because it
|
|
55
|
+
* CAN reach a relay-capable peer in its own namespace and take the configured relay's
|
|
56
|
+
* slot. See `relay-reservation.ts`'s module doc and `docs/architecture.md`.
|
|
54
57
|
*/
|
|
55
58
|
import { multiaddr } from '@multiformats/multiaddr';
|
|
56
59
|
import { circuitRelayTargetOrThrow } from './delegate-admission.js';
|
|
@@ -169,9 +172,11 @@ const WS_TRANSPORT_SWITCH_PORT = 0;
|
|
|
169
172
|
*
|
|
170
173
|
* - **WebSocket is DERIVED.** It is the one non-TCP transport the shipped configs need
|
|
171
174
|
* (the React Native reference app's companion drone; `cadre start --ws-port`), and
|
|
172
|
-
* `@optimystic/db-p2p` already knows how to add it
|
|
173
|
-
*
|
|
174
|
-
* (
|
|
175
|
+
* `@optimystic/db-p2p` already knows how to add it, so `cadre-core` flips db-p2p's own
|
|
176
|
+
* switch ({@link WS_TRANSPORT_SWITCH_PORT}). A node with configured relays is the one
|
|
177
|
+
* case where cadre passes the transport list itself (`node-transports.ts`, to switch
|
|
178
|
+
* relay discovery off); when the embedder gave none, that list comes from
|
|
179
|
+
* `network.defaultTransports`, which reads the same switch.
|
|
175
180
|
* - **Everything else is REFUSED.** Deriving `/quic-v1`, `/webrtc` or `/webtransport`
|
|
176
181
|
* would mean importing transport packages into every `cadre-core` consumer including
|
|
177
182
|
* the React Native and browser bundles (against the cross-platform rule in
|
package/dist/relay-addrs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relay-addrs.js","sourceRoot":"","sources":["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UAAU,CAAC,CAAC,CAAC,6BAA6B;IACtE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,4FAA4F,SAAS,EAAE,EACvG,EAAE,KAAK,EAAE,GAAG,EAAE,CACf,CAAC;IACJ,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,2FAA2F;AAC3F,SAAS,eAAe,CAAC,SAAiB;IACxC,IAAI,CAAC;QACH,OAAO,SAAS,CAAC,SAAS,CAAC,CAAC,aAAa,EAAE,CAAC;IAC9C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,sDAAsD,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;IACrG,CAAC;AACH,CAAC;AAED,yFAAyF;AACzF,SAAS,MAAM,CAAC,KAAwB;IACtC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -73,12 +73,33 @@
|
|
|
73
73
|
* relay's address. So it asks the relay for a slot directly, via the
|
|
74
74
|
* circuit-relay transport's own reservation store.
|
|
75
75
|
*
|
|
76
|
+
* ⚠️ WHY LIBP2P'S RELAY DISCOVERY IS SWITCHED OFF. Discovery does reach SOME
|
|
77
|
+
* peers: every connected peer whose identify lists the relay-hop protocol, and a
|
|
78
|
+
* storage-profile member's strand node runs the relay server in the same
|
|
79
|
+
* `/optimystic/strand-<id>/…` namespace as this node's strand node (control nodes
|
|
80
|
+
* share `/optimystic/control-<partyId>/…` the same way). Discovery reserves on such
|
|
81
|
+
* a peer as soon as it connects, and that takes one of the slots the configured
|
|
82
|
+
* relays' supervisors were going to fill. Worse, the reservation store runs one
|
|
83
|
+
* request at a time and, when a request takes the last free slot, clears its queue
|
|
84
|
+
* with `@libp2p/utils`' `Queue.clear()`, which drops a queued job WITHOUT ever
|
|
85
|
+
* settling its promise — so a supervisor whose `addRelay` was queued behind it
|
|
86
|
+
* waits out its whole deadline (gotchoices/sereus#34). A reservation discovery picks is
|
|
87
|
+
* also unmanaged: no supervisor re-drives it, the status does not count it, and a
|
|
88
|
+
* member's strand node goes away whenever that member hibernates. So every node
|
|
89
|
+
* whose bare search entries cadre generated for configured relays is built through
|
|
90
|
+
* {@link withoutRelayDiscovery} (`node-transports.ts`), and its slots are filled by
|
|
91
|
+
* the supervisors alone — given a transport list to wrap, which React Native and
|
|
92
|
+
* browser embedders always pass and a Node host passes as
|
|
93
|
+
* `network.defaultTransports` (cadre-cli does). A hand-written bare `/p2p-circuit`
|
|
94
|
+
* with no configured relay keeps discovery, since nothing else would fill that slot.
|
|
95
|
+
*
|
|
76
96
|
* Status is derived from the node's LIVE multiaddrs on every read rather than
|
|
77
97
|
* cached at drive time: when a relay restarts or the connection drops, libp2p's
|
|
78
98
|
* listener clears its listening addrs and the circuit multiaddr disappears, so a
|
|
79
99
|
* cached snapshot would keep claiming `reserved` for a node nothing can dial.
|
|
80
100
|
*
|
|
81
|
-
* And because discovery is
|
|
101
|
+
* And because discovery is either off or blind to the relay, nothing would ever
|
|
102
|
+
* ASK again either —
|
|
82
103
|
* so {@link driveRelayReservation} stays a single-shot primitive and
|
|
83
104
|
* {@link superviseRelayReservation} owns the retry cadence on top of it. That
|
|
84
105
|
* loop is what makes a lost reservation recover without a page reload. Single-shot
|
|
@@ -87,20 +108,20 @@
|
|
|
87
108
|
* logs failures that read as real and — through the timers it still holds — keeps
|
|
88
109
|
* the process alive for the rest of its `timeoutMs`.
|
|
89
110
|
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* mechanisms in production, one guarantee; the specs disable discovery's half
|
|
111
|
+
* What switching discovery off costs: libp2p 3.1.3's `connection.newStream` records
|
|
112
|
+
* every protocol OUR OWN outbound stream negotiated into the peer store, so the
|
|
113
|
+
* explicit reservation request writes the relay-hop protocol id against the relay
|
|
114
|
+
* itself, and with discovery on it refilled a slot freed by a hangup (while the
|
|
115
|
+
* relay stays up) within ~25 ms, measured. With it off that refill waits for the
|
|
116
|
+
* supervisor's next liveness check ({@link DEFAULT_RELAY_CHECK_MS}, 5 s while held).
|
|
117
|
+
* A relay RESTART always needed the supervisor, which un-poisons the store's
|
|
118
|
+
* `relayFilter` before every attempt ({@link clearRelayFilterEntry}). The specs
|
|
119
|
+
* that build their own clients keep discovery on and disable its refill
|
|
100
120
|
* (`forgetRelayProtocol` in `relay-reservation.spec.ts`) so they prove the
|
|
101
121
|
* supervisor's.
|
|
102
122
|
*/
|
|
103
123
|
import type { Libp2p, PeerId } from '@libp2p/interface';
|
|
124
|
+
import type { Libp2pTransports } from '@optimystic/db-p2p';
|
|
104
125
|
/**
|
|
105
126
|
* Relay-reservation posture for a node that reserves through the SEARCH listen
|
|
106
127
|
* addr (bare `/p2p-circuit`) — every cadre control node, whether its relays came
|
|
@@ -232,6 +253,19 @@ export declare function circuitMultiaddrsVia(node: Libp2p, addrs: readonly strin
|
|
|
232
253
|
* module to the discovery wait that never fires.
|
|
233
254
|
*/
|
|
234
255
|
export declare function findCircuitRelayTransport(node: Libp2p): CircuitRelayTransportLike | null;
|
|
256
|
+
/**
|
|
257
|
+
* `transports` with libp2p's relay discovery switched off in the circuit-relay transport any of
|
|
258
|
+
* them builds, for a node whose bare `/p2p-circuit` slots cadre's own supervisors fill (see the
|
|
259
|
+
* module header, "WHY LIBP2P'S RELAY DISCOVERY IS SWITCHED OFF"). Every other transport is built
|
|
260
|
+
* untouched.
|
|
261
|
+
*
|
|
262
|
+
* Each factory is wrapped rather than the built node patched afterwards: libp2p calls the
|
|
263
|
+
* factories in its constructor, and `@optimystic/db-p2p` builds with `start: false`, so the
|
|
264
|
+
* switch lands before anything starts. Patching the running node instead races — db-p2p starts
|
|
265
|
+
* the node before `createLibp2pNode` returns, and a cohort-seed connection in that window has
|
|
266
|
+
* already queued a discovered reservation.
|
|
267
|
+
*/
|
|
268
|
+
export declare function withoutRelayDiscovery(transports: Libp2pTransports): Libp2pTransports;
|
|
235
269
|
/**
|
|
236
270
|
* Dial every relay in `addrs`, ask the first one that answers for a reservation
|
|
237
271
|
* slot, then wait until a `/p2p-circuit` address appears.
|
|
@@ -317,8 +351,9 @@ export interface RelayReservationSupervisor {
|
|
|
317
351
|
* it still is — the thing that makes a lost reservation recover on its own.
|
|
318
352
|
*
|
|
319
353
|
* Needed because nothing else re-drives: libp2p re-fills a search listener's
|
|
320
|
-
* freed slot from relay DISCOVERY,
|
|
321
|
-
*
|
|
354
|
+
* freed slot from relay DISCOVERY, which cannot see a stock-identify relay from a
|
|
355
|
+
* cadre node's namespaced identify, and which is switched off outright on every
|
|
356
|
+
* node whose slots cadre supervises (see the module header). Without this loop a
|
|
322
357
|
* relay restart left a browser tab undialable until the user reloaded the page.
|
|
323
358
|
*
|
|
324
359
|
* Per tick:
|
|
@@ -378,9 +413,9 @@ export declare function clearRelayFilterEntry(store: RelayReservationStoreLike,
|
|
|
378
413
|
* NOBODY IS GOING TO TRY AGAIN. A lost reservation does come back on its own now,
|
|
379
414
|
* as long as a {@link RelayReservationSupervisor} is running — that loop is the
|
|
380
415
|
* only thing that re-drives, since libp2p re-fills a search listener's freed slot
|
|
381
|
-
* from relay DISCOVERY, which a
|
|
382
|
-
*
|
|
383
|
-
* stopped, was never started, or there is no node at all.
|
|
416
|
+
* from relay DISCOVERY, which cannot see a stock-identify relay and is switched off
|
|
417
|
+
* on every node cadre supervises (see the module header). So `error` means the
|
|
418
|
+
* supervisor was stopped, was never started, or there is no node at all.
|
|
384
419
|
*
|
|
385
420
|
* `retryAtMs` is the supervisor's next scheduled tick (`null` while a drive runs
|
|
386
421
|
* or when there is no supervisor); it both selects `retrying` and is passed
|