@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
@@ -33,6 +33,7 @@ import { formationDeadlines } from './strand-formation-deadlines.js';
33
33
  import { MEMBERSHIP_INVITE_TTL_MS } from './strand-formation-manager.js';
34
34
  import { scheduleRuns, type TableChangeWatch, type TableChangeWatchOptions } from './table-change-watch.js';
35
35
  import { defaultTimeoutScheduler, type TimeoutScheduler } from './timeout-scheduler.js';
36
+ import { describeThrown } from './describe-thrown.js';
36
37
 
37
38
  const log = debug('sereus:cadre:pending-join');
38
39
 
@@ -100,6 +101,12 @@ export interface PendingJoinRunnerDeps {
100
101
  remove(id: string): Promise<boolean>;
101
102
  /** Whether this machine reaches no sibling now (`CadreNode.hasReachableControlSibling`), so a write it commits reaches no other machine. */
102
103
  isAlone(): boolean;
104
+ /**
105
+ * Whether a write nothing waits on must wait for a reachable sibling now
106
+ * (`CadreNode.controlWriteCouldFork`): this machine reaches none while the party has other
107
+ * machines, so another owner machine writing the same tables meanwhile would fork them.
108
+ */
109
+ deferBackgroundWrites(): Promise<boolean>;
103
110
  /** The sApp the request's invitation names. */
104
111
  sAppIdOf(join: PendingJoin): string;
105
112
  /** Every pass's joins, read by an owner machine; `CadreNode` stages the membership invitations they carry. */
@@ -119,7 +126,7 @@ interface TrackedJoin {
119
126
  /** Due, waiting for a background attempt slot. */
120
127
  queued: boolean;
121
128
  /** Set while an attempt (or a re-run of its outcome write) is running. */
122
- attempt?: Promise<void>;
129
+ attempt?: Promise<'deferred' | undefined>;
123
130
  trying: boolean;
124
131
  nextAttemptAt?: number;
125
132
  lastError?: AttemptError;
@@ -236,10 +243,6 @@ function failedOutcome(code: string, reason: string, now: number): JoinOutcome {
236
243
  return { kind: 'failed', RecordedAt: now, Code: code, Reason: reason };
237
244
  }
238
245
 
239
- function errorText(error: unknown): string {
240
- return error instanceof Error ? error.message : String(error);
241
- }
242
-
243
246
  /** A fraction in [0, 1) fixed by `key` (32-bit FNV-1a): the same machine staggers the same join the same way every time. */
244
247
  function stableFraction(key: string): number {
245
248
  let hash = 0x811c9dc5;
@@ -266,6 +269,8 @@ export class PendingJoinRunner {
266
269
  /** Every pass runs on it, one at a time; present between {@link start} and {@link stop}. */
267
270
  private watch: TableChangeWatch | null = null;
268
271
  private backgroundAttempts = 0;
272
+ /** A background write was deferred ({@link PendingJoinRunnerDeps.deferBackgroundWrites}); {@link resumeDeferredWrites} runs a pass for it. */
273
+ private deferredWrites = false;
269
274
 
270
275
  constructor(private readonly deps: PendingJoinRunnerDeps) {
271
276
  this.scheduler = deps.scheduler ?? defaultTimeoutScheduler;
@@ -311,6 +316,7 @@ export class PendingJoinRunner {
311
316
  this.tracked.clear();
312
317
  this.dueQueue.length = 0;
313
318
  this.writtenAlone.clear();
319
+ this.deferredWrites = false;
314
320
  }
315
321
 
316
322
  /**
@@ -321,14 +327,26 @@ export class PendingJoinRunner {
321
327
  this.watch?.trigger(0);
322
328
  }
323
329
 
330
+ /**
331
+ * Run a pass now if a background write was deferred while one could have forked the party
332
+ * ({@link PendingJoinRunnerDeps.deferBackgroundWrites}), so the joins it left unscheduled are
333
+ * scheduled again. Called on the control cohort's growth edge, when a sibling becomes reachable.
334
+ */
335
+ resumeDeferredWrites(): void {
336
+ if (!this.deferredWrites) return;
337
+ this.deferredWrites = false;
338
+ this.kick();
339
+ }
340
+
324
341
  /**
325
342
  * Try `join` on this machine at once, outside the background slots, and report the status
326
343
  * after the attempt. Joins an attempt already running for it.
327
344
  */
328
345
  async attemptNow(join: PendingJoin): Promise<PendingJoinStatus> {
329
346
  const entry = this.adopt(join);
330
- if (entry.row.outcome === null) {
331
- await this.startAttempt(entry);
347
+ // A background attempt already running for it may defer instead of attempting.
348
+ if (entry.row.outcome === null && await this.startAttempt(entry, false) === 'deferred') {
349
+ await this.startAttempt(entry, false);
332
350
  }
333
351
  return this.describe(entry.row, entry);
334
352
  }
@@ -387,7 +405,7 @@ export class PendingJoinRunner {
387
405
  if (entry?.row.StampId === stampId) entry.row = written;
388
406
  log('pending join %s: re-issued the join written while alone', id);
389
407
  } catch (error) {
390
- log('pending join %s: re-issuing the join written while alone failed; kept for the next connection: %s', id, errorText(error));
408
+ log('pending join %s: re-issuing the join written while alone failed; kept for the next connection: %s', id, describeThrown(error));
391
409
  }
392
410
  }
393
411
  }
@@ -408,7 +426,7 @@ export class PendingJoinRunner {
408
426
  try {
409
427
  await this.runPass();
410
428
  } catch (error) {
411
- log('pending-join pass failed; retried in 30 s: %s', errorText(error));
429
+ log('pending-join pass failed; retried in 30 s: %s', describeThrown(error));
412
430
  this.retryPass();
413
431
  }
414
432
  }
@@ -436,7 +454,7 @@ export class PendingJoinRunner {
436
454
  try {
437
455
  await this.consider(join);
438
456
  } catch (error) {
439
- log('pending join %s: this pass could not handle it; retried in 30 s: %s', join.Id, errorText(error));
457
+ log('pending join %s: this pass could not handle it; retried in 30 s: %s', join.Id, describeThrown(error));
440
458
  this.retryPass();
441
459
  }
442
460
  }
@@ -462,7 +480,7 @@ export class PendingJoinRunner {
462
480
  return;
463
481
  }
464
482
  if (entry.joinedHere || this.now() >= entry.row.ExpiresAt) {
465
- await this.startAttempt(entry);
483
+ await this.startAttempt(entry, true);
466
484
  return;
467
485
  }
468
486
  if (entry.timer === undefined && !entry.queued) {
@@ -530,15 +548,19 @@ export class PendingJoinRunner {
530
548
  entry.queued = false;
531
549
  if (entry.attempt || this.tracked.get(entry.row.Id) !== entry) continue;
532
550
  this.backgroundAttempts++;
533
- void this.startAttempt(entry).finally(() => {
551
+ void this.startAttempt(entry, true).finally(() => {
534
552
  this.backgroundAttempts--;
535
553
  this.pump();
536
554
  });
537
555
  }
538
556
  }
539
557
 
540
- /** Run one attempt for `entry`, or join the one already running. Never rejects. */
541
- private startAttempt(entry: TrackedJoin): Promise<void> {
558
+ /**
559
+ * Run one attempt for `entry`, or join the one already running. A `background` attempt (one no
560
+ * `requestJoin` asked for) is deferred while a write could fork the party ({@link attemptOnce}),
561
+ * and then resolves `'deferred'`, also for a caller that joined it. Never rejects.
562
+ */
563
+ private startAttempt(entry: TrackedJoin, background: boolean): Promise<'deferred' | undefined> {
542
564
  if (entry.attempt) return entry.attempt;
543
565
  this.cancelTimer(entry);
544
566
  if (entry.queued) {
@@ -548,13 +570,14 @@ export class PendingJoinRunner {
548
570
  // NOTE: only a join is held for re-writing (`joinedHere`); a failed write of a final failure is
549
571
  // retried by attempting again, so a `local` failure whose write failed ends up recorded as
550
572
  // `token-spent`. If apps come to branch on that code, hold failures the same way.
551
- const run = this.attemptOnce(entry)
573
+ const run = this.attemptOnce(entry, background)
552
574
  .catch((error: unknown) => {
553
575
  entry.trying = false;
554
- log('pending join %s: attempt failed on this machine: %s', entry.row.Id, errorText(error));
576
+ log('pending join %s: attempt failed on this machine: %s', entry.row.Id, describeThrown(error));
555
577
  if (entry.row.outcome === null && this.tracked.get(entry.row.Id) === entry) {
556
- this.retryLater(entry, { code: 'local', reason: errorText(error) });
578
+ this.retryLater(entry, { code: 'local', reason: describeThrown(error) });
557
579
  }
580
+ return undefined;
558
581
  })
559
582
  .finally(() => {
560
583
  entry.attempt = undefined;
@@ -563,12 +586,22 @@ export class PendingJoinRunner {
563
586
  return run;
564
587
  }
565
588
 
566
- private async attemptOnce(entry: TrackedJoin): Promise<void> {
589
+ /**
590
+ * One attempt, or the write it is due. A join this machine already made is recorded whatever
591
+ * else holds: kept only in memory, it would be lost with a restart, and the next start's
592
+ * attempt would fail the join as `token-spent`. Otherwise a background attempt, and the
593
+ * `expired` outcome due in its place, are deferred while a write could fork the party.
594
+ */
595
+ private async attemptOnce(entry: TrackedJoin, background: boolean): Promise<'deferred' | undefined> {
567
596
  if (entry.row.outcome !== null) return;
568
597
  if (entry.joinedHere) {
569
598
  await this.writeOutcome(entry, entry.joinedHere);
570
599
  return;
571
600
  }
601
+ if (background && await this.deps.deferBackgroundWrites()) {
602
+ this.deferAttempt(entry);
603
+ return 'deferred';
604
+ }
572
605
  if (this.now() >= entry.row.ExpiresAt) {
573
606
  const reason = `No attempt starts after ${new Date(entry.row.ExpiresAt).toISOString()}`;
574
607
  await this.writeOutcome(entry, failedOutcome('expired', reason, this.now()));
@@ -591,6 +624,14 @@ export class PendingJoinRunner {
591
624
  await this.writeOutcome(entry, entry.joinedHere);
592
625
  }
593
626
 
627
+ /** Leave `entry` unscheduled; the pass {@link resumeDeferredWrites} runs schedules it again. */
628
+ private deferAttempt(entry: TrackedJoin): void {
629
+ entry.nextAttemptAt = undefined;
630
+ this.deferredWrites = true;
631
+ log('pending join %s: background attempt deferred until a sibling is reachable', entry.row.Id);
632
+ this.emitIfChanged(entry);
633
+ }
634
+
594
635
  /** Read a failed attempt: retry, confirm a spent token, or fail the join. */
595
636
  private async onAttemptFailed(entry: TrackedJoin, error: unknown): Promise<void> {
596
637
  const now = this.now();
@@ -608,8 +649,8 @@ export class PendingJoinRunner {
608
649
  this.retryLater(entry, { code: 'unreachable', reason: error.message });
609
650
  } else {
610
651
  // Retrying is safe: nothing is attempted after the request's expiry.
611
- log('pending join %s: attempt threw an unexpected error; retrying: %s', entry.row.Id, errorText(error));
612
- this.retryLater(entry, { code: 'local', reason: errorText(error) });
652
+ log('pending join %s: attempt threw an unexpected error; retrying: %s', entry.row.Id, describeThrown(error));
653
+ this.retryLater(entry, { code: 'local', reason: describeThrown(error) });
613
654
  }
614
655
  }
615
656
 
@@ -698,7 +739,8 @@ export class PendingJoinRunner {
698
739
  /**
699
740
  * Remove a finished join {@link MEMBERSHIP_INVITE_TTL_MS} after its outcome: the membership
700
741
  * invitation it carries is dead by then, and an app that was not running has seen the strand
701
- * through `strand:discovered`. Only while connected, like every write nothing waits on.
742
+ * through `strand:discovered`. Deferred while a write could fork the party, like every write
743
+ * nothing waits on.
702
744
  *
703
745
  * NOTE: `deletePendingJoin` removes whichever incarnation is live, so a `requestJoin` of the
704
746
  * same invitation landing on another machine in the same instant can be removed with it. The
@@ -706,7 +748,11 @@ export class PendingJoinRunner {
706
748
  */
707
749
  private async ageOut(entry: TrackedJoin): Promise<void> {
708
750
  const recordedAt = entry.row.outcome?.RecordedAt;
709
- if (recordedAt === undefined || this.now() < recordedAt + MEMBERSHIP_INVITE_TTL_MS || this.deps.isAlone()) return;
751
+ if (recordedAt === undefined || this.now() < recordedAt + MEMBERSHIP_INVITE_TTL_MS) return;
752
+ if (await this.deps.deferBackgroundWrites()) {
753
+ this.deferredWrites = true;
754
+ return;
755
+ }
710
756
  await this.deps.remove(entry.row.Id);
711
757
  log('pending join %s: removed, %d days after its outcome', entry.row.Id, MEMBERSHIP_INVITE_TTL_MS / (24 * 3600_000));
712
758
  this.forget(entry);
@@ -32,7 +32,8 @@ import { connect, type ClientHttp2Session } from 'node:http2';
32
32
  import debug from 'debug';
33
33
  import type { ApnsCredentials } from './types.js';
34
34
  import type { PushMessage, PushNotifier, PushSendResult } from './push-notifier.js';
35
- import { MAX_REASON_LEN, b64urlJson, errText, redact } from './push-notifier-shared.js';
35
+ import { MAX_REASON_LEN, b64urlJson, redact } from './push-notifier-shared.js';
36
+ import { describeThrown } from './describe-thrown.js';
36
37
 
37
38
  const APNS_PROD_HOST = 'https://api.push.apple.com';
38
39
  const APNS_SANDBOX_HOST = 'https://api.sandbox.push.apple.com';
@@ -95,8 +96,8 @@ export function createApnsPushNotifier(creds: ApnsCredentials, deps: ApnsPushDep
95
96
  try {
96
97
  jwt = providerToken(false);
97
98
  } catch (err) {
98
- log(`provider-token mint failed: ${errText(err)}`);
99
- return { ok: false, unregistered: false, error: `apns jwt mint failed: ${errText(err)}` };
99
+ log(`provider-token mint failed: ${describeThrown(err)}`);
100
+ return { ok: false, unregistered: false, error: `apns jwt mint failed: ${describeThrown(err)}` };
100
101
  }
101
102
 
102
103
  let res = await tryRequest(msg, jwt);
@@ -107,8 +108,8 @@ export function createApnsPushNotifier(creds: ApnsCredentials, deps: ApnsPushDep
107
108
  try {
108
109
  jwt = providerToken(true);
109
110
  } catch (err) {
110
- log(`provider-token re-mint failed: ${errText(err)}`);
111
- return { ok: false, unregistered: false, error: `apns jwt re-mint failed: ${errText(err)}` };
111
+ log(`provider-token re-mint failed: ${describeThrown(err)}`);
112
+ return { ok: false, unregistered: false, error: `apns jwt re-mint failed: ${describeThrown(err)}` };
112
113
  }
113
114
  res = await tryRequest(msg, jwt);
114
115
  if (!res) return { ok: false, unregistered: false, error: `apns transport failed (token=${redact(msg.token)})` };
@@ -127,11 +128,11 @@ export function createApnsPushNotifier(creds: ApnsCredentials, deps: ApnsPushDep
127
128
  try {
128
129
  return await transport.request(req);
129
130
  } catch (err1) {
130
- log(`http2 request failed, re-establishing once: ${errText(err1)}`);
131
+ log(`http2 request failed, re-establishing once: ${describeThrown(err1)}`);
131
132
  try {
132
133
  return await transport.request(req);
133
134
  } catch (err2) {
134
- log(`http2 request failed after re-establish: ${errText(err2)}`);
135
+ log(`http2 request failed after re-establish: ${describeThrown(err2)}`);
135
136
  return null;
136
137
  }
137
138
  }
@@ -24,7 +24,8 @@ import { sign } from 'node:crypto';
24
24
  import debug from 'debug';
25
25
  import type { FcmCredentials } from './types.js';
26
26
  import type { PushMessage, PushNotifier, PushSendResult } from './push-notifier.js';
27
- import { MAX_REASON_LEN, b64urlJson, errText, redact } from './push-notifier-shared.js';
27
+ import { MAX_REASON_LEN, b64urlJson, redact } from './push-notifier-shared.js';
28
+ import { describeThrown } from './describe-thrown.js';
28
29
 
29
30
  const TOKEN_ENDPOINT = 'https://oauth2.googleapis.com/token';
30
31
  const FCM_SCOPE = 'https://www.googleapis.com/auth/firebase.messaging';
@@ -77,8 +78,8 @@ export function createFcmPushNotifier(creds: FcmCredentials, deps: FcmPushDeps =
77
78
  try {
78
79
  token = await accessToken(false);
79
80
  } catch (err) {
80
- log(`oauth mint failed: ${errText(err)}`);
81
- return { ok: false, unregistered: false, error: `fcm oauth mint failed: ${errText(err)}` };
81
+ log(`oauth mint failed: ${describeThrown(err)}`);
82
+ return { ok: false, unregistered: false, error: `fcm oauth mint failed: ${describeThrown(err)}` };
82
83
  }
83
84
 
84
85
  const first = await postSend(msg, token);
@@ -90,8 +91,8 @@ export function createFcmPushNotifier(creds: FcmCredentials, deps: FcmPushDeps =
90
91
  try {
91
92
  retryToken = await accessToken(true);
92
93
  } catch (err) {
93
- log(`oauth re-mint failed: ${errText(err)}`);
94
- return { ok: false, unregistered: false, error: `fcm oauth re-mint failed: ${errText(err)}` };
94
+ log(`oauth re-mint failed: ${describeThrown(err)}`);
95
+ return { ok: false, unregistered: false, error: `fcm oauth re-mint failed: ${describeThrown(err)}` };
95
96
  }
96
97
  return mapResult(await postSend(msg, retryToken), msg.token);
97
98
  }
@@ -6,6 +6,11 @@
6
6
  * single, hardenable source rather than drifting between the two transports.
7
7
  */
8
8
 
9
+ // NOTE: the notifiers describe caught values with `describeThrown`, which turns a thrown non-Error
10
+ // object into JSON; every thrower on their paths (node:crypto, fetch, node:http2) throws an Error
11
+ // today. If one ever throws an object that can carry a key or an OAuth token, describe it here
12
+ // without serializing it.
13
+
9
14
  /** Defensive cap on the free-form `reason` carried in a strand-wake payload. */
10
15
  export const MAX_REASON_LEN = 256;
11
16
 
@@ -14,11 +19,6 @@ export function b64urlJson(obj: unknown): string {
14
19
  return Buffer.from(JSON.stringify(obj)).toString('base64url');
15
20
  }
16
21
 
17
- /** A short, secret-free string for an unknown thrown value. */
18
- export function errText(err: unknown): string {
19
- return err instanceof Error ? err.message : String(err);
20
- }
21
-
22
22
  /**
23
23
  * Redact a device token to a short, non-reversible prefix for debug lines — the
24
24
  * full FCM/APNs token is a secret and must never reach a log.