@fairfox/polly 0.72.0 → 0.73.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/src/elysia/index.js +464 -4
  2. package/dist/src/elysia/index.js.map +6 -4
  3. package/dist/src/peer.d.ts +2 -0
  4. package/dist/src/peer.js +468 -4
  5. package/dist/src/peer.js.map +8 -5
  6. package/dist/src/polly-ui/ActionInput.d.ts +2 -1
  7. package/dist/src/polly-ui/ActionSelect.d.ts +2 -1
  8. package/dist/src/polly-ui/Button.d.ts +4 -0
  9. package/dist/src/polly-ui/Cluster.d.ts +2 -1
  10. package/dist/src/polly-ui/Code.d.ts +2 -1
  11. package/dist/src/polly-ui/Dropdown.d.ts +6 -0
  12. package/dist/src/polly-ui/Surface.d.ts +12 -1
  13. package/dist/src/polly-ui/Text.d.ts +23 -11
  14. package/dist/src/polly-ui/index.css +44 -18
  15. package/dist/src/polly-ui/index.js +118 -12
  16. package/dist/src/polly-ui/index.js.map +12 -11
  17. package/dist/src/polly-ui/internal/passthrough.d.ts +25 -0
  18. package/dist/src/polly-ui/styles.css +59 -18
  19. package/dist/src/polly-ui/theme.css +1 -0
  20. package/dist/src/shared/lib/peer-repo-server.d.ts +18 -0
  21. package/dist/src/shared/lib/sweep-sealed.d.ts +111 -0
  22. package/dist/tools/test/src/browser/run.js +42 -33
  23. package/dist/tools/test/src/browser/run.js.map +6 -5
  24. package/dist/tools/test/src/browser/runner-core.d.ts +32 -0
  25. package/dist/tools/test/src/e2e-mesh/index.js +193 -171
  26. package/dist/tools/test/src/e2e-mesh/index.js.map +4 -4
  27. package/dist/tools/test/src/visual/index.js +248 -229
  28. package/dist/tools/test/src/visual/index.js.map +5 -5
  29. package/dist/tools/verify/specs/tla/MeshSeed.cfg +27 -0
  30. package/dist/tools/verify/specs/tla/MeshSeed.tla +179 -0
  31. package/dist/tools/verify/specs/tla/README.md +11 -1
  32. package/dist/tools/verify/src/cli.js +79 -2
  33. package/dist/tools/verify/src/cli.js.map +7 -6
  34. package/dist/tools/visualize/src/cli.js +179 -3
  35. package/dist/tools/visualize/src/cli.js.map +6 -6
  36. package/package.json +3 -2
@@ -162,174 +162,25 @@ var init_encryption = __esm(() => {
162
162
  };
163
163
  });
164
164
 
