@serfab/cadre-core 0.8.1 → 0.9.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 (93) hide show
  1. package/README.md +2 -2
  2. package/dist/cadre-node.d.ts +101 -61
  3. package/dist/cadre-node.js +165 -124
  4. package/dist/cadre-node.js.map +1 -1
  5. package/dist/control-cohort.d.ts +15 -15
  6. package/dist/control-cohort.js +14 -14
  7. package/dist/control-cohort.js.map +1 -1
  8. package/dist/control-database.d.ts +51 -34
  9. package/dist/control-database.js +72 -56
  10. package/dist/control-database.js.map +1 -1
  11. package/dist/control-formation-recorder.d.ts +2 -2
  12. package/dist/control-formation-recorder.js +2 -2
  13. package/dist/control-schema.d.ts +1 -1
  14. package/dist/control-schema.js +57 -33
  15. package/dist/control-schema.js.map +1 -1
  16. package/dist/device-token.d.ts +1 -1
  17. package/dist/device-token.js +1 -1
  18. package/dist/{authority-key.d.ts → ed25519-key.d.ts} +11 -10
  19. package/dist/{authority-key.js → ed25519-key.js} +9 -10
  20. package/dist/ed25519-key.js.map +1 -0
  21. package/dist/index.d.ts +3 -3
  22. package/dist/index.js +8 -8
  23. package/dist/index.js.map +1 -1
  24. package/dist/key-store.d.ts +1 -1
  25. package/dist/key-store.js +1 -1
  26. package/dist/peer-authorization.d.ts +28 -6
  27. package/dist/peer-authorization.js +33 -7
  28. package/dist/peer-authorization.js.map +1 -1
  29. package/dist/peer-record.d.ts +3 -3
  30. package/dist/peer-record.js +3 -3
  31. package/dist/push-node.d.ts +38 -0
  32. package/dist/push-node.js +48 -0
  33. package/dist/push-node.js.map +1 -0
  34. package/dist/push-notifier-apns.d.ts +10 -2
  35. package/dist/push-notifier-apns.js +14 -10
  36. package/dist/push-notifier-apns.js.map +1 -1
  37. package/dist/push-notifier-fcm.d.ts +7 -1
  38. package/dist/push-notifier-fcm.js +9 -10
  39. package/dist/push-notifier-fcm.js.map +1 -1
  40. package/dist/push-notifier.d.ts +16 -35
  41. package/dist/push-notifier.js +16 -44
  42. package/dist/push-notifier.js.map +1 -1
  43. package/dist/seed-bootstrap.d.ts +70 -51
  44. package/dist/seed-bootstrap.js +168 -106
  45. package/dist/seed-bootstrap.js.map +1 -1
  46. package/dist/seed-trust-policy.d.ts +11 -11
  47. package/dist/seed-trust-policy.js +11 -11
  48. package/dist/seed-trust-policy.js.map +1 -1
  49. package/dist/strand-database.d.ts +5 -5
  50. package/dist/strand-database.js +4 -4
  51. package/dist/strand-database.js.map +1 -1
  52. package/dist/strand-formation-protocol.d.ts +1 -1
  53. package/dist/strand-formation-protocol.js +1 -1
  54. package/dist/strand-instance-manager.d.ts +1 -1
  55. package/dist/strand-instance-manager.js +1 -1
  56. package/dist/strand-instance-manager.js.map +1 -1
  57. package/dist/strand-member-key.d.ts +6 -6
  58. package/dist/strand-member-key.js +6 -6
  59. package/dist/strand-member-key.js.map +1 -1
  60. package/dist/strand-member-registry.d.ts +7 -7
  61. package/dist/strand-member-registry.js +5 -5
  62. package/dist/strand-member-registry.js.map +1 -1
  63. package/dist/strand-membership-writer.d.ts +84 -84
  64. package/dist/strand-membership-writer.js +90 -90
  65. package/dist/strand-membership-writer.js.map +1 -1
  66. package/dist/types.d.ts +52 -32
  67. package/dist/types.js.map +1 -1
  68. package/package.json +7 -3
  69. package/src/cadre-node.ts +170 -126
  70. package/src/control-cohort.ts +17 -17
  71. package/src/control-database.ts +76 -59
  72. package/src/control-formation-recorder.ts +2 -2
  73. package/src/control-schema.ts +57 -33
  74. package/src/device-token.ts +1 -1
  75. package/src/{authority-key.ts → ed25519-key.ts} +12 -11
  76. package/src/index.ts +21 -19
  77. package/src/key-store.ts +1 -1
  78. package/src/peer-authorization.ts +35 -7
  79. package/src/peer-record.ts +3 -3
  80. package/src/push-node.ts +64 -0
  81. package/src/push-notifier-apns.ts +16 -12
  82. package/src/push-notifier-fcm.ts +9 -10
  83. package/src/push-notifier.ts +16 -57
  84. package/src/seed-bootstrap.ts +179 -115
  85. package/src/seed-trust-policy.ts +18 -18
  86. package/src/strand-database.ts +6 -6
  87. package/src/strand-formation-protocol.ts +1 -1
  88. package/src/strand-instance-manager.ts +2 -2
  89. package/src/strand-member-key.ts +7 -7
  90. package/src/strand-member-registry.ts +10 -10
  91. package/src/strand-membership-writer.ts +127 -127
  92. package/src/types.ts +52 -32
  93. package/dist/authority-key.js.map +0 -1
