@serfab/cadre-core 1.19.1 → 1.21.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.
Files changed (103) hide show
  1. package/dist/cadre-node.d.ts +53 -14
  2. package/dist/cadre-node.js +97 -30
  3. package/dist/cadre-node.js.map +1 -1
  4. package/dist/control-database.d.ts +2 -1
  5. package/dist/control-database.js +146 -135
  6. package/dist/control-database.js.map +1 -1
  7. package/dist/control-protocol-guard.js +3 -2
  8. package/dist/control-protocol-guard.js.map +1 -1
  9. package/dist/control-stream.js +2 -1
  10. package/dist/control-stream.js.map +1 -1
  11. package/dist/describe-thrown.d.ts +12 -0
  12. package/dist/describe-thrown.js +59 -0
  13. package/dist/describe-thrown.js.map +1 -0
  14. package/dist/edge-node/dissolve.d.ts +1 -1
  15. package/dist/edge-node/dissolve.js +1 -1
  16. package/dist/edge-node/dissolve.js.map +1 -1
  17. package/dist/edge-node/edge-join.js +2 -1
  18. package/dist/edge-node/edge-join.js.map +1 -1
  19. package/dist/edge-node/edge-node.js +2 -1
  20. package/dist/edge-node/edge-node.js.map +1 -1
  21. package/dist/edge-node/strand-move.d.ts +0 -2
  22. package/dist/edge-node/strand-move.js +1 -4
  23. package/dist/edge-node/strand-move.js.map +1 -1
  24. package/dist/edge-node/strands.js +2 -1
  25. package/dist/edge-node/strands.js.map +1 -1
  26. package/dist/enrollment.js +2 -1
  27. package/dist/enrollment.js.map +1 -1
  28. package/dist/index.d.ts +3 -1
  29. package/dist/index.js +3 -0
  30. package/dist/index.js.map +1 -1
  31. package/dist/member-redemption.js +3 -9
  32. package/dist/member-redemption.js.map +1 -1
  33. package/dist/node-local-snapshot.js +2 -1
  34. package/dist/node-local-snapshot.js.map +1 -1
  35. package/dist/peer-dial.js +3 -2
  36. package/dist/peer-dial.js.map +1 -1
  37. package/dist/pending-join-runner.d.ts +29 -2
  38. package/dist/pending-join-runner.js +60 -20
  39. package/dist/pending-join-runner.js.map +1 -1
  40. package/dist/push-notifier-apns.js +8 -7
  41. package/dist/push-notifier-apns.js.map +1 -1
  42. package/dist/push-notifier-fcm.js +6 -5
  43. package/dist/push-notifier-fcm.js.map +1 -1
  44. package/dist/push-notifier-shared.d.ts +0 -2
  45. package/dist/push-notifier-shared.js +4 -4
  46. package/dist/push-notifier-shared.js.map +1 -1
  47. package/dist/relay-reservation.js +24 -4
  48. package/dist/relay-reservation.js.map +1 -1
  49. package/dist/strand-addr-protocol.js +2 -1
  50. package/dist/strand-addr-protocol.js.map +1 -1
  51. package/dist/strand-app-schema-report.d.ts +56 -0
  52. package/dist/strand-app-schema-report.js +83 -0
  53. package/dist/strand-app-schema-report.js.map +1 -0
  54. package/dist/strand-database.d.ts +9 -5
  55. package/dist/strand-database.js +12 -6
  56. package/dist/strand-database.js.map +1 -1
  57. package/dist/strand-first-sync-gate.js +4 -3
  58. package/dist/strand-first-sync-gate.js.map +1 -1
  59. package/dist/strand-formation-protocol.js +4 -3
  60. package/dist/strand-formation-protocol.js.map +1 -1
  61. package/dist/strand-instance-manager.d.ts +8 -2
  62. package/dist/strand-instance-manager.js +8 -6
  63. package/dist/strand-instance-manager.js.map +1 -1
  64. package/dist/strand-membership-reconciler.js +9 -11
  65. package/dist/strand-membership-reconciler.js.map +1 -1
  66. package/dist/strand-move.js +4 -6
  67. package/dist/strand-move.js.map +1 -1
  68. package/dist/strand-offline.d.ts +10 -39
  69. package/dist/strand-offline.js +9 -54
  70. package/dist/strand-offline.js.map +1 -1
  71. package/dist/types.d.ts +8 -5
  72. package/dist/types.js.map +1 -1
  73. package/package.json +8 -8
  74. package/src/cadre-node.ts +11528 -11456
  75. package/src/control-database.ts +5603 -5592
  76. package/src/control-protocol-guard.ts +3 -2
  77. package/src/control-stream.ts +2 -1
  78. package/src/describe-thrown.ts +60 -0
  79. package/src/edge-node/dissolve.ts +2 -1
  80. package/src/edge-node/edge-join.ts +1 -1
  81. package/src/edge-node/edge-node.ts +2 -1
  82. package/src/edge-node/strand-move.ts +1 -5
  83. package/src/edge-node/strands.ts +74 -73
  84. package/src/enrollment.ts +2 -1
  85. package/src/index.ts +924 -917
  86. package/src/member-redemption.ts +3 -9
  87. package/src/node-local-snapshot.ts +2 -1
  88. package/src/peer-dial.ts +605 -604
  89. package/src/pending-join-runner.ts +68 -22
  90. package/src/push-notifier-apns.ts +8 -7
  91. package/src/push-notifier-fcm.ts +6 -5
  92. package/src/push-notifier-shared.ts +5 -5
  93. package/src/relay-reservation.ts +1239 -1211
  94. package/src/strand-addr-protocol.ts +2 -1
  95. package/src/strand-app-schema-report.ts +122 -0
  96. package/src/strand-database.ts +474 -466
  97. package/src/strand-first-sync-gate.ts +600 -599
  98. package/src/strand-formation-protocol.ts +4 -3
  99. package/src/strand-instance-manager.ts +2219 -2210
  100. package/src/strand-membership-reconciler.ts +942 -945
  101. package/src/strand-move.ts +594 -597
  102. package/src/strand-offline.ts +11 -80
  103. package/src/types.ts +2963 -2960