165
- // tools/test/src/e2e-mesh/console-allowlist.ts
166
- var MESH_CONSOLE_ALLOWLIST = [
167
- {
168
- match: "[polly#107 H5]",
169
- reason: "polly#107 H5 warning fires whenever $meshState resolves against an unconfigured module instance during normal warmup; the issue tracks the longer fix."
170
- },
171
- {
172
- match: "automerge",
173
- level: "log",
174
- reason: "Automerge logs its own version banner at log level on first import; benign."
175
- },
176
- {
177
- match: "using deprecated parameters for `initSync()`",
178
- reason: "Automerge WASM bundler emits a deprecation warning on first init; upstream noise polly cannot suppress without a forked bundle."
179
- },
180
- {
181
- match: "Failed to load resource",
182
- level: "error",
183
- reason: "Puppeteer logs a 404 for /favicon.ico against the in-tree consumer because the consumer does not ship one; the e2e harness only cares about app-level errors."
184
- }
185
- ];
186
- function isAllowedConsoleLine(line, allowlist = MESH_CONSOLE_ALLOWLIST) {
187
- for (const entry of allowlist) {
188
- if (entry.level && entry.level !== line.level)
189
- continue;
190
- if (typeof entry.match === "string") {
191
- if (line.text.includes(entry.match))
192
- return true;
193
- } else if (entry.match.test(line.text)) {
194
- return true;
195
- }
196
- }
197
- return false;
198
- }
199
- // tools/test/src/e2e-mesh/keys.ts
200
- init_encryption();
201
-
202
- // src/shared/lib/signing.ts
203
- import nacl2 from "tweetnacl";
204
- var PUBLIC_KEY_BYTES = 32;
205
- var SECRET_KEY_BYTES = 64;
206
- var SIGNATURE_BYTES = 64;
207
-
208
- class SigningError extends Error {
209
- code;
210
- constructor(message, code) {
211
- super(message);
212
- this.name = "SigningError";
213
- this.code = code;
214
- }
215
- }
216
- function generateSigningKeyPair() {
217
- const pair = nacl2.sign.keyPair();
218
- return {
219
- publicKey: pair.publicKey,
220
- secretKey: pair.secretKey
221
- };
222
- }
223
- function signingKeyPairFromSecret(secretKey) {
224
- if (secretKey.length !== SECRET_KEY_BYTES) {
225
- throw new SigningError(`Ed25519 secret key must be ${SECRET_KEY_BYTES} bytes, got ${secretKey.length}.`, "invalid-secret-key");
226
- }
227
- const pair = nacl2.sign.keyPair.fromSecretKey(secretKey);
228
- return {
229
- publicKey: pair.publicKey,
230
- secretKey: pair.secretKey
231
- };
232
- }
233
- function sign(payload, secretKey) {
234
- if (secretKey.length !== SECRET_KEY_BYTES) {
235
- throw new SigningError(`Ed25519 secret key must be ${SECRET_KEY_BYTES} bytes, got ${secretKey.length}.`, "invalid-secret-key");
236
- }
237
- return nacl2.sign.detached(payload, secretKey);
238
- }
239
- function verify(payload, signature, publicKey) {
240
- if (publicKey.length !== PUBLIC_KEY_BYTES) {
241
- throw new SigningError(`Ed25519 public key must be ${PUBLIC_KEY_BYTES} bytes, got ${publicKey.length}.`, "invalid-public-key");
242
- }
243
- if (signature.length !== SIGNATURE_BYTES) {
244
- throw new SigningError(`Ed25519 signature must be ${SIGNATURE_BYTES} bytes, got ${signature.length}.`, "invalid-signature-length");
245
- }
246
- return nacl2.sign.detached.verify(payload, signature, publicKey);
247
- }
248
- function signEnvelope(payload, senderId, secretKey) {
249
- const signature = sign(payload, secretKey);
250
- return { senderId, payload, signature };
251
- }
252
- function openEnvelope2(envelope, publicKey) {
253
- const ok = verify(envelope.payload, envelope.signature, publicKey);
254
- if (!ok) {
255
- throw new SigningError(`Signature verification failed for envelope from ${envelope.senderId}.`, "envelope-malformed");
256
- }
257
- return envelope.payload;
258
- }
259
- function encodeSignedEnvelope(envelope) {
260
- const senderBytes = new TextEncoder().encode(envelope.senderId);
261
- const total = 4 + senderBytes.length + SIGNATURE_BYTES + envelope.payload.length;
262
- const out = new Uint8Array(total);
263
- const view = new DataView(out.buffer);
264
- view.setUint32(0, senderBytes.length, false);
265
- out.set(senderBytes, 4);
266
- out.set(envelope.signature, 4 + senderBytes.length);
267
- out.set(envelope.payload, 4 + senderBytes.length + SIGNATURE_BYTES);
268
- return out;
269
- }
270
- function decodeSignedEnvelope(bytes) {
271
- if (bytes.length < 4 + SIGNATURE_BYTES) {
272
- throw new SigningError(`Envelope too short: ${bytes.length} bytes, need at least ${4 + SIGNATURE_BYTES}.`, "envelope-malformed");
273
- }
274
- const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
275
- const senderLen = view.getUint32(0, false);
276
- if (bytes.length < 4 + senderLen + SIGNATURE_BYTES) {
277
- throw new SigningError(`Envelope truncated: declared sender length ${senderLen}, total ${bytes.length}.`, "envelope-malformed");
278
- }
279
- const senderId = new TextDecoder().decode(bytes.subarray(4, 4 + senderLen));
280
- const signature = bytes.slice(4 + senderLen, 4 + senderLen + SIGNATURE_BYTES);
281
- const payload = bytes.slice(4 + senderLen + SIGNATURE_BYTES);
282
- return { senderId, payload, signature };
283
- }
284
-
285
- // tools/test/src/e2e-mesh/keys.ts
286
- function toBase64(bytes) {
287
- let binary = "";
288
- for (let i = 0;i < bytes.byteLength; i++) {
289
- binary += String.fromCharCode(bytes[i]);
290
- }
291
- return btoa(binary);
292
- }
293
- function prebakeKeyringPair(peerIdA = "peer-a", peerIdB = "peer-b") {
294
- const set = prebakeKeyringSet([peerIdA, peerIdB]);
295
- return {
296
- peers: [set.peers[0], set.peers[1]],
297
- docKeyB64: set.docKeyB64
298
- };
299
- }
300
- function prebakeKeyringSet(peerIds) {
301
- if (peerIds.length < 2) {
302
- throw new Error("prebakeKeyringSet: at least two peer ids required");
303
- }
304
- const docKey = generateDocumentKey();
305
- const peers = peerIds.map((peerId) => {
306
- const pair = generateSigningKeyPair();
307
- return {
308
- peerId,
309
- identitySecretKeyB64: toBase64(pair.secretKey),
310
- identityPublicKeyB64: toBase64(pair.publicKey)
311
- };
312
- });
313
- return { peers, docKeyB64: toBase64(docKey) };
314
- }
315
- function knownPeersFor(set, thisPeerId) {
316
- const out = {};
317
- for (const peer of set.peers) {
318
- if (peer.peerId === thisPeerId)
319
- continue;
320
- out[peer.peerId] = peer.identityPublicKeyB64;
321
- }
322
- return out;
323
- }
324
- // tools/test/src/e2e-mesh/launch-peer.ts
325
- var {existsSync, mkdirSync, rmSync} = (() => ({}));
326
-
327
- // node:os
328
- var tmpdir = function() {
329
- return "/tmp";
330
- };
331
-
332
165
  // node:path
