@fairfox/polly 0.67.0 → 0.70.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/dist/src/client/index.js +17 -20
- package/dist/src/client/index.js.map +4 -4
- package/dist/src/mesh.js +85 -11
- package/dist/src/mesh.js.map +7 -6
- package/dist/src/peer.js +80 -6
- package/dist/src/peer.js.map +7 -6
- package/dist/src/polly-ui/markdown.js +3 -3
- package/dist/src/polly-ui/markdown.js.map +2 -2
- package/dist/src/shared/lib/crdt-specialised.d.ts +6 -0
- package/dist/src/shared/lib/crdt-state.d.ts +8 -1
- package/dist/src/shared/lib/mesh-diagnostics.d.ts +98 -0
- package/dist/src/shared/lib/mesh-network-adapter.d.ts +0 -4
- package/dist/tools/test/src/e2e-mesh/console-allowlist.d.ts +31 -0
- package/dist/tools/test/src/e2e-mesh/index.d.ts +27 -0
- package/dist/tools/test/src/e2e-mesh/index.js +1089 -0
- package/dist/tools/test/src/e2e-mesh/index.js.map +22 -0
- package/dist/tools/test/src/e2e-mesh/keys.d.ts +55 -0
- package/dist/tools/test/src/e2e-mesh/launch-peer.d.ts +70 -0
- package/dist/tools/test/src/e2e-mesh/mesh-assertions.d.ts +53 -0
- package/dist/tools/test/src/e2e-mesh/serve-consumer.d.ts +32 -0
- package/dist/tools/test/src/e2e-mesh/wait-for-convergence.d.ts +38 -0
- package/dist/tools/test/src/e2e-mesh/with-relay.d.ts +53 -0
- package/dist/tools/test/src/visual/index.js +24 -24
- package/dist/tools/test/src/visual/index.js.map +2 -2
- package/dist/tools/verify/src/cli.js +361 -22
- package/dist/tools/verify/src/cli.js.map +6 -6
- package/dist/tools/verify/src/config.d.ts +26 -1
- package/dist/tools/verify/src/config.js +9 -1
- package/dist/tools/verify/src/config.js.map +4 -4
- package/dist/tools/verify/src/primitives/index.d.ts +30 -0
- package/dist/tools/visualize/src/cli.js +43 -1
- package/dist/tools/visualize/src/cli.js.map +3 -3
- package/package.json +11 -8
- package/LICENSE +0 -21
- package/README.md +0 -362
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mesh-diagnostics — typed event stream for observable mesh failures and
|
|
3
|
+
* state transitions.
|
|
4
|
+
*
|
|
5
|
+
* The mesh network adapter's incoming path has seven branches that drop a
|
|
6
|
+
* message and return undefined: a malformed signed envelope, a revoked
|
|
7
|
+
* peer, an unknown peer, a bad signature, a malformed encrypted envelope,
|
|
8
|
+
* a missing document key, and a bad decryption. Each branch is correct —
|
|
9
|
+
* the adapter must not surface tampered or unidentifiable bytes to the
|
|
10
|
+
* Repo — but the drop is invisible to anything observing the application.
|
|
11
|
+
* The classic symptom is "the other peer typed something and nothing
|
|
12
|
+
* arrived" with no error anywhere.
|
|
13
|
+
*
|
|
14
|
+
* This module exposes a typed emit-and-subscribe stream that the adapter
|
|
15
|
+
* (and the pairing and revocation paths) write to. Tests subscribe to
|
|
16
|
+
* assert that exactly the expected diagnostics fired and no others;
|
|
17
|
+
* production code can attach an observability sink that turns the stream
|
|
18
|
+
* into telemetry or a user-visible diagnostic surface.
|
|
19
|
+
*
|
|
20
|
+
* The stream is module-level. Listeners are deduplicated by reference;
|
|
21
|
+
* subscribe returns an unsubscribe function. Listener exceptions are
|
|
22
|
+
* caught and dropped so a buggy observer cannot tear the network path.
|
|
23
|
+
*/
|
|
24
|
+
/** All diagnostic event kinds, discriminated by the `kind` field. */
|
|
25
|
+
export type MeshDiagnostic = {
|
|
26
|
+
kind: "drop:malformed-signed-envelope";
|
|
27
|
+
reason?: string;
|
|
28
|
+
} | {
|
|
29
|
+
kind: "drop:revoked-peer";
|
|
30
|
+
senderId: string;
|
|
31
|
+
} | {
|
|
32
|
+
kind: "drop:unknown-peer";
|
|
33
|
+
senderId: string;
|
|
34
|
+
} | {
|
|
35
|
+
kind: "drop:bad-signature";
|
|
36
|
+
senderId: string;
|
|
37
|
+
reason?: string;
|
|
38
|
+
} | {
|
|
39
|
+
kind: "drop:malformed-encrypted-envelope";
|
|
40
|
+
senderId: string;
|
|
41
|
+
reason?: string;
|
|
42
|
+
} | {
|
|
43
|
+
kind: "drop:missing-doc-key";
|
|
44
|
+
senderId: string;
|
|
45
|
+
documentId: string;
|
|
46
|
+
} | {
|
|
47
|
+
kind: "drop:bad-decryption";
|
|
48
|
+
senderId: string;
|
|
49
|
+
documentId: string;
|
|
50
|
+
reason?: string;
|
|
51
|
+
} | {
|
|
52
|
+
kind: "pair:invite-issued";
|
|
53
|
+
peerId: string;
|
|
54
|
+
} | {
|
|
55
|
+
kind: "pair:invite-accepted";
|
|
56
|
+
peerId: string;
|
|
57
|
+
issuerId: string;
|
|
58
|
+
} | {
|
|
59
|
+
kind: "revoke:issued";
|
|
60
|
+
revokedPeerId: string;
|
|
61
|
+
issuerId: string;
|
|
62
|
+
} | {
|
|
63
|
+
kind: "revoke:applied";
|
|
64
|
+
revokedPeerId: string;
|
|
65
|
+
};
|
|
66
|
+
/** A diagnostic event with the wall-clock timestamp the emitter stamped. */
|
|
67
|
+
export type MeshDiagnosticEvent = MeshDiagnostic & {
|
|
68
|
+
timestamp: number;
|
|
69
|
+
};
|
|
70
|
+
/** Callback shape for subscribers. */
|
|
71
|
+
export type MeshDiagnosticListener = (event: MeshDiagnosticEvent) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Emit a diagnostic to every active subscriber. Synchronous. Listener
|
|
74
|
+
* exceptions are swallowed.
|
|
75
|
+
*/
|
|
76
|
+
export declare function emitMeshDiagnostic(diagnostic: MeshDiagnostic): void;
|
|
77
|
+
/**
|
|
78
|
+
* Subscribe a listener. Returns an unsubscribe function. Idempotent on
|
|
79
|
+
* the same listener reference — subscribing the same function twice
|
|
80
|
+
* registers it once.
|
|
81
|
+
*/
|
|
82
|
+
export declare function subscribeToMeshDiagnostics(listener: MeshDiagnosticListener): () => void;
|
|
83
|
+
/**
|
|
84
|
+
* Convenience for tests and trace recorders: subscribe, collect every
|
|
85
|
+
* event into an array, return the array and a stop function that
|
|
86
|
+
* unsubscribes. The returned array is the live capture buffer — reads
|
|
87
|
+
* see new events the moment they fire.
|
|
88
|
+
*/
|
|
89
|
+
export declare function recordMeshDiagnostics(): {
|
|
90
|
+
events: ReadonlyArray<MeshDiagnosticEvent>;
|
|
91
|
+
stop: () => void;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Test-only: drop every subscriber. Use in `afterEach` to guarantee
|
|
95
|
+
* isolation between tests when a stop function was missed. Not exported
|
|
96
|
+
* from the mesh subpath in production builds — tests reach in directly.
|
|
97
|
+
*/
|
|
98
|
+
export declare function clearMeshDiagnosticListeners(): void;
|
|
@@ -139,9 +139,5 @@ export declare class MeshNetworkAdapter extends NetworkAdapter {
|
|
|
139
139
|
* and target ids and the crypto blob in the `data` field.
|
|
140
140
|
*/
|
|
141
141
|
private wrap;
|
|
142
|
-
/**
|
|
143
|
-
* Try to unwrap an incoming crypto-wrapped message. Returns the original
|
|
144
|
-
* Message on success, undefined on verification or decryption failure.
|
|
145
|
-
*/
|
|
146
142
|
private tryUnwrap;
|
|
147
143
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fairfox/polly/test/e2e-mesh — canonical console-noise allowlist.
|
|
3
|
+
*
|
|
4
|
+
* Mesh runs emit a small number of benign console lines (Repo lifecycle,
|
|
5
|
+
* Automerge warmup, occasional sync diagnostics). E2e scripts watch the
|
|
6
|
+
* Puppeteer console stream and fail on anything unexpected; without an
|
|
7
|
+
* allowlist every run trips on the same benign noise.
|
|
8
|
+
*
|
|
9
|
+
* The allowlist is owned by polly because polly knows which lines its
|
|
10
|
+
* own code produces. Consumers extend it with their app-specific noise.
|
|
11
|
+
* Entries are tested as substrings against the rendered console message.
|
|
12
|
+
*/
|
|
13
|
+
/** Match a console line that contains the given substring. */
|
|
14
|
+
export interface ConsolePattern {
|
|
15
|
+
/** Optional console level filter — "log" | "info" | "warn" | "error".
|
|
16
|
+
* Undefined matches any level. */
|
|
17
|
+
level?: "log" | "info" | "warn" | "error";
|
|
18
|
+
/** Substring or RegExp the rendered console line must satisfy. */
|
|
19
|
+
match: string | RegExp;
|
|
20
|
+
/** Short reason — surfaces in failure messages when the allowlist
|
|
21
|
+
* evolves and an entry should be removed. */
|
|
22
|
+
reason: string;
|
|
23
|
+
}
|
|
24
|
+
export declare const MESH_CONSOLE_ALLOWLIST: ReadonlyArray<ConsolePattern>;
|
|
25
|
+
/**
|
|
26
|
+
* Return true when the console line matches any allowlist entry.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isAllowedConsoleLine(line: {
|
|
29
|
+
level: string;
|
|
30
|
+
text: string;
|
|
31
|
+
}, allowlist?: ReadonlyArray<ConsolePattern>): boolean;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fairfox/polly/test/e2e-mesh — end-to-end test kit for the mesh.
|
|
3
|
+
*
|
|
4
|
+
* Centralises the patterns every consumer's e2e scripts reinvent today:
|
|
5
|
+
* pairing-ceremony driving, convergence polling, console-noise filtering,
|
|
6
|
+
* screenshot-on-failure, and an embedded signalling relay. Fairfox and
|
|
7
|
+
* lingua import from this subpath rather than reimplementing.
|
|
8
|
+
*
|
|
9
|
+
* The kit is opinionated about the shape of the consumer it drives —
|
|
10
|
+
* pairing UI exposes stable `data-e2e-*` attributes, the bootstrap path
|
|
11
|
+
* goes through `createMeshClient`, the document state is observable via
|
|
12
|
+
* a polled DOM predicate. Consumers that follow the conventions get the
|
|
13
|
+
* full kit for free; those that diverge supply their own driver per
|
|
14
|
+
* primitive.
|
|
15
|
+
*
|
|
16
|
+
* Diagnostic obligation runs by default through {@link startDiagnosticRecorder}:
|
|
17
|
+
* unexpected silent drops on the diagnostic stream fail the script. A
|
|
18
|
+
* scenario that legitimately exercises a drop branch (e.g. revocation)
|
|
19
|
+
* passes the expected kinds to `assertNoSilentDrops({ allow: [...] })`.
|
|
20
|
+
*/
|
|
21
|
+
export { type ConsolePattern, isAllowedConsoleLine, MESH_CONSOLE_ALLOWLIST, } from "./console-allowlist";
|
|
22
|
+
export { knownPeersFor, type PrebakedKeyringPair, type PrebakedKeyringSet, type PrebakedPeer, prebakeKeyringPair, prebakeKeyringSet, } from "./keys";
|
|
23
|
+
export { type CapturedConsoleLine, type LaunchedPeer, type LaunchPeerOptions, launchPeer, } from "./launch-peer";
|
|
24
|
+
export { type DiagnosticRecorder, MeshAssertionError, type MeshAssertionFailure, startDiagnosticRecorder, } from "./mesh-assertions";
|
|
25
|
+
export { type ServeConsumerOptions, type ServeConsumerResult, serveConsumer, } from "./serve-consumer";
|
|
26
|
+
export { type ConvergencePredicate, type PeerSnapshot, type WaitForConvergenceOptions, waitForConvergence, waitForMeshConnected, } from "./wait-for-convergence";
|
|
27
|
+
export { type WithRelayOptions, type WithRelayResult, withRelay } from "./with-relay";
|