@serfab/cadre-core 1.14.0 → 1.16.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 +64 -29
- package/dist/cadre-invite-protocol.js +207 -38
- package/dist/cadre-invite-protocol.js.map +1 -1
- 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 +375 -79
- package/dist/cadre-node.js +758 -186
- package/dist/cadre-node.js.map +1 -1
- package/dist/control-database.d.ts +92 -12
- package/dist/control-database.js +323 -142
- package/dist/control-database.js.map +1 -1
- package/dist/control-schema.d.ts +1 -1
- package/dist/control-schema.js +19 -3
- package/dist/control-schema.js.map +1 -1
- package/dist/ed25519-key.d.ts +7 -9
- package/dist/ed25519-key.js +20 -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 +12 -5
- package/dist/index.js +31 -6
- 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 +9 -4
- package/dist/link-budget.js +9 -4
- 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 +6 -5
- package/dist/membership-connection-gater.js +6 -5
- package/dist/membership-connection-gater.js.map +1 -1
- package/dist/node-claim-payload.d.ts +55 -0
- package/dist/node-claim-payload.js +108 -4
- package/dist/node-claim-payload.js.map +1 -1
- 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/peer-dial.d.ts +124 -27
- package/dist/peer-dial.js +254 -30
- package/dist/peer-dial.js.map +1 -1
- package/dist/peer-join-backfill.js +6 -0
- package/dist/peer-join-backfill.js.map +1 -1
- package/dist/peer-record.d.ts +6 -45
- package/dist/peer-record.js +8 -50
- package/dist/peer-record.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/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 +22 -5
- package/dist/seed-bootstrap.js +48 -25
- package/dist/seed-bootstrap.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 +4 -1
- 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-wake-protocol.js +10 -7
- package/dist/strand-wake-protocol.js.map +1 -1
- package/dist/types.d.ts +212 -4
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -1
- package/package.json +18 -10
- package/src/cadre-invite-protocol.ts +1052 -864
- package/src/cadre-join-request.ts +167 -0
- package/src/cadre-node.ts +10003 -9381
- package/src/control-database.ts +4663 -4451
- package/src/control-schema.ts +19 -3
- package/src/ed25519-key.ts +20 -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 +71 -4
- 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 +9 -4
- package/src/machine-removal.ts +216 -0
- package/src/membership-connection-gater.ts +638 -637
- package/src/node-claim-payload.ts +138 -4
- package/src/node-default-transports.ts +38 -0
- package/src/node-transports.ts +49 -0
- package/src/peer-dial.ts +604 -336
- package/src/peer-join-backfill.ts +6 -0
- package/src/peer-record.ts +159 -202
- 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/relay-addrs.ts +9 -4
- package/src/relay-reservation.ts +1211 -1121
- package/src/seed-bootstrap.ts +1502 -1471
- 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-wake-protocol.ts +10 -7
- package/src/types.ts +220 -4
|
@@ -2,6 +2,7 @@ import debug from 'debug';
|
|
|
2
2
|
import { concat as uint8ArrayConcat, fromString as uint8ArrayFromString, toString as uint8ArrayToString } from 'uint8arrays';
|
|
3
3
|
import { sign, verify } from '@optimystic/quereus-plugin-crypto';
|
|
4
4
|
import { formationVouchMessage } from './control-database.js';
|
|
5
|
+
import { resolveFetch as resolveFetchImpl } from './fetch-impl.js';
|
|
5
6
|
const log = debug('sereus:cadre:formation-approval');
|
|
6
7
|
/**
|
|
7
8
|
* Abort an unanswered approval request after this long when no `timeoutMs` is supplied.
|
|
@@ -102,20 +103,13 @@ function parseHookUrl(validationUrl) {
|
|
|
102
103
|
}
|
|
103
104
|
return url;
|
|
104
105
|
}
|
|
105
|
-
/**
|
|
106
|
-
* The `fetch` this approver will call: the injected one, else the global.
|
|
107
|
-
*
|
|
108
|
-
* Bound to `globalThis` because an unbound global `fetch` is an illegal invocation in browsers
|
|
109
|
-
* (and in any runtime whose `fetch` is a branded method rather than a plain function).
|
|
110
|
-
*/
|
|
106
|
+
/** The `fetch` this approver will call (`fetch-impl.ts`); none at all is a misconfiguration. */
|
|
111
107
|
function resolveFetch(fetchImpl) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
if (typeof globalThis.fetch !== 'function') {
|
|
108
|
+
const resolved = resolveFetchImpl(fetchImpl);
|
|
109
|
+
if (!resolved) {
|
|
116
110
|
throw new FormationApprovalError('misconfigured', 'No fetch implementation: globalThis.fetch is missing and no fetchImpl was supplied');
|
|
117
111
|
}
|
|
118
|
-
return
|
|
112
|
+
return resolved;
|
|
119
113
|
}
|
|
120
114
|
/**
|
|
121
115
|
* Read the response body as text, refusing anything over {@link MAX_RESPONSE_BYTES}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formation-approval.js","sourceRoot":"","sources":["../src/formation-approval.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,MAAM,IAAI,gBAAgB,EAC1B,UAAU,IAAI,oBAAoB,EAClC,QAAQ,IAAI,kBAAkB,EAC/B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"formation-approval.js","sourceRoot":"","sources":["../src/formation-approval.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,MAAM,IAAI,gBAAgB,EAC1B,UAAU,IAAI,oBAAoB,EAClC,QAAQ,IAAI,kBAAkB,EAC/B,MAAM,aAAa,CAAC;AACrB,O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O,QAAQ,CAAC;YAClB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,sFAAsF;gBACtF,yFAAyF;gBACzF,IAAI,KAAK,YAAY,sBAAsB,EAAE,CAAC;oBAC5C,MAAM,KAAK,CAAC;gBACd,CAAC;gBACD,MAAM,IAAI,sBAAsB,CAC9B,aAAa,EACb,iBAAiB,MAAM,uBAAuB,EAC9C,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;YACJ,CAAC;oBAAS,CAAC;gBACT,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/fs-atomic.d.ts
CHANGED
|
@@ -1,25 +1,6 @@
|
|
|
1
1
|
/** Best-effort POSIX permissions (ignored on Windows / unsupported FSes). */
|
|
2
2
|
export declare const DIR_MODE = 448;
|
|
3
3
|
export declare const FILE_MODE = 384;
|
|
4
|
-
/**
|
|
5
|
-
* Percent-encode a string into a filesystem-safe filename component. Beyond
|
|
6
|
-
* `encodeURIComponent` (which already escapes `/`, spaces, and unicode), this
|
|
7
|
-
* also escapes the unreserved characters `encodeURIComponent` leaves intact but
|
|
8
|
-
* that are unsafe in filenames on some platforms (notably `*` on Windows) — and
|
|
9
|
-
* `.`, so a file suffix appended by the caller is the only literal dot, making
|
|
10
|
-
* suffix-stripping unambiguous — and every uppercase letter, because Windows
|
|
11
|
-
* (NTFS) and macOS (APFS/HFS+ by default) ignore case in file names. Reversed by
|
|
12
|
-
* `decodeURIComponent`.
|
|
13
|
-
*
|
|
14
|
-
* The result contains only `a-z0-9-_` and `%XX` escapes (uppercase hex). Since a
|
|
15
|
-
* literal `%` is itself escaped, every `%` starts an escape, so ignoring case
|
|
16
|
-
* can change only escape hex digits — which decode case-insensitively — and two
|
|
17
|
-
* different inputs never yield names equal ignoring case. The escapes keep
|
|
18
|
-
* `encodeURIComponent`'s uppercase hex so a name built from an id with no
|
|
19
|
-
* capital letters (the identity slot `cadre%2Fidentity.key`, a lowercase party
|
|
20
|
-
* id) is the same as before uppercase letters were escaped.
|
|
21
|
-
*/
|
|
22
|
-
export declare function encodeFileSafeComponent(component: string): string;
|
|
23
4
|
/** Whether an unknown error is a Node "file/dir not found" (ENOENT). */
|
|
24
5
|
export declare function isNotFound(error: unknown): boolean;
|
|
25
6
|
/**
|
package/dist/fs-atomic.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Node-only filesystem helpers: atomic file write
|
|
3
|
-
*
|
|
2
|
+
* Node-only filesystem helpers: atomic file write and the ENOENT check, shared
|
|
3
|
+
* by `key-store-file.ts` and `file-durable-slot.ts`. The filename-safe encoding
|
|
4
|
+
* they also use is cross-platform and lives in `file-safe-name.ts`.
|
|
4
5
|
*
|
|
5
6
|
* This module imports `node:fs/promises`, so — like its consumers — it is kept
|
|
6
7
|
* OUT of the package's cross-platform default entry and is not itself an
|
|
@@ -12,28 +13,6 @@ const log = debug('sereus:cadre:fs-atomic');
|
|
|
12
13
|
/** Best-effort POSIX permissions (ignored on Windows / unsupported FSes). */
|
|
13
14
|
export const DIR_MODE = 0o700;
|
|
14
15
|
export const FILE_MODE = 0o600;
|
|
15
|
-
/**
|
|
16
|
-
* Percent-encode a string into a filesystem-safe filename component. Beyond
|
|
17
|
-
* `encodeURIComponent` (which already escapes `/`, spaces, and unicode), this
|
|
18
|
-
* also escapes the unreserved characters `encodeURIComponent` leaves intact but
|
|
19
|
-
* that are unsafe in filenames on some platforms (notably `*` on Windows) — and
|
|
20
|
-
* `.`, so a file suffix appended by the caller is the only literal dot, making
|
|
21
|
-
* suffix-stripping unambiguous — and every uppercase letter, because Windows
|
|
22
|
-
* (NTFS) and macOS (APFS/HFS+ by default) ignore case in file names. Reversed by
|
|
23
|
-
* `decodeURIComponent`.
|
|
24
|
-
*
|
|
25
|
-
* The result contains only `a-z0-9-_` and `%XX` escapes (uppercase hex). Since a
|
|
26
|
-
* literal `%` is itself escaped, every `%` starts an escape, so ignoring case
|
|
27
|
-
* can change only escape hex digits — which decode case-insensitively — and two
|
|
28
|
-
* different inputs never yield names equal ignoring case. The escapes keep
|
|
29
|
-
* `encodeURIComponent`'s uppercase hex so a name built from an id with no
|
|
30
|
-
* capital letters (the identity slot `cadre%2Fidentity.key`, a lowercase party
|
|
31
|
-
* id) is the same as before uppercase letters were escaped.
|
|
32
|
-
*/
|
|
33
|
-
export function encodeFileSafeComponent(component) {
|
|
34
|
-
// NOTE: a file left from before uppercase letters were escaped (`trusted-owners.Alice.json`) has, ignoring case, the new name of the all-lowercase id (`alice`), so on Windows/macOS a lookup for that id opens it; the per-party records' envelope party-id check rejects it (cold start), and `FileKeyStore` needs two parties in one key directory whose ids fold to the same lowercase string. The release note says to delete old files; if a store ever reads another id's old file in practice, rename or remove old-format files when the store opens.
|
|
35
|
-
return encodeURIComponent(component).replace(/(%[0-9A-F]{2})|[!'()*~.A-Z]/g, (c, escape) => escape ?? `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
36
|
-
}
|
|
37
16
|
/** Whether an unknown error is a Node "file/dir not found" (ENOENT). */
|
|
38
17
|
export function isNotFound(error) {
|
|
39
18
|
return typeof error === 'object' && error !== null
|
package/dist/fs-atomic.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs-atomic.js","sourceRoot":"","sources":["../src/fs-atomic.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"fs-atomic.js","sourceRoot":"","sources":["../src/fs-atomic.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAG3D,MAAM,GAAG,GAAG,KAAK,CAAC,wBAAwB,CAAC,CAAC;AAE5C,6EAA6E;AAC7E,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAC;AAC9B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,GAAW;IAC3C,IAAI,SAAiC,CAAC;IACtC,IAAI,CAAC;QACJ,SAAS,GAAG,MAAM,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACjC,MAAM,SAAS,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,GAAG,CAAC,oCAAoC,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IACvD,CAAC;YAAS,CAAC;QACV,MAAM,SAAS,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC1C,CAAC;AACF,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
export * from './types.js';
|
|
2
2
|
export { canonicalJson } from './canonical-json.js';
|
|
3
3
|
export { CadreNode, OWNER_INVITATION_DEFAULT_TTL_MS, CADRE_INVITATION_DEFAULT_TTL_MS } from './cadre-node.js';
|
|
4
|
-
export {
|
|
4
|
+
export { MachineRemovalRefusedError } from './machine-removal.js';
|
|
5
|
+
export { ControlDatabase, parseNullableStoredDatetimeMs, MissingHostStrandError, InvitationExhaustedError, CadreInviteIssuerUnknownError, buildAuthorizationMessage, registerPartyIdFunction, formationVouchMessage, formationConsentMessage, cadreInviteAddMessage, cadreInviteRedeemMessage, cadreInviteConsentMessage, projectSeedPeers, REAPABLE_TABLES, type ReapableTable, type ControlDatabaseConfig, type ControlTable, type RevocableTable, type FormationUsageResult, type FormationInviteRow, type MembershipChangeListener, type GuardedDeleteListener, type ControlWriteAbandonedListener, type RevokedRowRef, type MachineRemovalWrites } from './control-database.js';
|
|
5
6
|
export { CONTROL_WRITE_ATTEMPTS, CONTROL_WRITE_RETRY_BUDGET_MS, SCHEMA_INIT_ATTEMPTS, SCHEMA_INIT_RETRY_POLICY, isRetriableControlWriteFailure, isRetriableSchemaInitFailure, retryControlWrite, type ControlWriteRetryOptions } from './control-write-retry.js';
|
|
6
7
|
export { CONTROL_READ_ATTEMPTS, CONTROL_READ_RETRY_DELAYS_MS, CONTROL_READ_RETRY_BUDGET_MS, isRetriableControlReadFailure, retryControlRead, type ControlReadRetryOptions } from './control-read-retry.js';
|
|
7
8
|
export type { ControlRetryAbandonment, ControlRetryAbandonReason, ControlRetryAbandonListener } from './control-retry.js';
|
|
8
9
|
export { controlAuthorizationFields, unboundAuthorizationFields, cadreInviteRowFields, type ControlDomain, type BoundControlDomain, type UnboundControlDomain, type ControlAction, type CadreInviteSignedFields } from './control-authorization.js';
|
|
9
10
|
export { ed25519KeyPairFromLibp2p, ed25519PublicKeyFromPrivate, ed25519PublicKeyB64FromPeerId, requireEd25519PublicKeyB64, type Ed25519KeyPair } from './ed25519-key.js';
|
|
10
11
|
export { InMemoryKeyStore, KeyStoreAccessError, DEFAULT_IDENTITY_KEY_ID, type KeyStore, type KeyId } from './key-store.js';
|
|
12
|
+
export { encodeFileSafeComponent } from './file-safe-name.js';
|
|
11
13
|
export { loadOrCreateIdentityKey } from './identity-key.js';
|
|
12
14
|
export { MemoryTrustedOwnerStore, PersistentTrustedOwnerStore, type TrustedOwnerStore, type TrustSource } from './trusted-owner-store.js';
|
|
13
15
|
export type { DurableSlot } from './node-local-snapshot.js';
|
|
@@ -18,6 +20,7 @@ export { MemoryStrandNetworkStateStore, PersistentStrandNetworkStateStore, stran
|
|
|
18
20
|
export { strandFretPeerAddrs, type FretAddrHost, type FretPeerAddrs } from './strand-fret-addrs.js';
|
|
19
21
|
export { controlStorageScope, isControlStorageScope, isValidStrandScopeKey, assertStrandScopeKey, InvalidStrandIdError } from './storage-scope.js';
|
|
20
22
|
export { StrandDatabase, type StrandDatabaseConfig } from './strand-database.js';
|
|
23
|
+
export type { StrandCommitDurability, StrandCommitHeld } from './strand-commit-durability.js';
|
|
21
24
|
export { StrandWatcher, type StrandWatcherCallbacks, type StrandQueryable, type SAppIdLookup, type StrandRowWithApp } from './strand-watcher.js';
|
|
22
25
|
export { StrandInstanceManager, type StartStrandConfig, type ResumeStrandOverrides, getStrandStoragePath, isAwaitingFirstSync, liveStrandStatus } from './strand-instance-manager.js';
|
|
23
26
|
export { StrandAwaitingFirstSyncError, DEFAULT_STRAND_FIRST_SYNC_TIMEOUT_MS, DEFAULT_STRAND_FIRST_SYNC_POLL_MS, strandHeaderHeld, appTablesReadable, strandFirstSyncComplete, type StrandFirstSyncConfig } from './strand-first-sync-gate.js';
|
|
@@ -41,23 +44,27 @@ export { peerAuthorizationDigest, cadrePeerVoucherDigest, cadrePeerRemoveDigest,
|
|
|
41
44
|
export { deriveOwnerAnchor, type OwnerAnchorInputs, type OwnerAnchorDerivation } from './owner-anchor-sync.js';
|
|
42
45
|
export { StrandWakeService, dialWake, WAKE_PROTOCOL, DEFAULT_WAKE_DIAL_BUDGET_MS, type StrandWakeServiceOptions, type DialWakeOptions } from './strand-wake-protocol.js';
|
|
43
46
|
export { StrandAddrService, collectStrandAddrs, STRAND_ADDR_PROTOCOL, type StrandAddrServiceOptions, type StrandAddrPeer, type CollectStrandAddrsOptions, type StrandAddrOutcome, type StrandAddrCollection } from './strand-addr-protocol.js';
|
|
44
|
-
export { peerRecordSignedPayload, signPeerRecord, verifyPeerRecordSignature, isPeerRecordFresh, isSignalingAddr, orderSignalingFirst,
|
|
47
|
+
export { peerRecordSignedPayload, signPeerRecord, verifyPeerRecordSignature, isPeerRecordFresh, isSignalingAddr, orderSignalingFirst, currentMemberTrustPolicy, DEFAULT_PEER_RECORD_MAX_AGE_MS, DEFAULT_PEER_RECORD_HEARTBEAT_MS } from './peer-record.js';
|
|
45
48
|
export { deviceTokenSignedPayload, signDeviceTokenRecord, verifyDeviceTokenSignature, isPushPlatform } from './device-token.js';
|
|
46
49
|
export { STRAND_WAKE_TYPE, type StrandWakePayload } from './strand-wake-payload.js';
|
|
47
50
|
export type { PushNotifier, PushMessage, PushSendResult } from './push-notifier.js';
|
|
48
51
|
export { validatePushCredentials, redactPushCredentials, REDACTED } from './push-credentials.js';
|
|
49
52
|
export { PushFanoutService, DEFAULT_PUSH_COOLDOWN_MS, DEFAULT_PUSH_DEBOUNCE_MS, type PushFanoutOptions, type FanoutMember } from './push-fanout.js';
|
|
50
53
|
export { selectControlCohortDials, DEFAULT_CONTROL_COHORT_RECONCILE_MS, DEFAULT_CONTROL_COHORT_TARGET_DEGREE, type ControlCohortSelection, type ControlCohortReconcileResult } from './control-cohort.js';
|
|
51
|
-
export { dialPeerAddrs, SelfRelayOnlyError, PeerUnreachableError, tryAddrsInTurn, directBeforeRelayed, DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS, DEFAULT_CONTROL_COHORT_PER_ADDRESS_DIAL_TIMEOUT_MS, CONTROL_COHORT_DIAL_ADDRESS_ATTEMPTS, DEFAULT_PEER_DIAL_BUDGET, type PeerDialBudget, type AddrDialer } from './peer-dial.js';
|
|
54
|
+
export { dialAddr, withTrailingPeerId, dialPeerAddrs, SelfRelayOnlyError, PeerUnreachableError, tryAddrsInTurn, directBeforeRelayed, DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS, DEFAULT_CONTROL_COHORT_PER_ADDRESS_DIAL_TIMEOUT_MS, CONTROL_COHORT_DIAL_ADDRESS_ATTEMPTS, DEFAULT_PEER_DIAL_BUDGET, type PeerDialBudget, type AddrDialer } from './peer-dial.js';
|
|
52
55
|
export { DECLARED_LINK_ROUND_TRIP_MS, CIRCUIT_DIAL_ROUND_TRIPS, RELAY_DIAL_ROUND_TRIPS, RELAYED_DIAL_ROUND_TRIPS, RELAY_RESERVATION_ROUND_TRIPS, CIRCUIT_REQUEST_ROUND_TRIPS, RELAYED_REQUEST_ROUND_TRIPS, PUSH_TRANSFER_ALLOWANCE_MS, ADMISSION_DECISION_TIMEOUT_MS, resolveLinkRoundTripMs, relayedDialBudgetMs, relayReservationBudgetMs, circuitRequestBudgetMs, relayedRequestBudgetMs, peerJoinPushBudget, type PeerJoinPushBudget, DIAL_ADMISSION_DECISIONS, optimysticDialLimits, type OptimysticDialLimits } from './link-budget.js';
|
|
53
56
|
export { anchoredTrustPolicy, pinnedKeyTrustPolicy, tofuTrustPolicy, claimSecretTrustPolicy, type SeedTrustPolicy, type SeedTrustContext, type SeedTrustDecision, type ClaimSecretTrustPolicyOptions } from './seed-trust-policy.js';
|
|
54
57
|
export { parseClaimSecret, claimProof, verifyClaimProof, ClaimRefusedError, CLAIM_SECRET_BYTES } from './claim-proof.js';
|
|
55
|
-
export { encodeNodeClaimPayload, decodeNodeClaimPayload, NODE_CLAIM_PAYLOAD_PREFIX, type NodeClaimPayload } from './node-claim-payload.js';
|
|
58
|
+
export { encodeNodeClaimPayload, decodeNodeClaimPayload, selectNodeClaimAddresses, withClaimDestination, destinationPeerIdOf, classifyDialAddress, NODE_CLAIM_PAYLOAD_PREFIX, type NodeClaimPayload, type NodeClaimAddressOptions, type DialAddressKind } from './node-claim-payload.js';
|
|
59
|
+
export { exportStrandBundle, adoptStrandBundle, readStrandHoldings, unheldBundleContent, StrandMoveNotOwnerError, StrandMoveSamePartyError, type StrandHoldings, type StrandBundle, type StrandBundleEntry, type FormationInviteEntry, type StrandMoveReport, type StrandMoveFailure } from './strand-move.js';
|
|
60
|
+
export { encodeCadreJoinRequest, decodeCadreJoinRequest, requireCadreJoinReply, CADRE_JOIN_REQUEST_PREFIX, CADRE_INVITATION_PREFIX, CADRE_JOIN_REQUEST_MAX_APP_NAME, type CadreJoinReply, type CadreJoinRequest } from './cadre-join-request.js';
|
|
61
|
+
export * from './provider/index.js';
|
|
56
62
|
export { signSchema, verifySchema, assertSchemaSignature, SchemaVerificationError } from './schema-verification.js';
|
|
57
63
|
export { FormationListener, dialFormation, dialFormationByMachine, isValidResponderCreatesResult, isWellFormedMembershipInvite, sanitizeStrandAddrs, FORMATION_PROTOCOL, type FormationParty, type FormationContactMessage, type FormationResultMessage, type FormationProvisionResult, type FormationStrandInfo, type FormationDbConnectionInfo, type FormationListenerOptions, type FormationDialOptions, type FormationDialResult, type FormationRejection, type FormationTokenCheck, type ResponderProvisionOutcome } from './strand-formation-protocol.js';
|
|
58
64
|
export { FormationRejectedError, FormationUnreachableError, FormationPostApprovalError, FORMATION_REJECTION_RETRYABLE, isFormationRejectionCode, type FormationRejectionCode } from './strand-formation-rejection.js';
|
|
59
65
|
export { formationDeadlines, type FormationDeadlines } from './strand-formation-deadlines.js';
|
|
60
|
-
export { CadreInviteHandler, redeemAtMembers, signRedeemRequest, verifyRedeemReply, encodeCadreInvitation, decodeCadreInvitation, isWellFormedCadreInviteRow, sanitizeAddrs, CadreInviteRejectedError, CadreInviteUnreachableError, CadreInviteReplyInvalidError, CADRE_INVITE_PROTOCOL, CADRE_INVITE_REJECTION_RETRYABLE, isCadreInviteRejectionCode, type CadreInvitation, type CadreInviteRedeemRequest, type CadreInviteRedeemReply, type CadreInviteAccepted, type CadreInviteRejectionCode, type CadreInviteAddressOutcome, type CadreInviteHandlerOptions, type CadreInviteStore, type RedeemAtMembersOptions, type RedeemSigner, type CadreInviteRedemption } from './cadre-invite-protocol.js';
|
|
66
|
+
export { CadreInviteHandler, redeemAtMembers, redeemInPasses, signRedeemRequest, verifyRedeemReply, encodeCadreInvitation, decodeCadreInvitation, isWellFormedCadreInviteRow, sanitizeAddrs, CadreInviteRejectedError, CadreInviteUnreachableError, CadreInviteReplyInvalidError, CADRE_INVITE_PROTOCOL, CADRE_INVITE_REJECTION_RETRYABLE, isCadreInviteRejectionCode, type CadreInvitation, type CadreInviteRedeemRequest, type CadreInviteRedeemReply, type CadreInviteAccepted, type CadreInviteRejectionCode, type CadreInviteAddressOutcome, type CadreInviteHandlerOptions, type CadreInviteStore, type RedeemAtMembersOptions, type RedeemInPassesOptions, type RedeemSigner, type CadreInviteRedemption } from './cadre-invite-protocol.js';
|
|
67
|
+
export { selectCadreInvitationMembers, cadreInvitationReach, CADRE_INVITATION_MAX_ADDRS, CADRE_INVITATION_ADDRS_PER_SIBLING } from './invitation-bootstrap.js';
|
|
61
68
|
export { PENDING_JOIN_POLL_MS, PENDING_JOIN_MAX_BACKOFF_MS, MAX_PENDING_JOIN_MS } from './pending-join-runner.js';
|
|
62
69
|
export { StrandFormationManager, createStrandFormationManager, MEMBERSHIP_INVITE_TTL_MS, MEMBERSHIP_INVITE_UNAVAILABLE_REASON, HOST_STRAND_MUST_BE_RECREATED_REASON, type CadrePeerAddrsSource, type MembershipInviteIssuer, type StrandFormationManagerConfig, type StrandFormationManagerOptions } from './strand-formation-manager.js';
|
|
63
70
|
export { controlProtocolClasses, type ControlProtocolClass } from './control-protocol-guard.js';
|
package/dist/index.js
CHANGED
|
@@ -4,8 +4,11 @@ export * from './types.js';
|
|
|
4
4
|
export { canonicalJson } from './canonical-json.js';
|
|
5
5
|
// Main CadreNode class
|
|
6
6
|
export { CadreNode, OWNER_INVITATION_DEFAULT_TTL_MS, CADRE_INVITATION_DEFAULT_TTL_MS } from './cadre-node.js';
|
|
7
|
+
// Removing a machine from a cadre: the by-name refusal `CadreNode.removeMachine` throws
|
|
8
|
+
// (the listing, plan and result types are in types.ts)
|
|
9
|
+
export { MachineRemovalRefusedError } from './machine-removal.js';
|
|
7
10
|
// Control database
|
|
8
|
-
export { ControlDatabase, MissingHostStrandError, InvitationExhaustedError, CadreInviteIssuerUnknownError, buildAuthorizationMessage, registerPartyIdFunction, formationVouchMessage, formationConsentMessage, cadreInviteAddMessage, cadreInviteRedeemMessage, cadreInviteConsentMessage, projectSeedPeers, REAPABLE_TABLES } from './control-database.js';
|
|
11
|
+
export { ControlDatabase, parseNullableStoredDatetimeMs, MissingHostStrandError, InvitationExhaustedError, CadreInviteIssuerUnknownError, buildAuthorizationMessage, registerPartyIdFunction, formationVouchMessage, formationConsentMessage, cadreInviteAddMessage, cadreInviteRedeemMessage, cadreInviteConsentMessage, projectSeedPeers, REAPABLE_TABLES } from './control-database.js';
|
|
9
12
|
// Bounded retry for transient control-write failures (classifier + loop behind
|
|
10
13
|
// ControlDatabase.lockedWithRetry; exported so the integration package can drive the
|
|
11
14
|
// classifier against real engine errors)
|
|
@@ -23,6 +26,9 @@ export { ed25519KeyPairFromLibp2p, ed25519PublicKeyFromPrivate, ed25519PublicKey
|
|
|
23
26
|
// separate subpath module ('@serfab/cadre-core/key-store-file') so its node:fs
|
|
24
27
|
// import never lands here.
|
|
25
28
|
export { InMemoryKeyStore, KeyStoreAccessError, DEFAULT_IDENTITY_KEY_ID } from './key-store.js';
|
|
29
|
+
// The filename-safe form of an id that every Node-only per-party file store names its file
|
|
30
|
+
// with (`<name>.<encoded party>.json`), for an embedder keeping its own file beside theirs.
|
|
31
|
+
export { encodeFileSafeComponent } from './file-safe-name.js';
|
|
26
32
|
// The KeyStore-backed identity rule, shared with embedding apps that need the
|
|
27
33
|
// node key BEFORE `CadreNode` exists.
|
|
28
34
|
export { loadOrCreateIdentityKey } from './identity-key.js';
|
|
@@ -140,7 +146,7 @@ export { StrandWakeService, dialWake, WAKE_PROTOCOL, DEFAULT_WAKE_DIAL_BUDGET_MS
|
|
|
140
146
|
// `export * from './types.js'` (StrandAddrRequest / StrandAddrResponse / StrandAddrStatus).
|
|
141
147
|
export { StrandAddrService, collectStrandAddrs, STRAND_ADDR_PROTOCOL } from './strand-addr-protocol.js';
|
|
142
148
|
// Peer-address record (self-published, signed, freshness-stamped CadrePeer row)
|
|
143
|
-
export { peerRecordSignedPayload, signPeerRecord, verifyPeerRecordSignature, isPeerRecordFresh, isSignalingAddr, orderSignalingFirst,
|
|
149
|
+
export { peerRecordSignedPayload, signPeerRecord, verifyPeerRecordSignature, isPeerRecordFresh, isSignalingAddr, orderSignalingFirst, currentMemberTrustPolicy, DEFAULT_PEER_RECORD_MAX_AGE_MS, DEFAULT_PEER_RECORD_HEARTBEAT_MS } from './peer-record.js';
|
|
144
150
|
// Device-token record (self-published, signed FCM/APNs push token — CadrePeer sibling)
|
|
145
151
|
export { deviceTokenSignedPayload, signDeviceTokenRecord, verifyDeviceTokenSignature, isPushPlatform } from './device-token.js';
|
|
146
152
|
// Strand-wake payload contract (canonical; shared by the server sender + RN receiver)
|
|
@@ -157,8 +163,10 @@ export { PushFanoutService, DEFAULT_PUSH_COOLDOWN_MS, DEFAULT_PUSH_DEBOUNCE_MS }
|
|
|
157
163
|
// the cadence/degree defaults the proactive reconcile routine reads.
|
|
158
164
|
export { selectControlCohortDials, DEFAULT_CONTROL_COHORT_RECONCILE_MS, DEFAULT_CONTROL_COHORT_TARGET_DEGREE } from './control-cohort.js';
|
|
159
165
|
// Dialing one peer from several candidate addresses, each under its own time
|
|
160
|
-
// limit, so an address that never answers cannot starve the rest.
|
|
161
|
-
|
|
166
|
+
// limit, so an address that never answers cannot starve the rest. Each address is
|
|
167
|
+
// bound to the peer expected and dialed outside libp2p's dial queue (`dialAddr`),
|
|
168
|
+
// so another dial of the same peer in flight cannot capture the attempt.
|
|
169
|
+
export { dialAddr, withTrailingPeerId, dialPeerAddrs, SelfRelayOnlyError, PeerUnreachableError, tryAddrsInTurn, directBeforeRelayed, DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS, DEFAULT_CONTROL_COHORT_PER_ADDRESS_DIAL_TIMEOUT_MS, CONTROL_COHORT_DIAL_ADDRESS_ATTEMPTS, DEFAULT_PEER_DIAL_BUDGET } from './peer-dial.js';
|
|
162
170
|
// Dial and reservation budgets counted in link round trips rather than fixed milliseconds, so
|
|
163
171
|
// one declared assumption about the link moves them all — see `NetworkConfig.linkRoundTripMs`.
|
|
164
172
|
export { DECLARED_LINK_ROUND_TRIP_MS, CIRCUIT_DIAL_ROUND_TRIPS, RELAY_DIAL_ROUND_TRIPS, RELAYED_DIAL_ROUND_TRIPS, RELAY_RESERVATION_ROUND_TRIPS, CIRCUIT_REQUEST_ROUND_TRIPS, RELAYED_REQUEST_ROUND_TRIPS, PUSH_TRANSFER_ALLOWANCE_MS, ADMISSION_DECISION_TIMEOUT_MS, resolveLinkRoundTripMs, relayedDialBudgetMs, relayReservationBudgetMs, circuitRequestBudgetMs, relayedRequestBudgetMs, peerJoinPushBudget, DIAL_ADMISSION_DECISIONS, optimysticDialLimits } from './link-budget.js';
|
|
@@ -172,7 +180,22 @@ export { anchoredTrustPolicy, pinnedKeyTrustPolicy, tofuTrustPolicy, claimSecret
|
|
|
172
180
|
export { parseClaimSecret, claimProof, verifyClaimProof, ClaimRefusedError, CLAIM_SECRET_BYTES } from './claim-proof.js';
|
|
173
181
|
// The claim payload: the node's peer id, addresses and claim secret as the text a host
|
|
174
182
|
// shows as a QR code and a phone scans (`CadreNode.claimNode` takes the decoded form).
|
|
175
|
-
export { encodeNodeClaimPayload, decodeNodeClaimPayload, NODE_CLAIM_PAYLOAD_PREFIX } from './node-claim-payload.js';
|
|
183
|
+
export { encodeNodeClaimPayload, decodeNodeClaimPayload, selectNodeClaimAddresses, withClaimDestination, destinationPeerIdOf, classifyDialAddress, NODE_CLAIM_PAYLOAD_PREFIX } from './node-claim-payload.js';
|
|
184
|
+
// Moving a party's strands into another party of the same owner, so an app's strands follow
|
|
185
|
+
// the app into the user's main cadre: the bundle one node exports from the party it leaves,
|
|
186
|
+
// its adoption by a node of the party it joined, and the check that the party it left holds
|
|
187
|
+
// nothing the joined one lacks before it is dissolved.
|
|
188
|
+
export { exportStrandBundle, adoptStrandBundle, readStrandHoldings, unheldBundleContent, StrandMoveNotOwnerError, StrandMoveSamePartyError } from './strand-move.js';
|
|
189
|
+
// The join request: what an app that wants to join a cadre copies to the app that manages it,
|
|
190
|
+
// which mints an invitation targeted at the request's peer id. Both paste-text prefixes live here.
|
|
191
|
+
export { encodeCadreJoinRequest, decodeCadreJoinRequest, requireCadreJoinReply, CADRE_JOIN_REQUEST_PREFIX, CADRE_INVITATION_PREFIX, CADRE_JOIN_REQUEST_MAX_APP_NAME } from './cadre-join-request.js';
|
|
192
|
+
// Renting a node from a hosting provider: the provider's descriptor, the app's side of the
|
|
193
|
+
// OAuth 2 + PKCE sign-in, the typed client for its container API, and `rentNode` /
|
|
194
|
+
// `finishRental`, which add the rented container to this node's cadre by invitation or by
|
|
195
|
+
// claim. Global `fetch` and `crypto.getRandomValues` only, so the whole set loads on React
|
|
196
|
+
// Native and in the browser (`docs/architecture.md` → "Renting a node from an app"). The
|
|
197
|
+
// barrel is the curated list; it is not repeated here.
|
|
198
|
+
export * from './provider/index.js';
|
|
176
199
|
// Schema Verification
|
|
177
200
|
export { signSchema, verifySchema, assertSchemaSignature, SchemaVerificationError } from './schema-verification.js';
|
|
178
201
|
// Strand Formation transport (native cadre-core protocol)
|
|
@@ -182,7 +205,9 @@ export { FormationRejectedError, FormationUnreachableError, FormationPostApprova
|
|
|
182
205
|
export { formationDeadlines } from './strand-formation-deadlines.js';
|
|
183
206
|
// Cadre invitation redemption transport: the bundle an owner hands out, the wire messages, the
|
|
184
207
|
// member-side handler and the device-side dialer, and how a redemption fails
|
|
185
|
-
export { CadreInviteHandler, redeemAtMembers, signRedeemRequest, verifyRedeemReply, encodeCadreInvitation, decodeCadreInvitation, isWellFormedCadreInviteRow, sanitizeAddrs, CadreInviteRejectedError, CadreInviteUnreachableError, CadreInviteReplyInvalidError, CADRE_INVITE_PROTOCOL, CADRE_INVITE_REJECTION_RETRYABLE, isCadreInviteRejectionCode } from './cadre-invite-protocol.js';
|
|
208
|
+
export { CadreInviteHandler, redeemAtMembers, redeemInPasses, signRedeemRequest, verifyRedeemReply, encodeCadreInvitation, decodeCadreInvitation, isWellFormedCadreInviteRow, sanitizeAddrs, CadreInviteRejectedError, CadreInviteUnreachableError, CadreInviteReplyInvalidError, CADRE_INVITE_PROTOCOL, CADRE_INVITE_REJECTION_RETRYABLE, isCadreInviteRejectionCode } from './cadre-invite-protocol.js';
|
|
209
|
+
// Which machines, and how many addresses of each, an invitation names; how far a cadre invitation reaches
|
|
210
|
+
export { selectCadreInvitationMembers, cadreInvitationReach, CADRE_INVITATION_MAX_ADDRS, CADRE_INVITATION_ADDRS_PER_SIBLING } from './invitation-bootstrap.js';
|
|
186
211
|
// The pending-join retry loop behind CadreNode.requestJoin (PendingJoinStatus is in types.ts)
|
|
187
212
|
export { PENDING_JOIN_POLL_MS, PENDING_JOIN_MAX_BACKOFF_MS, MAX_PENDING_JOIN_MS } from './pending-join-runner.js';
|
|
188
213
|
// Strand Formation manager (drives the native transport)
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,cAAc,YAAY,CAAC;AAE3B,+DAA+D;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,uBAAuB;AACvB,OAAO,EAAE,SAAS,EAAE,+BAA+B,EAAE,+BAA+B,EAAE,MAAM,iBAAiB,CAAC;AAE9G,mBAAmB;AACnB,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,cAAc,YAAY,CAAC;AAE3B,+DAA+D;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,uBAAuB;AACvB,OAAO,EAAE,SAAS,EAAE,+BAA+B,EAAE,+BAA+B,EAAE,MAAM,iBAAiB,CAAC;AAE9G,wFAAwF;AACxF,uDAAuD;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAElE,mBAAmB;AACnB,OAAO,EAAE,eAAe,EAAE,6BAA6B,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,eAAe,EAA4R,MAAM,uBAAuB,CAAC;AAErpB,+EAA+E;AAC/E,qFAAqF;A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B,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAwB,MAAM,4BAA4B,CAAC;AACnF,yFAAyF;AACzF,8DAA8D;AAC9D,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,kBAAkB,EAAmB,MAAM,iBAAiB,CAAC;AACrG,2FAA2F;AAC3F,8FAA8F;AAC9F,+EAA+E;AAC/E,OAAO,EACL,kBAAkB,EAClB,4BAA4B,EAC5B,8BAA8B,EAG/B,MAAM,mBAAmB,CAAC;AAE3B,gFAAgF;AAChF,0EAA0E;AAC1E,6BAA6B;AAC7B,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,gCAAgC,EAChC,6BAA6B,EAC7B,sBAAsB,EACtB,4BAA4B,EAC5B,4BAA4B,EAM7B,MAAM,wBAAwB,CAAC;AAEhC,2EAA2E;AAC3E,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EAMzB,MAAM,kCAAkC,CAAC"}
|
|
@@ -1,21 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Which of the inviting party's
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Which of the inviting party's machines an invitation names, so a joiner can still form or
|
|
3
|
+
* join while the machine that minted it is offline: an open strand invitation
|
|
4
|
+
* (`CadreNode.createOpenInvitation`, which puts the minting machine's own addresses first
|
|
5
|
+
* itself) and a cadre invitation ({@link selectCadreInvitationMembers}). Also how far a cadre
|
|
6
|
+
* invitation reaches once its minting machine is gone ({@link cadreInvitationReach}).
|
|
5
7
|
*/
|
|
8
|
+
import type { CadreInvitationReach } from './types.js';
|
|
6
9
|
/**
|
|
7
10
|
* At most this many of the party's other machines are named, each with at most
|
|
8
11
|
* {@link INVITATION_ADDRS_PER_SIBLING} addresses: 12 extra addresses of roughly 100–200
|
|
9
12
|
* characters, base64url-encoded into an invitation shared as text.
|
|
10
13
|
*
|
|
11
|
-
* NOTE:
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* NOTE: a cadre invitation, which may be carried in a QR code, is capped harder
|
|
15
|
+
* ({@link CADRE_INVITATION_MAX_ADDRS}); an open strand invitation keeps these caps. If open
|
|
16
|
+
* invitations are ever carried in a QR code too, cap them the same way.
|
|
17
|
+
* NOTE: for an open strand invitation the per-machine cap keeps the record's order (relay first,
|
|
18
|
+
* then direct addresses as the machine published them, loopback included); a cadre invitation
|
|
19
|
+
* ranks them first. If an open invitation's sibling is seen to have its reachable address cut,
|
|
20
|
+
* rank the same way.
|
|
16
21
|
*/
|
|
17
22
|
export declare const INVITATION_SIBLING_MACHINES = 3;
|
|
18
23
|
export declare const INVITATION_ADDRS_PER_SIBLING = 4;
|
|
24
|
+
/**
|
|
25
|
+
* Most addresses a cadre invitation names in total, so its text fits one QR code. Measured
|
|
26
|
+
* with three owner keys: 2,206 characters encoded at 6 relayed addresses of about 155
|
|
27
|
+
* characters (the worst case, since ranking puts relayed addresses first), 1,972 with relayed
|
|
28
|
+
* and direct WebSocket addresses alternating, against 2,331 bytes in the largest QR code at
|
|
29
|
+
* error-correction level M (2,953 at L). Each further address costs about 170 characters, each
|
|
30
|
+
* further owner key about 60.
|
|
31
|
+
*/
|
|
32
|
+
export declare const CADRE_INVITATION_MAX_ADDRS = 6;
|
|
33
|
+
/** Most addresses a cadre invitation names for each of the party's other machines. */
|
|
34
|
+
export declare const CADRE_INVITATION_ADDRS_PER_SIBLING = 2;
|
|
19
35
|
/** One other machine of the party whose signed address record resolved. */
|
|
20
36
|
export interface InvitationSibling {
|
|
21
37
|
peerId: string;
|
|
@@ -25,8 +41,30 @@ export interface InvitationSibling {
|
|
|
25
41
|
addrs: string[];
|
|
26
42
|
}
|
|
27
43
|
/**
|
|
28
|
-
* The addresses of the siblings an invitation names
|
|
29
|
-
* now come first, since a live connection is the best evidence that
|
|
30
|
-
* shows only that it was up within the freshness window. Within each
|
|
44
|
+
* The addresses of the siblings an invitation names, at most `perSibling` each. Machines this
|
|
45
|
+
* node is connected to right now come first, since a live connection is the best evidence that
|
|
46
|
+
* a machine is up; a record shows only that it was up within the freshness window. Within each
|
|
47
|
+
* half, newest record first.
|
|
48
|
+
*/
|
|
49
|
+
export declare function selectInvitationSiblingAddrs(siblings: InvitationSibling[], connected: ReadonlySet<string>, perSibling?: number): string[];
|
|
50
|
+
/**
|
|
51
|
+
* The `members` of a cadre invitation: the minting machine's own addresses first (at most
|
|
52
|
+
* {@link INVITATION_ADDRS_PER_SIBLING}), then the other machines' in
|
|
53
|
+
* {@link selectInvitationSiblingAddrs} order (at most {@link CADRE_INVITATION_ADDRS_PER_SIBLING}
|
|
54
|
+
* each), the whole list cut to {@link CADRE_INVITATION_MAX_ADDRS}. Each machine's addresses are
|
|
55
|
+
* ranked for a phone before they are cut ({@link rankForPhone}): libp2p reports a machine
|
|
56
|
+
* listening on every interface with its loopback and private addresses ahead of its relayed one.
|
|
57
|
+
*
|
|
58
|
+
* NOTE: accepted tradeoff — with two or more other machines, only the best two addresses of
|
|
59
|
+
* each survive, connected machines first, so a reachable address of a sibling can be cut. Size
|
|
60
|
+
* was weighed over completeness, so the text fits a QR code; revisit if redemptions are seen
|
|
61
|
+
* failing for want of a sibling address the record held.
|
|
62
|
+
*/
|
|
63
|
+
export declare function selectCadreInvitationMembers(own: readonly string[], siblings: InvitationSibling[], connected: ReadonlySet<string>): string[];
|
|
64
|
+
/**
|
|
65
|
+
* Where a phone could redeem an invitation naming `members` from, judged on the machines other
|
|
66
|
+
* than `issuerPeerId`: in the app flows the minting app is the one closed or in the background
|
|
67
|
+
* when the other app redeems, and two apps on one phone cannot reach each other. An address
|
|
68
|
+
* names its machine by its last `/p2p/`.
|
|
31
69
|
*/
|
|
32
|
-
export declare function
|
|
70
|
+
export declare function cadreInvitationReach(members: readonly string[], issuerPeerId: string): CadreInvitationReach;
|
|
@@ -1,30 +1,93 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Which of the inviting party's
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Which of the inviting party's machines an invitation names, so a joiner can still form or
|
|
3
|
+
* join while the machine that minted it is offline: an open strand invitation
|
|
4
|
+
* (`CadreNode.createOpenInvitation`, which puts the minting machine's own addresses first
|
|
5
|
+
* itself) and a cadre invitation ({@link selectCadreInvitationMembers}). Also how far a cadre
|
|
6
|
+
* invitation reaches once its minting machine is gone ({@link cadreInvitationReach}).
|
|
5
7
|
*/
|
|
8
|
+
import { classifyDialAddress, destinationPeerIdOf } from './node-claim-payload.js';
|
|
6
9
|
/**
|
|
7
10
|
* At most this many of the party's other machines are named, each with at most
|
|
8
11
|
* {@link INVITATION_ADDRS_PER_SIBLING} addresses: 12 extra addresses of roughly 100–200
|
|
9
12
|
* characters, base64url-encoded into an invitation shared as text.
|
|
10
13
|
*
|
|
11
|
-
* NOTE:
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* NOTE: a cadre invitation, which may be carried in a QR code, is capped harder
|
|
15
|
+
* ({@link CADRE_INVITATION_MAX_ADDRS}); an open strand invitation keeps these caps. If open
|
|
16
|
+
* invitations are ever carried in a QR code too, cap them the same way.
|
|
17
|
+
* NOTE: for an open strand invitation the per-machine cap keeps the record's order (relay first,
|
|
18
|
+
* then direct addresses as the machine published them, loopback included); a cadre invitation
|
|
19
|
+
* ranks them first. If an open invitation's sibling is seen to have its reachable address cut,
|
|
20
|
+
* rank the same way.
|
|
16
21
|
*/
|
|
17
22
|
export const INVITATION_SIBLING_MACHINES = 3;
|
|
18
23
|
export const INVITATION_ADDRS_PER_SIBLING = 4;
|
|
19
24
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
25
|
+
* Most addresses a cadre invitation names in total, so its text fits one QR code. Measured
|
|
26
|
+
* with three owner keys: 2,206 characters encoded at 6 relayed addresses of about 155
|
|
27
|
+
* characters (the worst case, since ranking puts relayed addresses first), 1,972 with relayed
|
|
28
|
+
* and direct WebSocket addresses alternating, against 2,331 bytes in the largest QR code at
|
|
29
|
+
* error-correction level M (2,953 at L). Each further address costs about 170 characters, each
|
|
30
|
+
* further owner key about 60.
|
|
23
31
|
*/
|
|
24
|
-
export
|
|
32
|
+
export const CADRE_INVITATION_MAX_ADDRS = 6;
|
|
33
|
+
/** Most addresses a cadre invitation names for each of the party's other machines. */
|
|
34
|
+
export const CADRE_INVITATION_ADDRS_PER_SIBLING = 2;
|
|
35
|
+
/**
|
|
36
|
+
* The addresses of the siblings an invitation names, at most `perSibling` each. Machines this
|
|
37
|
+
* node is connected to right now come first, since a live connection is the best evidence that
|
|
38
|
+
* a machine is up; a record shows only that it was up within the freshness window. Within each
|
|
39
|
+
* half, newest record first.
|
|
40
|
+
*/
|
|
41
|
+
export function selectInvitationSiblingAddrs(siblings, connected, perSibling = INVITATION_ADDRS_PER_SIBLING) {
|
|
25
42
|
return [...siblings]
|
|
26
43
|
.sort((a, b) => Number(connected.has(b.peerId)) - Number(connected.has(a.peerId)) || b.updatedAt - a.updatedAt)
|
|
27
44
|
.slice(0, INVITATION_SIBLING_MACHINES)
|
|
28
|
-
.flatMap((sibling) => sibling.addrs.slice(0,
|
|
45
|
+
.flatMap((sibling) => sibling.addrs.slice(0, perSibling));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The `members` of a cadre invitation: the minting machine's own addresses first (at most
|
|
49
|
+
* {@link INVITATION_ADDRS_PER_SIBLING}), then the other machines' in
|
|
50
|
+
* {@link selectInvitationSiblingAddrs} order (at most {@link CADRE_INVITATION_ADDRS_PER_SIBLING}
|
|
51
|
+
* each), the whole list cut to {@link CADRE_INVITATION_MAX_ADDRS}. Each machine's addresses are
|
|
52
|
+
* ranked for a phone before they are cut ({@link rankForPhone}): libp2p reports a machine
|
|
53
|
+
* listening on every interface with its loopback and private addresses ahead of its relayed one.
|
|
54
|
+
*
|
|
55
|
+
* NOTE: accepted tradeoff — with two or more other machines, only the best two addresses of
|
|
56
|
+
* each survive, connected machines first, so a reachable address of a sibling can be cut. Size
|
|
57
|
+
* was weighed over completeness, so the text fits a QR code; revisit if redemptions are seen
|
|
58
|
+
* failing for want of a sibling address the record held.
|
|
59
|
+
*/
|
|
60
|
+
export function selectCadreInvitationMembers(own, siblings, connected) {
|
|
61
|
+
const ranked = siblings.map((sibling) => ({ ...sibling, addrs: rankForPhone(sibling.addrs) }));
|
|
62
|
+
return [
|
|
63
|
+
...rankForPhone(own).slice(0, INVITATION_ADDRS_PER_SIBLING),
|
|
64
|
+
...selectInvitationSiblingAddrs(ranked, connected, CADRE_INVITATION_ADDRS_PER_SIBLING),
|
|
65
|
+
].slice(0, CADRE_INVITATION_MAX_ADDRS);
|
|
66
|
+
}
|
|
67
|
+
/** Order in which a phone is likeliest to reach an address: from anywhere, on its network, on that machine, not at all. */
|
|
68
|
+
const PHONE_DIAL_RANK = { relay: 0, name: 0, public: 0, private: 1, loopback: 2 };
|
|
69
|
+
/** `addrs` best first for a phone dialing them ({@link PHONE_DIAL_RANK}), ties in their given order; one a phone cannot dial (plain TCP) last. */
|
|
70
|
+
function rankForPhone(addrs) {
|
|
71
|
+
const rankOf = (addr) => {
|
|
72
|
+
const kind = classifyDialAddress(addr);
|
|
73
|
+
return kind === undefined ? 3 : PHONE_DIAL_RANK[kind];
|
|
74
|
+
};
|
|
75
|
+
return addrs.map((addr) => ({ addr, rank: rankOf(addr) })).sort((a, b) => a.rank - b.rank).map(({ addr }) => addr);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Where a phone could redeem an invitation naming `members` from, judged on the machines other
|
|
79
|
+
* than `issuerPeerId`: in the app flows the minting app is the one closed or in the background
|
|
80
|
+
* when the other app redeems, and two apps on one phone cannot reach each other. An address
|
|
81
|
+
* names its machine by its last `/p2p/`.
|
|
82
|
+
*/
|
|
83
|
+
export function cadreInvitationReach(members, issuerPeerId) {
|
|
84
|
+
const others = members.flatMap((addr) => {
|
|
85
|
+
const kind = classifyDialAddress(addr);
|
|
86
|
+
// Classified, so it parses and `destinationPeerIdOf` cannot throw.
|
|
87
|
+
return kind === undefined || destinationPeerIdOf(addr) === issuerPeerId ? [] : [kind];
|
|
88
|
+
});
|
|
89
|
+
if (others.some((kind) => kind === 'relay' || kind === 'name' || kind === 'public'))
|
|
90
|
+
return 'anywhere';
|
|
91
|
+
return others.length > 0 ? 'local-network' : 'issuer-only';
|
|
29
92
|
}
|
|
30
93
|
//# sourceMappingURL=invitation-bootstrap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invitation-bootstrap.js","sourceRoot":"","sources":["../src/invitation-bootstrap.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"invitation-bootstrap.js","sourceRoot":"","sources":["../src/invitation-bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAwB,MAAM,yBAAyB,CAAC;AAGzG;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAC7C,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC;AAE9C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAE5C,sFAAsF;AACtF,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,CAAC;AAWpD;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAC3C,QAA6B,EAC7B,SAA8B,EAC9B,aAAqB,4BAA4B;IAEjD,OAAO,CAAC,GAAG,QAAQ,CAAC;SAClB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC;SAC9G,KAAK,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AI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;AACpH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAA0B,EAAE,YAAoB;IACpF,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACvC,MAAM,IAAI,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;QACvC,mEAAmE;QACnE,OAAO,IAAI,KAAK,SAAS,IAAI,mBAAmB,CAAC,IAAI,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACvF,CAAC,CAAC,CAAC;IACH,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,QAAQ,CAAC;QAAE,OAAO,UAAU,CAAC;IACvG,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,aAAa,CAAC;AAC5D,CAAC"}
|
|
@@ -128,6 +128,13 @@ export declare class JoinedStrandSession {
|
|
|
128
128
|
* predate a leave the record re-joined after.
|
|
129
129
|
*/
|
|
130
130
|
withControlRows(control: readonly StrandRow[]): Promise<StrandRow[]>;
|
|
131
|
+
/**
|
|
132
|
+
* This machine's unpublished joins, straight from the store (never the last-good list a
|
|
133
|
+
* failed read stands in with). What a strand move exports beside the `JoinedStrand`
|
|
134
|
+
* table: a machine publishes only while it holds a control connection, so until then its
|
|
135
|
+
* joins live only here.
|
|
136
|
+
*/
|
|
137
|
+
unpublishedRecords(): Promise<JoinedStrandRecord[]>;
|
|
131
138
|
/** Record a join `formStrand` just made. A re-join also cancels a removal a revocation queued. */
|
|
132
139
|
remember(record: JoinedStrandRecord): Promise<void>;
|
|
133
140
|
/**
|
|
@@ -257,6 +257,15 @@ export class JoinedStrandSession {
|
|
|
257
257
|
}
|
|
258
258
|
return [...offered.values()];
|
|
259
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* This machine's unpublished joins, straight from the store (never the last-good list a
|
|
262
|
+
* failed read stands in with). What a strand move exports beside the `JoinedStrand`
|
|
263
|
+
* table: a machine publishes only while it holds a control connection, so until then its
|
|
264
|
+
* joins live only here.
|
|
265
|
+
*/
|
|
266
|
+
unpublishedRecords() {
|
|
267
|
+
return this.store.list();
|
|
268
|
+
}
|
|
260
269
|
/** Record a join `formStrand` just made. A re-join also cancels a removal a revocation queued. */
|
|
261
270
|
async remember(record) {
|
|
262
271
|
this.pendingRemovals.delete(record.Id);
|