166
+ var exports_path = {};
167
+ __export(exports_path, {
168
+ sep: () => sep,
169
+ resolve: () => resolve,
170
+ relative: () => relative,
171
+ posix: () => posix,
172
+ parse: () => parse,
173
+ normalize: () => normalize,
174
+ join: () => join,
175
+ isAbsolute: () => isAbsolute,
176
+ format: () => format,
177
+ extname: () => extname,
178
+ dirname: () => dirname,
179
+ delimiter: () => delimiter,
180
+ default: () => path_default,
181
+ basename: () => basename,
182
+ _makeLong: () => _makeLong
183
+ });
333
184
  function assertPath(path) {
334
185
  if (typeof path !== "string")
335
186
  throw TypeError("Path must be a string. Received " + JSON.stringify(path));
@@ -645,11 +496,181 @@ function parse(path) {
645
496
  ret.dir = "/";
646
497
  return ret;
647
498
  }
648
- var sep = "/";
649
- var delimiter = ":";
650
- var posix = ((p) => (p.posix = p, p))({ resolve, normalize, isAbsolute, join, relative, _makeLong, dirname, basename, extname, format, parse, sep, delimiter, win32: null, posix: null });
499
+ var sep = "/", delimiter = ":", posix, path_default;
500
+ var init_path = __esm(() => {
501
+ posix = ((p) => (p.posix = p, p))({ resolve, normalize, isAbsolute, join, relative, _makeLong, dirname, basename, extname, format, parse, sep, delimiter, win32: null, posix: null });
502
+ path_default = posix;
503
+ });
504
+
505
+ // tools/test/src/e2e-mesh/console-allowlist.ts
506
+ var MESH_CONSOLE_ALLOWLIST = [
507
+ {
508
+ match: "[polly#107 H5]",
509
+ reason: "polly#107 H5 warning fires whenever $meshState resolves against an unconfigured module instance during normal warmup; the issue tracks the longer fix."
510
+ },
511
+ {
512
+ match: "automerge",
513
+ level: "log",
514
+ reason: "Automerge logs its own version banner at log level on first import; benign."
515
+ },
516
+ {
517
+ match: "using deprecated parameters for `initSync()`",
518
+ reason: "Automerge WASM bundler emits a deprecation warning on first init; upstream noise polly cannot suppress without a forked bundle."
519
+ },
520
+ {
521
+ match: "Failed to load resource",
522
+ level: "error",
523
+ reason: "Puppeteer logs a 404 for /favicon.ico against the in-tree consumer because the consumer does not ship one; the e2e harness only cares about app-level errors."
524
+ }
525
+ ];
526
+ function isAllowedConsoleLine(line, allowlist = MESH_CONSOLE_ALLOWLIST) {
527
+ for (const entry of allowlist) {
528
+ if (entry.level && entry.level !== line.level)
529
+ continue;
530
+ if (typeof entry.match === "string") {
531
+ if (line.text.includes(entry.match))
532
+ return true;
533
+ } else if (entry.match.test(line.text)) {
534
+ return true;
535
+ }
536
+ }
537
+ return false;
538
+ }
539
+ // tools/test/src/e2e-mesh/keys.ts
540
+ init_encryption();
541
+
542
+ // src/shared/lib/signing.ts
543
+ import nacl2 from "tweetnacl";
544
+ var PUBLIC_KEY_BYTES = 32;
545
+ var SECRET_KEY_BYTES = 64;
546
+ var SIGNATURE_BYTES = 64;
547
+
548
+ class SigningError extends Error {
549
+ code;
550
+ constructor(message, code) {
551
+ super(message);
552
+ this.name = "SigningError";
553
+ this.code = code;
554
+ }
555
+ }
556
+ function generateSigningKeyPair() {
557
+ const pair = nacl2.sign.keyPair();
558
+ return {
559
+ publicKey: pair.publicKey,
560
+ secretKey: pair.secretKey
561
+ };
562
+ }
563
+ function signingKeyPairFromSecret(secretKey) {
564
+ if (secretKey.length !== SECRET_KEY_BYTES) {
565
+ throw new SigningError(`Ed25519 secret key must be ${SECRET_KEY_BYTES} bytes, got ${secretKey.length}.`, "invalid-secret-key");
566
+ }
567
+ const pair = nacl2.sign.keyPair.fromSecretKey(secretKey);
568
+ return {
569
+ publicKey: pair.publicKey,
570
+ secretKey: pair.secretKey
571
+ };
572
+ }
573
+ function sign(payload, secretKey) {
574
+ if (secretKey.length !== SECRET_KEY_BYTES) {
575
+ throw new SigningError(`Ed25519 secret key must be ${SECRET_KEY_BYTES} bytes, got ${secretKey.length}.`, "invalid-secret-key");
576
+ }
577
+ return nacl2.sign.detached(payload, secretKey);
578
+ }
579
+ function verify(payload, signature, publicKey) {
580
+ if (publicKey.length !== PUBLIC_KEY_BYTES) {
581
+ throw new SigningError(`Ed25519 public key must be ${PUBLIC_KEY_BYTES} bytes, got ${publicKey.length}.`, "invalid-public-key");
582
+ }
583
+ if (signature.length !== SIGNATURE_BYTES) {
584
+ throw new SigningError(`Ed25519 signature must be ${SIGNATURE_BYTES} bytes, got ${signature.length}.`, "invalid-signature-length");
585
+ }
586
+ return nacl2.sign.detached.verify(payload, signature, publicKey);
587
+ }
588
+ function signEnvelope(payload, senderId, secretKey) {
589
+ const signature = sign(payload, secretKey);
590
+ return { senderId, payload, signature };
591
+ }
592
+ function openEnvelope2(envelope, publicKey) {
593
+ const ok = verify(envelope.payload, envelope.signature, publicKey);
594
+ if (!ok) {
595
+ throw new SigningError(`Signature verification failed for envelope from ${envelope.senderId}.`, "envelope-malformed");
596
+ }
597
+ return envelope.payload;
598
+ }
599
+ function encodeSignedEnvelope(envelope) {
600
+ const senderBytes = new TextEncoder().encode(envelope.senderId);
601
+ const total = 4 + senderBytes.length + SIGNATURE_BYTES + envelope.payload.length;
602
+ const out = new Uint8Array(total);
603
+ const view = new DataView(out.buffer);
604
+ view.setUint32(0, senderBytes.length, false);
605
+ out.set(senderBytes, 4);
606
+ out.set(envelope.signature, 4 + senderBytes.length);
607
+ out.set(envelope.payload, 4 + senderBytes.length + SIGNATURE_BYTES);
608
+ return out;
609
+ }
610
+ function decodeSignedEnvelope(bytes) {
611
+ if (bytes.length < 4 + SIGNATURE_BYTES) {
612
+ throw new SigningError(`Envelope too short: ${bytes.length} bytes, need at least ${4 + SIGNATURE_BYTES}.`, "envelope-malformed");
613
+ }
614
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
615
+ const senderLen = view.getUint32(0, false);
616
+ if (bytes.length < 4 + senderLen + SIGNATURE_BYTES) {
617
+ throw new SigningError(`Envelope truncated: declared sender length ${senderLen}, total ${bytes.length}.`, "envelope-malformed");
618
+ }
619
+ const senderId = new TextDecoder().decode(bytes.subarray(4, 4 + senderLen));
620
+ const signature = bytes.slice(4 + senderLen, 4 + senderLen + SIGNATURE_BYTES);
621
+ const payload = bytes.slice(4 + senderLen + SIGNATURE_BYTES);
622
+ return { senderId, payload, signature };
623
+ }
624
+
625
+ // tools/test/src/e2e-mesh/keys.ts
626
+ function toBase64(bytes) {
627
+ let binary = "";
628
+ for (let i = 0;i < bytes.byteLength; i++) {
629
+ binary += String.fromCharCode(bytes[i]);
630
+ }
631
+ return btoa(binary);
632
+ }
633
+ function prebakeKeyringPair(peerIdA = "peer-a", peerIdB = "peer-b") {
634
+ const set = prebakeKeyringSet([peerIdA, peerIdB]);
635
+ return {
636
+ peers: [set.peers[0], set.peers[1]],
637
+ docKeyB64: set.docKeyB64
638
+ };
639
+ }
640
+ function prebakeKeyringSet(peerIds) {
641
+ if (peerIds.length < 2) {
642
+ throw new Error("prebakeKeyringSet: at least two peer ids required");
643
+ }
644
+ const docKey = generateDocumentKey();
645
+ const peers = peerIds.map((peerId) => {
646
+ const pair = generateSigningKeyPair();
647
+ return {
648
+ peerId,
649
+ identitySecretKeyB64: toBase64(pair.secretKey),
650
+ identityPublicKeyB64: toBase64(pair.publicKey)
651
+ };
652
+ });
653
+ return { peers, docKeyB64: toBase64(docKey) };
654
+ }
655
+ function knownPeersFor(set, thisPeerId) {
656
+ const out = {};
657
+ for (const peer of set.peers) {
658
+ if (peer.peerId === thisPeerId)
659
+ continue;
660
+ out[peer.peerId] = peer.identityPublicKeyB64;
661
+ }
662
+ return out;
663
+ }
664
+ // tools/test/src/e2e-mesh/launch-peer.ts
665
+ var {existsSync, mkdirSync, rmSync} = (() => ({}));
666
+
667
+ // node:os
668
+ var tmpdir = function() {
669
+ return "/tmp";
670
+ };
651
671
 
652
672
  // tools/test/src/e2e-mesh/launch-peer.ts
673
+ init_path();
653
674
  import puppeteer from "puppeteer";
654
675
 
655
676
  // src/shared/lib/mesh-diagnostics.ts
@@ -921,6 +942,7 @@ ${summary}`, unexpected);
921
942
  };
922
943
  }
923
944
  // tools/test/src/e2e-mesh/serve-consumer.ts
945
+ init_path();
924
946
  var {readFileSync} = (() => ({}));
925
947
  var __dirname = "/Users/AJT/projects/polly/packages/polly/tools/test/src/e2e-mesh";
926
948
  var pollyRoot = resolve(__dirname, "../../../..");
@@ -1180,4 +1202,4 @@ export {
1180
1202
  MESH_CONSOLE_ALLOWLIST
1181
1203
  };
1182
1204
 
1183
- //# debugId=2D797840A9246AEE64756E2164756E21
1205
+ //# debugId=5450AD59549265DC64756E2164756E21