@serfab/cadre-core 0.8.1 → 0.10.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 (197) hide show
  1. package/README.md +6 -4
  2. package/dist/bootstrap-peer-store-file.d.ts +13 -0
  3. package/dist/bootstrap-peer-store-file.js +42 -0
  4. package/dist/bootstrap-peer-store-file.js.map +1 -0
  5. package/dist/bootstrap-peer-store.d.ts +73 -0
  6. package/dist/bootstrap-peer-store.js +128 -0
  7. package/dist/bootstrap-peer-store.js.map +1 -0
  8. package/dist/cadre-node.d.ts +1006 -101
  9. package/dist/cadre-node.js +1977 -283
  10. package/dist/cadre-node.js.map +1 -1
  11. package/dist/control-authorization.d.ts +93 -0
  12. package/dist/control-authorization.js +57 -0
  13. package/dist/control-authorization.js.map +1 -0
  14. package/dist/control-cohort.d.ts +15 -15
  15. package/dist/control-cohort.js +14 -14
  16. package/dist/control-cohort.js.map +1 -1
  17. package/dist/control-database.d.ts +1033 -76
  18. package/dist/control-database.js +1520 -153
  19. package/dist/control-database.js.map +1 -1
  20. package/dist/control-formation-recorder.d.ts +91 -12
  21. package/dist/control-formation-recorder.js +131 -16
  22. package/dist/control-formation-recorder.js.map +1 -1
  23. package/dist/control-schema.d.ts +1 -1
  24. package/dist/control-schema.js +774 -186
  25. package/dist/control-schema.js.map +1 -1
  26. package/dist/control-stream.d.ts +38 -4
  27. package/dist/control-stream.js +70 -4
  28. package/dist/control-stream.js.map +1 -1
  29. package/dist/control-write-retry.d.ts +151 -0
  30. package/dist/control-write-retry.js +411 -0
  31. package/dist/control-write-retry.js.map +1 -0
  32. package/dist/delegate-admission.d.ts +134 -0
  33. package/dist/delegate-admission.js +244 -0
  34. package/dist/delegate-admission.js.map +1 -0
  35. package/dist/device-token.d.ts +12 -12
  36. package/dist/device-token.js +15 -14
  37. package/dist/device-token.js.map +1 -1
  38. package/dist/ed25519-key.d.ts +68 -0
  39. package/dist/ed25519-key.js +106 -0
  40. package/dist/ed25519-key.js.map +1 -0
  41. package/dist/file-durable-slot.d.ts +20 -0
  42. package/dist/file-durable-slot.js +53 -0
  43. package/dist/file-durable-slot.js.map +1 -0
  44. package/dist/formation-approval.d.ts +157 -0
  45. package/dist/formation-approval.js +375 -0
  46. package/dist/formation-approval.js.map +1 -0
  47. package/dist/fs-atomic.d.ts +38 -0
  48. package/dist/fs-atomic.js +97 -0
  49. package/dist/fs-atomic.js.map +1 -0
  50. package/dist/identity-key.d.ts +49 -0
  51. package/dist/identity-key.js +81 -0
  52. package/dist/identity-key.js.map +1 -0
  53. package/dist/index.d.ts +16 -6
  54. package/dist/index.js +44 -10
  55. package/dist/index.js.map +1 -1
  56. package/dist/key-store-file.d.ts +2 -24
  57. package/dist/key-store-file.js +10 -77
  58. package/dist/key-store-file.js.map +1 -1
  59. package/dist/key-store.d.ts +1 -1
  60. package/dist/key-store.js +1 -1
  61. package/dist/membership-connection-gater.d.ts +146 -0
  62. package/dist/membership-connection-gater.js +180 -0
  63. package/dist/membership-connection-gater.js.map +1 -0
  64. package/dist/node-local-snapshot.d.ts +109 -0
  65. package/dist/node-local-snapshot.js +182 -0
  66. package/dist/node-local-snapshot.js.map +1 -0
  67. package/dist/peer-authorization.d.ts +150 -11
  68. package/dist/peer-authorization.js +170 -13
  69. package/dist/peer-authorization.js.map +1 -1
  70. package/dist/peer-record.d.ts +24 -11
  71. package/dist/peer-record.js +29 -13
  72. package/dist/peer-record.js.map +1 -1
  73. package/dist/push-node.d.ts +38 -0
  74. package/dist/push-node.js +48 -0
  75. package/dist/push-node.js.map +1 -0
  76. package/dist/push-notifier-apns.d.ts +10 -2
  77. package/dist/push-notifier-apns.js +14 -10
  78. package/dist/push-notifier-apns.js.map +1 -1
  79. package/dist/push-notifier-fcm.d.ts +7 -1
  80. package/dist/push-notifier-fcm.js +9 -10
  81. package/dist/push-notifier-fcm.js.map +1 -1
  82. package/dist/push-notifier.d.ts +16 -35
  83. package/dist/push-notifier.js +16 -44
  84. package/dist/push-notifier.js.map +1 -1
  85. package/dist/relay-addrs.d.ts +45 -0
  86. package/dist/relay-addrs.js +103 -0
  87. package/dist/relay-addrs.js.map +1 -0
  88. package/dist/relay-reservation.d.ts +266 -0
  89. package/dist/relay-reservation.js +613 -0
  90. package/dist/relay-reservation.js.map +1 -0
  91. package/dist/seed-bootstrap.d.ts +263 -79
  92. package/dist/seed-bootstrap.js +413 -211
  93. package/dist/seed-bootstrap.js.map +1 -1
  94. package/dist/seed-trust-policy.d.ts +50 -24
  95. package/dist/seed-trust-policy.js +28 -19
  96. package/dist/seed-trust-policy.js.map +1 -1
  97. package/dist/strand-addr-protocol.d.ts +42 -13
  98. package/dist/strand-addr-protocol.js +58 -52
  99. package/dist/strand-addr-protocol.js.map +1 -1
  100. package/dist/strand-backfill.d.ts +109 -0
  101. package/dist/strand-backfill.js +279 -0
  102. package/dist/strand-backfill.js.map +1 -0
  103. package/dist/strand-database.d.ts +5 -5
  104. package/dist/strand-database.js +4 -4
  105. package/dist/strand-database.js.map +1 -1
  106. package/dist/strand-formation-manager.d.ts +38 -9
  107. package/dist/strand-formation-manager.js +120 -17
  108. package/dist/strand-formation-manager.js.map +1 -1
  109. package/dist/strand-formation-protocol.d.ts +104 -5
  110. package/dist/strand-formation-protocol.js +233 -5
  111. package/dist/strand-formation-protocol.js.map +1 -1
  112. package/dist/strand-instance-manager.d.ts +40 -2
  113. package/dist/strand-instance-manager.js +93 -15
  114. package/dist/strand-instance-manager.js.map +1 -1
  115. package/dist/strand-member-key.d.ts +6 -6
  116. package/dist/strand-member-key.js +6 -6
  117. package/dist/strand-member-key.js.map +1 -1
  118. package/dist/strand-member-registry.d.ts +12 -12
  119. package/dist/strand-member-registry.js +22 -14
  120. package/dist/strand-member-registry.js.map +1 -1
  121. package/dist/strand-membership-writer.d.ts +532 -138
  122. package/dist/strand-membership-writer.js +800 -179
  123. package/dist/strand-membership-writer.js.map +1 -1
  124. package/dist/strand-solicitation.d.ts +99 -33
  125. package/dist/strand-solicitation.js +100 -52
  126. package/dist/strand-solicitation.js.map +1 -1
  127. package/dist/strand-transport-key.d.ts +40 -0
  128. package/dist/strand-transport-key.js +56 -0
  129. package/dist/strand-transport-key.js.map +1 -0
  130. package/dist/strand-wake-protocol.d.ts +9 -7
  131. package/dist/strand-wake-protocol.js +22 -46
  132. package/dist/strand-wake-protocol.js.map +1 -1
  133. package/dist/strand-watcher.d.ts +17 -2
  134. package/dist/strand-watcher.js +47 -3
  135. package/dist/strand-watcher.js.map +1 -1
  136. package/dist/trusted-owner-store-file.d.ts +12 -0
  137. package/dist/trusted-owner-store-file.js +39 -0
  138. package/dist/trusted-owner-store-file.js.map +1 -0
  139. package/dist/trusted-owner-store.d.ts +64 -0
  140. package/dist/trusted-owner-store.js +126 -0
  141. package/dist/trusted-owner-store.js.map +1 -0
  142. package/dist/types.d.ts +325 -50
  143. package/dist/types.js +13 -0
  144. package/dist/types.js.map +1 -1
  145. package/package.json +23 -8
  146. package/src/bootstrap-peer-store-file.ts +44 -0
  147. package/src/bootstrap-peer-store.ts +172 -0
  148. package/src/cadre-node.ts +2129 -295
  149. package/src/control-authorization.ts +114 -0
  150. package/src/control-cohort.ts +17 -17
  151. package/src/control-database.ts +1766 -191
  152. package/src/control-formation-recorder.ts +174 -21
  153. package/src/control-schema.ts +786 -198
  154. package/src/control-stream.ts +81 -4
  155. package/src/control-write-retry.ts +473 -0
  156. package/src/delegate-admission.ts +302 -0
  157. package/src/device-token.ts +19 -14
  158. package/src/ed25519-key.ts +134 -0
  159. package/src/file-durable-slot.ts +61 -0
  160. package/src/formation-approval.ts +604 -0
  161. package/src/fs-atomic.ts +107 -0
  162. package/src/identity-key.ts +109 -0
  163. package/src/index.ts +157 -24
  164. package/src/key-store-file.ts +10 -81
  165. package/src/key-store.ts +1 -1
  166. package/src/membership-connection-gater.ts +204 -0
  167. package/src/node-local-snapshot.ts +260 -0
  168. package/src/peer-authorization.ts +219 -13
  169. package/src/peer-record.ts +31 -13
  170. package/src/push-node.ts +64 -0
  171. package/src/push-notifier-apns.ts +16 -12
  172. package/src/push-notifier-fcm.ts +9 -10
  173. package/src/push-notifier.ts +16 -57
  174. package/src/relay-addrs.ts +111 -0
  175. package/src/relay-reservation.ts +823 -0
  176. package/src/seed-bootstrap.ts +490 -226
  177. package/src/seed-trust-policy.ts +65 -32
  178. package/src/strand-addr-protocol.ts +84 -53
  179. package/src/strand-backfill.ts +366 -0
  180. package/src/strand-database.ts +6 -6
  181. package/src/strand-formation-manager.ts +145 -19
  182. package/src/strand-formation-protocol.ts +310 -9
  183. package/src/strand-instance-manager.ts +113 -16
  184. package/src/strand-member-key.ts +7 -7
  185. package/src/strand-member-registry.ts +28 -23
  186. package/src/strand-membership-writer.ts +1430 -640
  187. package/src/strand-solicitation.ts +155 -90
  188. package/src/strand-transport-key.ts +58 -0
  189. package/src/strand-wake-protocol.ts +29 -46
  190. package/src/strand-watcher.ts +66 -3
  191. package/src/trusted-owner-store-file.ts +41 -0
  192. package/src/trusted-owner-store.ts +171 -0
  193. package/src/types.ts +342 -51
  194. package/dist/authority-key.d.ts +0 -41
  195. package/dist/authority-key.js +0 -52
  196. package/dist/authority-key.js.map +0 -1
  197. package/src/authority-key.ts +0 -68