@@ -2,12 +2,12 @@ import debug from 'debug';
2
2
  import { digest, verify } from '@optimystic/quereus-plugin-crypto';
3
3
  const log = debug('sereus:cadre:peer-authorization');
4
4
  /**
5
- * Canonical digest an authority signs to authorize a peer.
5
+ * Canonical digest an owner signs to authorize a peer.
6
6
  *
7
7
  * This is the exact byte construction {@link SeedBootstrapService.authorizePeer}
8
8
  * signs over when it inserts an authorized `CadrePeer` row:
9
9
  * `digest([peerId], 'sha256', 'base64url')`. Factored into one place so the
10
- * producer (authority signing) and the verifier (the offline `cadre enroll
10
+ * producer (owner signing) and the verifier (the offline `cadre enroll
11
11
  * register` check) can never drift apart — change the digest here and both move
12
12
  * together. The SQL mirror is the bare single-field `digest(coalesce(new.PeerId, old.PeerId))`.
13
13
  */
@@ -15,22 +15,48 @@ export function peerAuthorizationDigest(peerId) {
15
15
  return digest([peerId], 'sha256', 'base64url');
16
16
  }
17
17
  /**
18
- * Verify that `signature` is a valid authority ed25519 signature over `peerId`'s
19
- * authorization digest, using `authorityPublicKey` (base64url).
18
+ * Canonical digest an owner signs to VOUCH a `CadrePeer` membership row (insert
19
+ * and the owner re-touch update). Binds the peer id to the row's single-use
20
+ * `StampId` nonce, so a captured signed insert cannot be replayed (the `StampId` is
21
+ * unique) and — because {@link cadrePeerRemoveDigest} scopes a DIFFERENT payload — the
22
+ * stored voucher (`VouchSig`) cannot be replayed to authorize a delete.
23
+ *
24
+ * The SQL mirror is `digest(new.PeerId, new.StampId)` (two TEXT fields), matching the
25
+ * canonical multi-field framing in control-database.ts:buildAuthorizationMessage.
26
+ */
27
+ export function cadrePeerVoucherDigest(peerId, stampId) {
28
+ return digest([peerId, stampId], 'sha256', 'base64url');
29
+ }
30
+ /**
31
+ * Canonical digest an owner signs to REMOVE a `CadrePeer` row. Deliberately a
32
+ * distinct payload from {@link cadrePeerVoucherDigest} (adds the `'remove'` action
33
+ * tag) so the row's stored voucher — a signature over the voucher digest — can never
34
+ * satisfy this delete check. The signature is supplied in write context and never
35
+ * stored, so no reader can replay it; binding the live row's `StampId` also invalidates
36
+ * any captured remove after a delete+reinsert (the nonce rotates).
37
+ *
38
+ * SQL mirror: `digest(old.PeerId, old.StampId, 'remove')`.
39
+ */
40
+ export function cadrePeerRemoveDigest(peerId, stampId) {
41
+ return digest([peerId, stampId, 'remove'], 'sha256', 'base64url');
42
+ }
43
+ /**
44
+ * Verify that `signature` is a valid owner ed25519 signature over `peerId`'s
45
+ * authorization digest, using `ownerPublicKey` (base64url).
20
46
  *
21
47
  * This is the mirror of the signing done in
22
48
  * {@link SeedBootstrapService.authorizePeer}: it checks the signature against
23
49
  * {@link peerAuthorizationDigest}. A `true` result means the holder of the
24
- * authority private key vouched for this peer ID — it does NOT mean the peer is
50
+ * owner private key vouched for this peer ID — it does NOT mean the peer is
25
51
  * registered anywhere.
26
52
  *
27
53
  * Returns a boolean and never throws: malformed base64url, a bad/garbage key, or
28
54
  * any crypto failure resolves to `false` (callers want a verdict, not an
29
55
  * exception). The catch is logged at debug.
30
56
  */
