@serfab/cadre-core 1.10.0 → 1.11.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 (61) hide show
  1. package/dist/cadre-node.d.ts +0 -27
  2. package/dist/cadre-node.js +2 -94
  3. package/dist/cadre-node.js.map +1 -1
  4. package/dist/control-schema.js +1066 -1066
  5. package/dist/diagnostics/connection-path.d.ts +1 -18
  6. package/dist/diagnostics/connection-path.js +1 -20
  7. package/dist/diagnostics/connection-path.js.map +1 -1
  8. package/dist/identity-key.d.ts +0 -30
  9. package/dist/identity-key.js +7 -40
  10. package/dist/identity-key.js.map +1 -1
  11. package/dist/index.d.ts +3 -2
  12. package/dist/index.js +6 -4
  13. package/dist/index.js.map +1 -1
  14. package/dist/relay-stun.d.ts +24 -0
  15. package/dist/relay-stun.js +51 -0
  16. package/dist/relay-stun.js.map +1 -0
  17. package/dist/seed-bootstrap.js +4 -4
  18. package/dist/strand-membership-writer.js +32 -32
  19. package/package.json +2 -2
  20. package/src/cadre-node.ts +8654 -8753
  21. package/src/control-authorization.ts +117 -117
  22. package/src/control-cohort.ts +128 -128
  23. package/src/control-formation-recorder.ts +353 -353
  24. package/src/control-read-retry.ts +216 -216
  25. package/src/control-schema.ts +1078 -1078
  26. package/src/control-write-retry.ts +567 -567
  27. package/src/diagnostics/connection-path.ts +1 -29
  28. package/src/formation-approval.ts +610 -610
  29. package/src/hibernation-manager.ts +638 -638
  30. package/src/identity-key.ts +7 -62
  31. package/src/index.ts +644 -647
  32. package/src/invitation-bootstrap.ts +40 -40
  33. package/src/joined-strand-store.ts +498 -498
  34. package/src/link-budget.ts +684 -684
  35. package/src/membership-connection-gater.ts +570 -570
  36. package/src/node-local-snapshot.ts +298 -298
  37. package/src/peer-dial.ts +315 -315
  38. package/src/peer-join-backfill.ts +710 -710
  39. package/src/pending-join-runner.ts +735 -735
  40. package/src/relay-reservation.ts +1121 -1121
  41. package/src/relay-server.ts +98 -98
  42. package/src/relay-stun.ts +58 -0
  43. package/src/seed-bootstrap.ts +1448 -1448
  44. package/src/strand-addr-protocol.ts +547 -547
  45. package/src/strand-database.ts +287 -287
  46. package/src/strand-first-sync-gate.ts +391 -391
  47. package/src/strand-formation-deadlines.ts +227 -227
  48. package/src/strand-formation-manager.ts +725 -725
  49. package/src/strand-fret-addrs.ts +145 -145
  50. package/src/strand-instance-manager.ts +1789 -1789
  51. package/src/strand-membership-writer.ts +1974 -1974
  52. package/src/strand-network-state-file.ts +40 -40
  53. package/src/strand-network-state.ts +243 -243
  54. package/src/strand-revocation-enforcer.ts +654 -654
  55. package/src/strand-solicitation.ts +532 -532
  56. package/src/strand-wake-protocol.ts +401 -401
  57. package/src/types.ts +2222 -2222
  58. package/dist/diagnostics/webrtc-turn-tracker.d.ts +0 -50
  59. package/dist/diagnostics/webrtc-turn-tracker.js +0 -196
  60. package/dist/diagnostics/webrtc-turn-tracker.js.map +0 -1
  61. package/src/diagnostics/webrtc-turn-tracker.ts +0 -222