@@ -0,0 +1,48 @@
1
+ /**
2
+ * push-node.ts — Node-only subpath entry for platform push **construction**.
3
+ *
4
+ * Import from the dedicated subpath, never the package root:
5
+ *
6
+ * ```ts
7
+ * import { createPushNotifier } from '@serfab/cadre-core/push-node';
8
+ * ```
9
+ *
10
+ * The FCM/APNs implementations reach for `node:crypto` / `node:http2`, so they
11
+ * are quarantined here — unreachable from the cross-platform `./index.js` graph
12
+ * (same isolation pattern as `./key-store-file`). A React Native / browser entry
13
+ * never resolves this path, so the Node builtins never reach a bundler that
14
+ * cannot satisfy them. The core references only the {@link PushNotifier}
15
+ * *interface* (`push-notifier.ts`) and a Node host injects the instance built
16
+ * here into `CadreNodeConfig.push.notifier`.
17
+ */
18
+ import { createFcmPushNotifier } from './push-notifier-fcm.js';
19
+ import { createApnsPushNotifier } from './push-notifier-apns.js';
20
+ /**
21
+ * Build a {@link PushNotifier} router over the configured credentials. Only the
22
+ * platforms whose credentials are present get a backing implementation; a `send`
23
+ * for an unconfigured platform returns a best-effort `no <platform> credentials`
24
+ * failure rather than throwing.
25
+ */
26
+ export function createPushNotifier(creds, deps = {}) {
27
+ const fcm = creds.fcm ? createFcmPushNotifier(creds.fcm, deps.fcm) : undefined;
28
+ const apns = creds.apns ? createApnsPushNotifier(creds.apns, deps.apns) : undefined;
29
+ async function send(msg) {
30
+ if (msg.platform === 'fcm')
31
+ return fcm ? fcm.send(msg) : noCreds('fcm');
32
+ if (msg.platform === 'apns')
33
+ return apns ? apns.send(msg) : noCreds('apns');
34
+ return { ok: false, unregistered: false, error: `unknown platform ${String(msg.platform)}` };
35
+ }
36
+ async function close() {
37
+ await Promise.all([fcm?.close(), apns?.close()]);
38
+ }
39
+ return { send, close };
40
+ }
41
+ /** Best-effort no-op result for a platform with no configured credentials. */
42
+ function noCreds(platform) {
43
+ return { ok: false, unregistered: false, error: `no ${platform} credentials` };
44
+ }
45
+ // Per-platform builders + their injected-dep types, for a host that wants a
46
+ // single-platform notifier or to inject a fake transport directly.
47
+ export { createFcmPushNotifier, createApnsPushNotifier };
48
+ //# sourceMappingURL=push-node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push-node.js","sourceRoot":"","sources":["../src/push-node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,EAAE,qBAAqB,EAAoB,MAAM,wBAAwB,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAqB,MAAM,yBAAyB,CAAC;AAWpF;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAsB,EAAE,OAAyB,EAAE;IACpF,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,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.
3
3
  *