31
- export function verifyPeerAuthorization(peerId, authorityPublicKey, signature) {
57
+ export function verifyPeerAuthorization(peerId, ownerPublicKey, signature) {
32
58
  try {
33
- return verify(peerAuthorizationDigest(peerId), signature, authorityPublicKey, 'ed25519', 'base64url', 'base64url', 'base64url');
59
+ return verify(peerAuthorizationDigest(peerId), signature, ownerPublicKey, 'ed25519', 'base64url', 'base64url', 'base64url');
34
60
  }
35
61
  catch (error) {
36
62
  log('verifyPeerAuthorization failed: %o', error);
@@ -1 +1 @@
1
- {"version":3,"file":"peer-authorization.js","sourceRoot":"","sources":["../src/peer-authorization.ts"],"names":[],"mappings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AACpE,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAc,EAAE,OAAe;IACnE,OAAO,MAAM,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,QAAQ,EAAE,WAAW,CAAW,CAAC;AAC9E,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAAc,EACd,cAAsB,EACtB,SAAiB;IAEjB,IAAI,CAAC;QACH,OAAO,MAAM,CACX,uBAAuB,CAAC,MAAM,CAAC,EAC/B,SAAS,EACT,cAAc,EACd,SAAS,EACT,WAAW,EACX,WAAW,EACX,WAAW,CACZ,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,oCAAoC,EAAE,KAAK,CAAC,CAAC;QACjD,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -49,7 +49,7 @@ export declare function peerRecordSignedPayload(peerId: string, multiaddr: strin
49
49
  * preserved and is the order signed over).
50
50
  *
51
51
  * @param fields - the record fields to sign (signaling addr first by convention)
52
- * @param privateKeyB64 - base64url ed25519 seed (see `authorityKeyFromLibp2p`)
52
+ * @param privateKeyB64 - base64url ed25519 seed (see `ed25519KeyPairFromLibp2p`)
53
53
  */
54
54
  export declare function signPeerRecord(fields: {
55
55
  peerId: string;
@@ -81,8 +81,8 @@ export declare function orderSignalingFirst(addrs: string[]): string[];
81
81
  /**
82
82
  * Default resolve trust gate: trust any peer that has a `CadrePeer` row.
83
83
  *
84
- * A row only exists because an authority signed its `AuthorizedInsert`, so row
85
- * presence already means "authority-vouched member". This is the seam where a
84
+ * A row only exists because an owner signed its `AuthorizedInsert`, so row
85
+ * presence already means "owner-vouched member". This is the seam where a
86
86
  * stricter policy (trust circle, pinned keys) plugs in — see
87
87
  * {@link PeerResolveTrustPolicy}.
88
88
  */
@@ -54,7 +54,7 @@ export function peerRecordSignedPayload(peerId, multiaddr, updatedAt) {
54
54
  * preserved and is the order signed over).
55
55
  *
56
56
  * @param fields - the record fields to sign (signaling addr first by convention)
57
- * @param privateKeyB64 - base64url ed25519 seed (see `authorityKeyFromLibp2p`)
57
+ * @param privateKeyB64 - base64url ed25519 seed (see `ed25519KeyPairFromLibp2p`)
58
58
  */
59
59
  export function signPeerRecord(fields, privateKeyB64) {
60
60
  const payloadDigest = peerRecordSignedPayload(fields.peerId, fields.addrs.join(','), fields.updatedAt);
@@ -102,8 +102,8 @@ export function orderSignalingFirst(addrs) {
102
102
  /**
103
103
  * Default resolve trust gate: trust any peer that has a `CadrePeer` row.
104
104
  *
105
- * A row only exists because an authority signed its `AuthorizedInsert`, so row
106
- * presence already means "authority-vouched member". This is the seam where a
105
+ * A row only exists because an owner signed its `AuthorizedInsert`, so row
106
+ * presence already means "owner-vouched member". This is the seam where a
107
107
  * stricter policy (trust circle, pinned keys) plugs in — see
108
108
  * {@link PeerResolveTrustPolicy}.
109
109
  */
@@ -0,0 +1,38 @@
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 type { PushCredentials } from './types.js';
19
+ import type { PushNotifier } from './push-notifier.js';
20
+ import { createFcmPushNotifier, type FcmPushDeps } from './push-notifier-fcm.js';
21
+ import { createApnsPushNotifier, type ApnsPushDeps } from './push-notifier-apns.js';
22
+ /**
23
+ * Per-platform transport/clock/log seams, injected by tests. Defaults are the
24
+ * real implementations (global `fetch` for FCM, a `node:http2` session for APNs).
25
+ */
26
+ export interface PushNotifierDeps {
27
+ fcm?: FcmPushDeps;
28
+ apns?: ApnsPushDeps;
29
+ }
30
+ /**
31
+ * Build a {@link PushNotifier} router over the configured credentials. Only the
32
+ * platforms whose credentials are present get a backing implementation; a `send`
33
+ * for an unconfigured platform returns a best-effort `no <platform> credentials`
34
+ * failure rather than throwing.
35
+ */
36
+ export declare function createPushNotifier(creds: PushCredentials, deps?: PushNotifierDeps): PushNotifier;
37
+ export { createFcmPushNotifier, createApnsPushNotifier };
38
+ export type { FcmPushDeps, ApnsPushDeps };
@@ -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,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;AAED,4EAA4E;AAC5E,mEAAmE;AACnE,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,CAAC"}
@@ -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
@@ -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,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAExF,MAAM,cAAc,GAAG,4BAA4B,CAAC;AACpD,MAAM,iBAAiB,GAAG,oCAAoC,CAAC;AAC/D,oFAAoF;AACpF,MAAM,qBAAqB,GAAG,EAAE,GAAG,KAAM,CAAC;AAE1C,MAAM,SAAS,GAAG,KAAK,CAAC,wBAAwB,CAAC,CAAC;AA2ClD,MAAM,UAAU,sBAAsB,CAAC,KAAsB,EAAE,OA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AG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,UAAU,KAAK;QAClB,MAAM,CAAC,GAAG,OAAO,CAAC;QAClB,OAAO,GAAG,IAAI,CAAC;QACf,IAAI,CAAC;YAAE,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC5B,CAAC;AAED,8EAA8E;AAC9E,SAAS,UAAU,CAAC,IAAY;IAC9B,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAyB,CAAC;QACxD,OAAO,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;IAClE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -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.
@@ -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,QAAQ,GAAG,KAAK,CAAC,uBAAuB,CAAC,CAAC;AA8BhD,MAAM,UAAU,qBAAqB,CAAC,KAAqB,EAAE,OAAoB,EAAE;IACjF,MAAM,OAAO,GAAa,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;IAC1E,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC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kB,IAAI,qDAAqD,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACjH,OAAO,KAAK,CAAC;AACf,CAAC;AAED,kFAAkF;AAClF,SAAS,YAAY,CAAC,IAAY;IAChC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAE7B,CAAC;QACF,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC;QACzB,IAAI,CAAC,GAAG;YAAE,OAAO,IAAI,CAAC;QACtB,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,SAAS,KAAK,QAAQ,CAAC,EAAE,SAAS,CAAC;QACxF,OAAO,UAAU,IAAI,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,mFAAmF;AACnF,SAAS,YAAY,CAAC,MAAc,EAAE,IAAY;IAChD,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,MAAM,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,MAAM,EAAE,CAAC;AAC1D,CAAC;AAED,KAAK,UAAU,QAAQ,CAAC,GAAoB;IAC1C,IAAI,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,KAA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