@@ -1,20 +1,16 @@
1
1
  /**
2
2
  * identity-key — the load-or-create rule for a {@link KeyStore}-backed node
3
- * identity, plus the "prove you hold this node key" signer built on top of it.
4
- *
5
- * Both live here because both are needed *outside* `CadreNode`: an embedding app
6
- * (the React Native reference app) has to resolve its identity key before the node
7
- * is constructed, so it can sign an out-of-band HTTP request with the same key the
8
- * node will then load. Keeping one copy of the load-or-create rule is load-bearing
9
- * — a second copy that drifted could generate a fresh key and orphan the real
10
3
  * identity.
11
4
  *
12
- * Dependency-free beyond `@libp2p/crypto` + `uint8arrays` (both already core
13
- * dependencies), so this module is safe in every (RN / browser / Node) entry graph.
5
+ * Exported beyond `CadreNode` because an embedding app may need its identity key
6
+ * before the node is constructed. Keeping one copy of the rule is load-bearing — a
7
+ * second copy that drifted could generate a fresh key and orphan the real identity.
8
+ *
9
+ * Dependency-free beyond `@libp2p/crypto` (already a core dependency), so this
10
+ * module is safe in every (RN / browser / Node) entry graph.
14
11
  */
15
12
  import debug from 'debug';
16
- import { generateKeyPair, privateKeyToProtobuf, privateKeyFromProtobuf, publicKeyToProtobuf } from '@libp2p/crypto/keys';
17
- import { toString as uint8ArrayToString } from 'uint8arrays';
13
+ import { generateKeyPair, privateKeyToProtobuf, privateKeyFromProtobuf } from '@libp2p/crypto/keys';
18
14
  import type { PrivateKey } from '@libp2p/interface';
19
15
  import { DEFAULT_IDENTITY_KEY_ID, type KeyId, type KeyStore } from './key-store.js';
20
16
 
@@ -56,54 +52,3 @@ export async function loadOrCreateIdentityKey(
56
52
  log('Identity key generated and persisted to key store (first run)');
57
53
  return generated;
58
54
  }
59
-
60
- /**
61
- * Proof-of-possession signer for a node key, for out-of-band HTTP services that
62
- * want to attribute a request to a peer id.
63
- *
64
- * Deliberately generic — it carries no ICE/TURN vocabulary, and the message it
65
- * signs is the caller's business. The one consumer today is the reference apps'
66
- * `loadIceConfig`, which signs the TURN credential issuer's peer assertion; those
67
- * files mirror this interface structurally rather than importing it, so they stay
68
- * dependency-free.
69
- */
70
- export interface PeerKeySigner {
71
- /** base58btc peer id — the same string libp2p reports for this node. */
72
- readonly peerId: string;
73
- /** base64url of the libp2p protobuf-encoded public key. */
74
- readonly publicKeyB64: string;
75
- /** Sign the UTF-8 bytes of `message`; resolves to a base64url signature. */
76
- sign(message: string): Promise<string>;
77
- }
78
-
79
- /**
80
- * Wrap a libp2p private key as a {@link PeerKeySigner}.
81
- *
82
- * Ed25519 only: the peer id is derived as an identity multihash (so
83
- * `publicKey.toString()` already *is* the base58btc peer id — no `@libp2p/peer-id`
84
- * round trip needed), and verifiers of this proof accept nothing else.
85
- *
86
- * @param privateKey - The node's libp2p Ed25519 private key.
87
- * @returns A signer exposing the peer id, the encoded public key, and `sign`.
88
- * @throws If the key is not Ed25519.
89
- */
90
- export function peerKeySigner(privateKey: PrivateKey): PeerKeySigner {
91
- if (privateKey.type !== 'Ed25519') {
92
- throw new Error(`peerKeySigner requires an Ed25519 key, got ${privateKey.type}`);
93
- }
94
-
95
- const publicKey = privateKey.publicKey;
96
- // For Ed25519 the public key's digest is an identity multihash, so its string
97
- // form is the peer id itself — the same value `peerIdFromPrivateKey` produces.
98
- const peerId = publicKey.toString();
99
- const publicKeyB64 = uint8ArrayToString(publicKeyToProtobuf(publicKey), 'base64url');
100
-
101
- return {
102
- peerId,
103
- publicKeyB64,
104
- async sign(message: string): Promise<string> {
105
- const signature = await privateKey.sign(new TextEncoder().encode(message));
106
- return uint8ArrayToString(signature, 'base64url');
107
- }
108
- };
109
- }