@@ -31,6 +31,7 @@ import { requireEd25519PublicKeyB64 } from './ed25519-key.js';
31
31
  import { dialAddr, nextMacrotask, trailingPeerId } from './peer-dial.js';
32
32
  import { chainMessages } from './control-retry.js';
33
33
  import { isRetriableControlWriteFailure } from './control-write-retry.js';
34
+ import { toError } from './describe-thrown.js';
34
35
  import type { CadreJoinProgress } from './types.js';
35
36
 
36
37
  const log = debug('sereus:cadre:member-redemption');
@@ -424,13 +425,6 @@ function isRefusal<Accepted>(reply: Accepted | RedemptionRefusalFrame): reply is
424
425
  return (reply as { accepted?: unknown }).accepted === false;
425
426
  }
426
427
 
427
- function asError(error: unknown): Error {
428
- if (error instanceof Error) return error;
429
- // A WebSocket transport rejects a refused dial with an `ErrorEvent`, whose text is its `message`.
430
- const message = (error as { message?: unknown } | null)?.message;
431
- return new Error(typeof message === 'string' && message.length > 0 ? message : String(error), { cause: error });
432
- }
433
-
434
428
  /**
435
429
  * Run `op` with a signal that aborts when either `deadline` or the caller's `signal` does.
436
430
  * Relayed by hand rather than with `AbortSignal.any`, which the phone runtimes lack.
@@ -491,8 +485,8 @@ async function dialOnce<Accepted>(node: Libp2p, options: MemberRedemptionOptions
491
485
  } catch (error) {
492
486
  // The caller's abort cut this attempt short; its reason, not the cut, is the answer.
493
487
  options.signal?.throwIfAborted();
494
- log('%s redemption via %s failed before an answer (%s); trying the next address', options.label, addr, asError(error).message);
495
- outcomes.push({ addr, error: asError(error) });
488
+ log('%s redemption via %s failed before an answer (%s); trying the next address', options.label, addr, toError(error).message);
489
+ outcomes.push({ addr, error: toError(error) });
496
490
  continue;
497
491
  }
498
492
  if (isRefusal(reply)) {
@@ -29,6 +29,7 @@
29
29
  * (`file-durable-slot.ts`) is what stays behind the `*-store-file` subpaths.
30
30
  */
31
31
  import debug from 'debug';
32
+ import { describeThrown } from './describe-thrown.js';
32
33
 
33
34
  const log = debug('sereus:cadre:node-local-snapshot');
34
35
 
@@ -231,7 +232,7 @@ async function loadEntries<E>(
231
232
  // slot is what knows the platform detail worth acting on (which file, which
232
233
  // database).
233
234
  throw new Error(
234
- `failed to read the ${spec.label} for party ${partyId}: ${error instanceof Error ? error.message : String(error)}`,
235
+ `failed to read the ${spec.label} for party ${partyId}: ${describeThrown(error)}`,
235
236
  { cause: error }
236
237
  );
237
238
  }