4
- * Server-only: signs a provider JWT (ES256, JOSE raw r‖s via `node:crypto`) and
5
- * sends a background data push over an HTTP/2 session to Apple's gateway.
4
+ * Node-only: signs a provider JWT (ES256, JOSE raw r‖s via `node:crypto`) and
5
+ * sends a background data push over an HTTP/2 session to Apple's gateway. APNs
6
+ * mandates HTTP/2, so `node:http2` is unavoidable here — one reason the push
7
+ * path is injected rather than rebuilt on WebCrypto/`fetch`.
8
+ *
9
+ * Reachable only through the `@serfab/cadre-core/push-node` subpath — never from
10
+ * the cross-platform `./index.js` graph — so the `node:crypto` / `node:http2`
11
+ * imports below are safe: no RN/browser bundler ever resolves this module. (Plain
12
+ * named imports; the old namespace-import-to-only-warn dance is obsolete now that
13
+ * the module is unreachable from a browser build by construction.)
6
14
  *
7
15
  * The HTTP/2 call is behind an injected `Http2Requester` seam (bundled with a
8
16
  * `close` into an {@link ApnsTransport}) so unit tests assert the request shape
@@ -1,8 +1,16 @@
1
1
  /**
2
2
  * push-notifier-apns.ts — APNs HTTP/2 strand-wake delivery.
3
3
  *
4
- * Server-only: signs a provider JWT (ES256, JOSE raw r‖s via `node:crypto`) and
5
- * sends a background data push over an HTTP/2 session to Apple's gateway.
4
+ * Node-only: signs a provider JWT (ES256, JOSE raw r‖s via `node:crypto`) and
5
+ * sends a background data push over an HTTP/2 session to Apple's gateway. APNs
6
+ * mandates HTTP/2, so `node:http2` is unavoidable here — one reason the push
7
+ * path is injected rather than rebuilt on WebCrypto/`fetch`.
8
+ *
9
+ * Reachable only through the `@serfab/cadre-core/push-node` subpath — never from
10
+ * the cross-platform `./index.js` graph — so the `node:crypto` / `node:http2`
11
+ * imports below are safe: no RN/browser bundler ever resolves this module. (Plain
12
+ * named imports; the old namespace-import-to-only-warn dance is obsolete now that
13
+ * the module is unreachable from a browser build by construction.)
6
14
  *
7
15
  * The HTTP/2 call is behind an injected `Http2Requester` seam (bundled with a
8
16
  * `close` into an {@link ApnsTransport}) so unit tests assert the request shape
@@ -18,12 +26,8 @@
18
26
  * are never logged — failure log lines carry only a status/reason and a redacted
19
27
  * token prefix.
20
28
  */
21
- // Namespace import (not `import { sign }`): a *named* import of the
22
- // browser-externalized `node:crypto` hard-fails the web build, whereas a
23
- // namespace import only warns — same reasoning as the `node:http2` import below
24
- // and the matching note in push-notifier-fcm.ts. Server-only; never run in browser.
25
- import * as nodeCrypto from 'node:crypto';
26
- import * as http2 from 'node:http2';
29
+ import { sign } from 'node:crypto';
30
+ import { connect } from 'node:http2';
27
31
  import debug from 'debug';
28
32
  import { MAX_REASON_LEN, b64urlJson, errText, redact } from './push-notifier-shared.js';
29
33
  const APNS_PROD_HOST = 'https://api.push.apple.com';
@@ -124,7 +128,7 @@ export function createApnsPushNotifier(creds, deps = {}) {
124
128
  const header = { alg: 'ES256', kid: creds.keyId };
125
129
  const claims = { iss: creds.teamId, iat };
126
130
  const signingInput = `${b64urlJson(header)}.${b64urlJson(claims)}`;
127
- const sig = nodeCrypto.sign('SHA256', Buffer.from(signingInput), {
131
+ const sig = sign('SHA256', Buffer.from(signingInput), {
128
132
  key: creds.privateKey,
129
133
  dsaEncoding: 'ieee-p1363',
130
134
  }).toString('base64url');
@@ -149,7 +153,7 @@ function createHttp2Transport(host) {
149
153
  function ensureSession() {
150
154
  if (session && !session.closed && !session.destroyed)
151
155
  return session;
152
- const s = http2.connect(host);
156
+ const s = connect(host);
153
157
  // Drop a dead session so ensureSession recreates it on the next request.
154
158
  s.on('error', () => { if (session === s)
155
159
  session = null; });
@@ -1 +1 @@
1
- {"version":3,"file":"push-notifier-apns.js","sourceRoot":"","sources":["../src/push-notifier-apns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,oEAAoE;AACpE,yEAAyE;AACzE,gFAAgF;AAChF,oFAAoF;AACpF,OAAO,KAAK,UAAU,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B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: mints a Google OAuth2 access token (RS256 JWT bearer grant signed
5
5
  * with `node:crypto`) and POSTs a data message to the FCM v1 endpoint. The legacy
6
6
  * server-key `fcm.googleapis.com/fcm/send` API is deprecated, so we use HTTP v1.
7
7
  *
8
+ * Reachable only through the `@serfab/cadre-core/push-node` subpath — never from
9
+ * the cross-platform `./index.js` graph — so the `node:crypto` import below is
10
+ * safe: no RN/browser bundler ever resolves this module. (Plain named import;
11
+ * the old namespace-import-to-only-warn dance is obsolete now that the module is
12
+ * unreachable from a browser build by construction.)
13
+ *
8
14
  * The network call is behind an injected `fetch`-like seam so unit tests assert
9
15
  * the request shape and map every documented response code with no real network
10
16
  * and no credentials. Failures are returned as {@link PushSendResult} values.
@@ -1,10 +1,16 @@
1
1
  /**
2
2
  * push-notifier-fcm.ts — FCM HTTP v1 strand-wake delivery.
3
3
  *
4
- * Server-only: mints a Google OAuth2 access token (RS256 JWT bearer grant signed
4
+ * Node-only: mints a Google OAuth2 access token (RS256 JWT bearer grant signed
5
5
  * with `node:crypto`) and POSTs a data message to the FCM v1 endpoint. The legacy
6
6
  * server-key `fcm.googleapis.com/fcm/send` API is deprecated, so we use HTTP v1.
7
7
  *
8
+ * Reachable only through the `@serfab/cadre-core/push-node` subpath — never from
9
+ * the cross-platform `./index.js` graph — so the `node:crypto` import below is
10
+ * safe: no RN/browser bundler ever resolves this module. (Plain named import;
11
+ * the old namespace-import-to-only-warn dance is obsolete now that the module is
12
+ * unreachable from a browser build by construction.)
13
+ *
8
14
  * The network call is behind an injected `fetch`-like seam so unit tests assert
9
15
  * the request shape and map every documented response code with no real network
10
16
  * and no credentials. Failures are returned as {@link PushSendResult} values.
@@ -13,14 +19,7 @@
13
19
  * device tokens are never logged — failure log lines carry only a status/error
14
20
  * code and a redacted token prefix.
15
21
  */
16
- // Namespace import (not `import { sign }`): this module is server-only and is
17
- // reached only via the guarded dynamic import in CadreNode, but bundlers still
18
- // analyse that lazy chunk. A *named* import of `node:crypto` hard-fails the
19
- // browser build ("sign is not exported by __vite-browser-external"), whereas a
20
- // namespace import of the deliberately-unaliased external only warns (matching
21
- // the `node:http2` namespace import in push-notifier-apns.ts). The browser
22
- // never executes this code (config.push is node-only), so the warning is benign.
23
- import * as nodeCrypto from 'node:crypto';
22
+ import { sign } from 'node:crypto';
24
23
  import debug from 'debug';
25
24
  import { MAX_REASON_LEN, b64urlJson, errText, redact } from './push-notifier-shared.js';
26
25
  const TOKEN_ENDPOINT = 'https://oauth2.googleapis.com/token';
@@ -128,7 +127,7 @@ export function createFcmPushNotifier(creds, deps = {}) {
128
127
  exp: iat + 3600,
129
128
  };
130
129
  const signingInput = `${b64urlJson(header)}.${b64urlJson(claims)}`;
131
- const sig = nodeCrypto.sign('RSA-SHA256', Buffer.from(signingInput), creds.privateKey).toString('base64url');
130
+ const sig = sign('RSA-SHA256', Buffer.from(signingInput), creds.privateKey).toString('base64url');
132
131
  return `${signingInput}.${sig}`;
133
132
  }
134
133
  async function close() {
@@ -1 +1 @@
1
- {"version":3,"file":"push-notifier-fcm.js","sourceRoot":"","sources":["../src/push-notifier-fcm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,8EAA8E;AAC9E,+EAA+E;AAC/E,4EAA4E;AAC5E,+EAA+E;AAC/E,+EAA+E;AAC/E,2EAA2E;AAC3E,iFAAiF;AACjF,OAAO,KAAK,UAAU,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAExF,MAAM,cAAc,GAAG,qCAAqC,CAAC;AAC7D,MAAM,SAAS,GAAG,oDAAoD,CAAC;AACvE,MAAM,gBAAgB,GAAG,6CAA6C,CAAC;AACvE,sEAAsE;AACtE,MAAM,qBAAqB,GAAG,KAAM,CAAC;AACrC,2EAA2E;AAC3E,MAAM,oBAAoB,GAAG,OAAS,CAAC;AAEvC,MAAM,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I,CAAC;QACH,OAAO,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
@@ -1,29 +1,25 @@
1
1
  /**
2
- * push-notifier.ts — the platform-push **delivery** seam for strand-wake.
2
+ * push-notifier.ts — the platform-push **delivery** contract for strand-wake.
3
3
  *
4
- * Given a resolved mobile peer token, send one `strand-wake` data message over
5
- * the right platform channel (FCM for Android, APNs for iOS). This module owns no
6
- * policy — *who* to wake and *when* is the fan-out (`push-fanout.ts`). It is the
7
- * reusable, credential-injected, transport-injected unit the fan-out constructs
8
- * inside a participating `CadreNode` when push credentials are configured.
4
+ * This module is the cross-platform-safe *interface* half: the message shape
5
+ * ({@link PushMessage}), the outcome value ({@link PushSendResult}), and the
6
+ * {@link PushNotifier} port a `CadreNode` sends over. It carries ZERO runtime
7
+ * dependencies and imports no implementation — so the RN/browser entry graph can
8
+ * reference the type without ever resolving `node:crypto` / `node:http2`.
9
9
  *
10
- * `createPushNotifier` returns a router that dispatches by `msg.platform` to an
11
- * `FcmPushNotifier` and/or `ApnsPushNotifier`, constructing only the
12
- * implementations whose credentials are present. Failures are values, never
13
- * thrown — mirroring `ServiceWakeResult` / `resolveDeviceToken`'s no-throw
14
- * conventions so a best-effort fan-out can branch on the outcome.
10
+ * The concrete FCM/APNs implementations (`push-notifier-fcm.ts` /
11
+ * `push-notifier-apns.ts`) and the `createPushNotifier` router that builds them
12
+ * live behind the Node-only subpath `@serfab/cadre-core/push-node`
13
+ * (`push-node.ts`). A Node host constructs a notifier from that subpath and
14
+ * injects the instance into `CadreNodeConfig.push.notifier`; the cross-platform
15
+ * core never constructs one, so the Node-only builtins stay out of its graph.
15
16
  *
16
- * Server-only by construction: the FCM/APNs implementations reach for
17
- * `node:crypto` / `node:http2`. They are never pulled into the RN/browser bundle
18
- * because the cross-platform `index.ts` re-exports only the *types* here (a
19
- * type-only re-export is erased at emit), and the only runtime constructor of a
20
- * notifier is the in-package fan-out that runs inside a Node `CadreNode`. A
21
- * cross-platform consumer imports the payload contract + types, never this value.
17
+ * Keep this file zero-import (beyond erased type-only imports): the whole point
18
+ * of the seam is that referencing the interface can never drag an implementation
19
+ * module into a bundler's graph.
22
20
  */
23
- import type { PushPlatform, PushCredentials } from './types.js';
21
+ import type { PushPlatform } from './types.js';
24
22
  import type { StrandWakePayload } from './strand-wake-payload.js';
25
- import { type FcmPushDeps } from './push-notifier-fcm.js';
26
- import { type ApnsPushDeps } from './push-notifier-apns.js';
27
23
  /** One strand-wake data message addressed to one device. */
28
24
  export interface PushMessage {
29
25
  /** The resolved `DeviceToken.token` for the target peer. */
@@ -54,18 +50,3 @@ export interface PushNotifier {
54
50
  /** Release transport resources (e.g. the APNs HTTP/2 session). */
55
51
  close(): Promise<void>;
56
52
  }
57
- /**
58
- * Per-platform transport/clock/log seams, injected by tests. Defaults are the
59
- * real implementations (global `fetch` for FCM, a `node:http2` session for APNs).
60
- */
61
- export interface PushNotifierDeps {
62
- fcm?: FcmPushDeps;
63
- apns?: ApnsPushDeps;
64
- }
65
- /**
66
- * Build a {@link PushNotifier} router over the configured credentials. Only the
67
- * platforms whose credentials are present get a backing implementation; a `send`
68
- * for an unconfigured platform returns a best-effort `no <platform> credentials`
69
- * failure rather than throwing.
70
- */
71
- export declare function createPushNotifier(creds: PushCredentials, deps?: PushNotifierDeps): PushNotifier;
@@ -1,50 +1,22 @@
1
1
  /**
2
- * push-notifier.ts — the platform-push **delivery** seam for strand-wake.
2
+ * push-notifier.ts — the platform-push **delivery** contract for strand-wake.
3
3
  *
4
- * Given a resolved mobile peer token, send one `strand-wake` data message over
5
- * the right platform channel (FCM for Android, APNs for iOS). This module owns no
6
- * policy — *who* to wake and *when* is the fan-out (`push-fanout.ts`). It is the
7
- * reusable, credential-injected, transport-injected unit the fan-out constructs
8
- * inside a participating `CadreNode` when push credentials are configured.
4
+ * This module is the cross-platform-safe *interface* half: the message shape
5
+ * ({@link PushMessage}), the outcome value ({@link PushSendResult}), and the
6
+ * {@link PushNotifier} port a `CadreNode` sends over. It carries ZERO runtime
7
+ * dependencies and imports no implementation — so the RN/browser entry graph can
8
+ * reference the type without ever resolving `node:crypto` / `node:http2`.
9
9
  *
10
- * `createPushNotifier` returns a router that dispatches by `msg.platform` to an
11
- * `FcmPushNotifier` and/or `ApnsPushNotifier`, constructing only the
12
- * implementations whose credentials are present. Failures are values, never
13
- * thrown — mirroring `ServiceWakeResult` / `resolveDeviceToken`'s no-throw
14
- * conventions so a best-effort fan-out can branch on the outcome.
10
+ * The concrete FCM/APNs implementations (`push-notifier-fcm.ts` /
11
+ * `push-notifier-apns.ts`) and the `createPushNotifier` router that builds them
12
+ * live behind the Node-only subpath `@serfab/cadre-core/push-node`
13
+ * (`push-node.ts`). A Node host constructs a notifier from that subpath and
14
+ * injects the instance into `CadreNodeConfig.push.notifier`; the cross-platform
15
+ * core never constructs one, so the Node-only builtins stay out of its graph.
15
16
  *
16
- * Server-only by construction: the FCM/APNs implementations reach for
17
- * `node:crypto` / `node:http2`. They are never pulled into the RN/browser bundle
18
- * because the cross-platform `index.ts` re-exports only the *types* here (a
19
- * type-only re-export is erased at emit), and the only runtime constructor of a
20
- * notifier is the in-package fan-out that runs inside a Node `CadreNode`. A
21
- * cross-platform consumer imports the payload contract + types, never this value.
17
+ * Keep this file zero-import (beyond erased type-only imports): the whole point
18
+ * of the seam is that referencing the interface can never drag an implementation
19
+ * module into a bundler's graph.
22
20
  */
23
- import { createFcmPushNotifier } from './push-notifier-fcm.js';
24
- import { createApnsPushNotifier } from './push-notifier-apns.js';
25
- /**
26
- * Build a {@link PushNotifier} router over the configured credentials. Only the
27
- * platforms whose credentials are present get a backing implementation; a `send`
28
- * for an unconfigured platform returns a best-effort `no <platform> credentials`
29
- * failure rather than throwing.
30
- */
31
- export function createPushNotifier(creds, deps = {}) {
32
- const fcm = creds.fcm ? createFcmPushNotifier(creds.fcm, deps.fcm) : undefined;
33
- const apns = creds.apns ? createApnsPushNotifier(creds.apns, deps.apns) : undefined;
34
- async function send(msg) {
35
- if (msg.platform === 'fcm')
36
- return fcm ? fcm.send(msg) : noCreds('fcm');
37
- if (msg.platform === 'apns')
38
- return apns ? apns.send(msg) : noCreds('apns');
39
- return { ok: false, unregistered: false, error: `unknown platform ${String(msg.platform)}` };
40
- }
41
- async function close() {
42
- await Promise.all([fcm?.close(), apns?.close()]);
43
- }
44
- return { send, close };
45
- }
46
- /** Best-effort no-op result for a platform with no configured credentials. */
47
- function noCreds(platform) {
48
- return { ok: false, unregistered: false, error: `no ${platform} credentials` };
49
- }
21
+ export {};
50
22
  //# sourceMappingURL=push-notifier.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"push-notifier.js","sourceRoot":"","sources":["../src/push-notifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,EAAE,qBAAqB,EAAoB,MAAM,wBAAwB,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAqB,MAAM,yBAAyB,CAAC;AAwCpF;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAsB,EAAE,OAAyB,EAAE;IACpF,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/E,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,sBAAsB,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAEpF,KAAK,UAAU,IAAI,CAAC,GAAgB;QAClC,IAAI,GAAG,CAAC,QAAQ,KAAK,KAAK;YAAE,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACxE,IAAI,GAAG,CAAC,QAAQ,KAAK,MAAM;YAAE,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC5E,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,oBAAoB,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;IAC/F,CAAC;IAED,KAAK,UAAU,KAAK;QAClB,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AACzB,CAAC;AAED,8EAA8E;AAC9E,SAAS,OAAO,CAAC,QAAsB;IACrC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,cAAc,EAAE,CAAC;AACjF,CAAC"}
1
+ {"version":3,"file":"push-notifier.js","sourceRoot":"","sources":["../src/push-notifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Translate `network.relayAddrs` — the operator-facing "use these relay servers"
3
+ * setting — into the mechanism this repo already has for reserving a circuit-relay
4
+ * slot: a `…/p2p/<relayPeerId>/p2p-circuit` entry in the node's listen addrs.
5
+ *
6
+ * `@libp2p/circuit-relay-v2`'s transport is always present on the Node path
7
+ * (`../optimystic/packages/db-p2p/src/libp2p-node.ts` pushes `circuitRelayTransport()`
8
+ * unconditionally), and listening on a relay's circuit addr is what makes libp2p dial
9
+ * that relay and hold a reservation. Everything downstream of the listen list —
10
+ * the reservation itself, `CadreNode.circuitRelayTargets()` picking delegate-announce
11
+ * targets, strand nodes inheriting the listen addrs, the `/p2p-circuit`-first address
12
+ * publishing in `registerSelf` — then works unchanged.
13
+ *
14
+ * So `relayAddrs` is a second, friendlier door onto an existing mechanism:
15
+ *
16
+ * effective listen addrs = listenAddrs ++ relayAddrs.map(a => a + '/p2p-circuit')
17
+ *
18
+ * NOTE: this is the FAIL-FAST route to a reservation — libp2p's transport manager
19
+ * throws when a configured circuit listener cannot listen, so naming a relay that
20
+ * is down means the node does not start. The fail-soft route is the bare
21
+ * `/p2p-circuit` search listener driven by `relay-reservation.ts`. The two are
22
+ * ALTERNATIVES, not layers: configuring `relayAddrs` on a node that already
23
+ * reserves via the search listener adds the fatal listener back and the node
24
+ * stops booting when its relay is down.
25
+ */
26
+ import type { NetworkConfig } from './types.js';
27
+ /**
28
+ * The circuit-listen multiaddr for each configured relay: `<relayAddr>/p2p-circuit`.
29
+ * An entry that already carries `/p2p-circuit` is passed through unchanged.
30
+ * Throws on an entry that is unparsable or names no relay peerId — this is
31
+ * operator configuration, so a typo must fail loudly at start rather than
32
+ * silently costing the node its reachability.
33
+ *
34
+ * Deliberately unlike `extractCircuitRelayTargets` (`delegate-admission.ts`), which
35
+ * SKIPS a bad entry: that one reads addresses discovered at runtime from peers, where
36
+ * one bad entry must not be fatal.
37
+ */
38
+ export declare function relayCircuitAddrs(relayAddrs: readonly string[]): string[];
39
+ /**
40
+ * The listen multiaddrs a node actually binds: configured `listenAddrs` plus the
41
+ * circuit-listen addr of every configured relay, deduplicated, order-stable
42
+ * (configured entries first). Returns `undefined` when neither field is set, so
43
+ * callers keep omitting `listenAddrs` and inherit db-p2p's default.
44
+ */
45
+ export declare function resolveListenAddrs(network: NetworkConfig | undefined): string[] | undefined;
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Translate `network.relayAddrs` — the operator-facing "use these relay servers"
3
+ * setting — into the mechanism this repo already has for reserving a circuit-relay
4
+ * slot: a `…/p2p/<relayPeerId>/p2p-circuit` entry in the node's listen addrs.
5
+ *
6
+ * `@libp2p/circuit-relay-v2`'s transport is always present on the Node path
7
+ * (`../optimystic/packages/db-p2p/src/libp2p-node.ts` pushes `circuitRelayTransport()`
8
+ * unconditionally), and listening on a relay's circuit addr is what makes libp2p dial
9
+ * that relay and hold a reservation. Everything downstream of the listen list —
10
+ * the reservation itself, `CadreNode.circuitRelayTargets()` picking delegate-announce
11
+ * targets, strand nodes inheriting the listen addrs, the `/p2p-circuit`-first address
12
+ * publishing in `registerSelf` — then works unchanged.
13
+ *
14
+ * So `relayAddrs` is a second, friendlier door onto an existing mechanism:
15
+ *
16
+ * effective listen addrs = listenAddrs ++ relayAddrs.map(a => a + '/p2p-circuit')
17
+ *
18
+ * NOTE: this is the FAIL-FAST route to a reservation — libp2p's transport manager
19
+ * throws when a configured circuit listener cannot listen, so naming a relay that
20
+ * is down means the node does not start. The fail-soft route is the bare
21
+ * `/p2p-circuit` search listener driven by `relay-reservation.ts`. The two are
22
+ * ALTERNATIVES, not layers: configuring `relayAddrs` on a node that already
23
+ * reserves via the search listener adds the fatal listener back and the node
24
+ * stops booting when its relay is down.
25
+ */
26
+ import { multiaddr } from '@multiformats/multiaddr';
27
+ import { circuitRelayTargetOrThrow } from './delegate-admission.js';
28
+ /**
29
+ * The direct listener a node keeps when it configures `relayAddrs` but no
30
+ * `listenAddrs`. Without this, naming a relay would silently REPLACE the node's
31
+ * direct TCP listener with a circuit-only one.
32
+ *
33
+ * NOTE: mirrors `createLibp2pNode`'s own default listen addr in
34
+ * `../optimystic/packages/db-p2p/src/libp2p-node.ts` (`/ip4/0.0.0.0/tcp/<port>`,
35
+ * and `CadreNode` passes `port: 0`) — that file is the source of truth. If it
36
+ * ever changes its default, this constant has to follow.
37
+ */
38
+ const DEFAULT_DIRECT_LISTEN_ADDR = '/ip4/0.0.0.0/tcp/0';
39
+ /**
40
+ * The circuit-listen multiaddr for each configured relay: `<relayAddr>/p2p-circuit`.
41
+ * An entry that already carries `/p2p-circuit` is passed through unchanged.
42
+ * Throws on an entry that is unparsable or names no relay peerId — this is
43
+ * operator configuration, so a typo must fail loudly at start rather than
44
+ * silently costing the node its reachability.
45
+ *
46
+ * Deliberately unlike `extractCircuitRelayTargets` (`delegate-admission.ts`), which
47
+ * SKIPS a bad entry: that one reads addresses discovered at runtime from peers, where
48
+ * one bad entry must not be fatal.
49
+ */
50
+ export function relayCircuitAddrs(relayAddrs) {
51
+ return dedupe(relayAddrs.map(circuitListenAddr));
52
+ }
53
+ /**
54
+ * The listen multiaddrs a node actually binds: configured `listenAddrs` plus the
55
+ * circuit-listen addr of every configured relay, deduplicated, order-stable
56
+ * (configured entries first). Returns `undefined` when neither field is set, so
57
+ * callers keep omitting `listenAddrs` and inherit db-p2p's default.
58
+ */
59
+ export function resolveListenAddrs(network) {
60
+ const circuits = relayCircuitAddrs(network?.relayAddrs ?? []);
61
+ const listenAddrs = network?.listenAddrs;
62
+ if (!listenAddrs && circuits.length === 0) {
63
+ return undefined;
64
+ }
65
+ // An explicitly empty `listenAddrs` (the React Native "cannot listen" case) stays
66
+ // empty — but a relay named alongside it still gets its circuit listener, since
67
+ // acquiring one is the whole point of configuring a relay.
68
+ return dedupe([...(listenAddrs ?? [DEFAULT_DIRECT_LISTEN_ADDR]), ...circuits]);
69
+ }
70
+ /**
71
+ * One entry of {@link relayCircuitAddrs}: the addr the node listens on for this relay.
72
+ *
73
+ * NOTE: an entry carrying components AFTER `/p2p-circuit` — a full relayed DIAL addr,
74
+ * `…/p2p/<relay>/p2p-circuit/p2p/<someone else>` — is passed through as written and
75
+ * would be listened on verbatim. It validates (the relay it names is real), so only an
76
+ * operator who pastes a peer's relayed address into `relayAddrs` hits it; if that turns
77
+ * out to be a common paste, truncate at the `/p2p-circuit` component here.
78
+ */
79
+ function circuitListenAddr(relayAddr) {
80
+ const alreadyCircuit = parseComponents(relayAddr).some((c) => c.name === 'p2p-circuit');
81
+ const listenAddr = alreadyCircuit ? relayAddr : `${relayAddr}/p2p-circuit`;
82
+ try {
83
+ circuitRelayTargetOrThrow(listenAddr); // validates the relay peerId
84
+ }
85
+ catch (err) {
86
+ throw new Error(`network.relayAddrs entry names no relay peerId (expected <dial addr>/p2p/<relayPeerId>): ${relayAddr}`, { cause: err });
87
+ }
88
+ return listenAddr;
89
+ }
90
+ /** Multiaddr components of `relayAddr`, with the config field named on a parse failure. */
91
+ function parseComponents(relayAddr) {
92
+ try {
93
+ return multiaddr(relayAddr).getComponents();
94
+ }
95
+ catch (err) {
96
+ throw new Error(`network.relayAddrs entry is not a valid multiaddr: ${relayAddr}`, { cause: err });
97
+ }
98
+ }
99
+ /** Exact-string dedupe, first occurrence wins, so the list is stable across restarts. */
100
+ function dedupe(addrs) {
101
+ return [...new Set(addrs)];
102
+ }
103
+ //# sourceMappingURL=relay-addrs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay-addrs.js","sourceRoot":"","sources":["../src/relay-addrs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,SAAS,EAAkB,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAGpE;;;;;;;;;GASG;AACH,MAAM,0BAA0B,GAAG,oBAAoB,CAAC;AAExD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAA6B;IAC7D,OAAO,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC;AACnD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAkC;IACnE,MAAM,QAAQ,GAAG,iBAAiB,CAAC,OAAO,EAAE,UAAU,IAAI,EAAE,CAAC,CAAC;IAC9D,MAAM,WAAW,GAAG,OAAO,EAAE,WAAW,CAAC;IACzC,IAAI,CAAC,WAAW,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1C,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,kFAAkF;IAClF,gFAAgF;IAChF,2DAA2D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