signalk-p2p-plugin 0.0.0-stage → 0.3.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 (159) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/LICENSE +201 -0
  3. package/README.md +101 -2
  4. package/deploy/README.md +83 -0
  5. package/deploy/peer.example.json +9 -0
  6. package/deploy/signalk-p2p-peer.service +23 -0
  7. package/dist/admin-page.d.ts +7 -0
  8. package/dist/admin-page.d.ts.map +1 -0
  9. package/dist/admin-page.js +8 -0
  10. package/dist/admin-page.js.map +1 -0
  11. package/dist/ais/publish.d.ts +7 -0
  12. package/dist/ais/publish.d.ts.map +1 -0
  13. package/dist/ais/publish.js +41 -0
  14. package/dist/ais/publish.js.map +1 -0
  15. package/dist/ais/store.d.ts +41 -0
  16. package/dist/ais/store.d.ts.map +1 -0
  17. package/dist/ais/store.js +140 -0
  18. package/dist/ais/store.js.map +1 -0
  19. package/dist/api.d.ts +55 -0
  20. package/dist/api.d.ts.map +1 -0
  21. package/dist/api.js +104 -0
  22. package/dist/api.js.map +1 -0
  23. package/dist/config.d.ts +161 -0
  24. package/dist/config.d.ts.map +1 -0
  25. package/dist/config.js +482 -0
  26. package/dist/config.js.map +1 -0
  27. package/dist/data/ais.d.ts +27 -0
  28. package/dist/data/ais.d.ts.map +1 -0
  29. package/dist/data/ais.js +192 -0
  30. package/dist/data/ais.js.map +1 -0
  31. package/dist/data/codec.d.ts +16 -0
  32. package/dist/data/codec.d.ts.map +1 -0
  33. package/dist/data/codec.js +56 -0
  34. package/dist/data/codec.js.map +1 -0
  35. package/dist/data/envelope.d.ts +10 -0
  36. package/dist/data/envelope.d.ts.map +1 -0
  37. package/dist/data/envelope.js +51 -0
  38. package/dist/data/envelope.js.map +1 -0
  39. package/dist/data/inject.d.ts +12 -0
  40. package/dist/data/inject.d.ts.map +1 -0
  41. package/dist/data/inject.js +226 -0
  42. package/dist/data/inject.js.map +1 -0
  43. package/dist/data/merge.d.ts +36 -0
  44. package/dist/data/merge.d.ts.map +1 -0
  45. package/dist/data/merge.js +72 -0
  46. package/dist/data/merge.js.map +1 -0
  47. package/dist/data/snapshot.d.ts +10 -0
  48. package/dist/data/snapshot.d.ts.map +1 -0
  49. package/dist/data/snapshot.js +273 -0
  50. package/dist/data/snapshot.js.map +1 -0
  51. package/dist/data/static.d.ts +5 -0
  52. package/dist/data/static.d.ts.map +1 -0
  53. package/dist/data/static.js +148 -0
  54. package/dist/data/static.js.map +1 -0
  55. package/dist/data/types.d.ts +76 -0
  56. package/dist/data/types.d.ts.map +1 -0
  57. package/dist/data/types.js +34 -0
  58. package/dist/data/types.js.map +1 -0
  59. package/dist/data/values.d.ts +5 -0
  60. package/dist/data/values.d.ts.map +1 -0
  61. package/dist/data/values.js +15 -0
  62. package/dist/data/values.js.map +1 -0
  63. package/dist/groups/control.d.ts +53 -0
  64. package/dist/groups/control.d.ts.map +1 -0
  65. package/dist/groups/control.js +161 -0
  66. package/dist/groups/control.js.map +1 -0
  67. package/dist/groups/crypto.d.ts +9 -0
  68. package/dist/groups/crypto.d.ts.map +1 -0
  69. package/dist/groups/crypto.js +55 -0
  70. package/dist/groups/crypto.js.map +1 -0
  71. package/dist/groups/manager.d.ts +84 -0
  72. package/dist/groups/manager.d.ts.map +1 -0
  73. package/dist/groups/manager.js +690 -0
  74. package/dist/groups/manager.js.map +1 -0
  75. package/dist/groups/types.d.ts +122 -0
  76. package/dist/groups/types.d.ts.map +1 -0
  77. package/dist/groups/types.js +84 -0
  78. package/dist/groups/types.js.map +1 -0
  79. package/dist/identity.d.ts +26 -0
  80. package/dist/identity.d.ts.map +1 -0
  81. package/dist/identity.js +91 -0
  82. package/dist/identity.js.map +1 -0
  83. package/dist/index.d.ts +22 -0
  84. package/dist/index.d.ts.map +1 -0
  85. package/dist/index.js +22 -0
  86. package/dist/index.js.map +1 -0
  87. package/dist/live/capability.d.ts +22 -0
  88. package/dist/live/capability.d.ts.map +1 -0
  89. package/dist/live/capability.js +83 -0
  90. package/dist/live/capability.js.map +1 -0
  91. package/dist/live/client.d.ts +71 -0
  92. package/dist/live/client.d.ts.map +1 -0
  93. package/dist/live/client.js +304 -0
  94. package/dist/live/client.js.map +1 -0
  95. package/dist/live/directory.d.ts +35 -0
  96. package/dist/live/directory.d.ts.map +1 -0
  97. package/dist/live/directory.js +83 -0
  98. package/dist/live/directory.js.map +1 -0
  99. package/dist/live/message.d.ts +28 -0
  100. package/dist/live/message.d.ts.map +1 -0
  101. package/dist/live/message.js +143 -0
  102. package/dist/live/message.js.map +1 -0
  103. package/dist/live/protocol.d.ts +16 -0
  104. package/dist/live/protocol.d.ts.map +1 -0
  105. package/dist/live/protocol.js +39 -0
  106. package/dist/live/protocol.js.map +1 -0
  107. package/dist/live/publisher.d.ts +54 -0
  108. package/dist/live/publisher.d.ts.map +1 -0
  109. package/dist/live/publisher.js +379 -0
  110. package/dist/live/publisher.js.map +1 -0
  111. package/dist/live/relay.d.ts +103 -0
  112. package/dist/live/relay.d.ts.map +1 -0
  113. package/dist/live/relay.js +333 -0
  114. package/dist/live/relay.js.map +1 -0
  115. package/dist/live/topic.d.ts +5 -0
  116. package/dist/live/topic.d.ts.map +1 -0
  117. package/dist/live/topic.js +8 -0
  118. package/dist/live/topic.js.map +1 -0
  119. package/dist/peer/cli.d.ts +3 -0
  120. package/dist/peer/cli.d.ts.map +1 -0
  121. package/dist/peer/cli.js +143 -0
  122. package/dist/peer/cli.js.map +1 -0
  123. package/dist/peer/config.d.ts +30 -0
  124. package/dist/peer/config.d.ts.map +1 -0
  125. package/dist/peer/config.js +70 -0
  126. package/dist/peer/config.js.map +1 -0
  127. package/dist/plugin.d.ts +6 -0
  128. package/dist/plugin.d.ts.map +1 -0
  129. package/dist/plugin.js +819 -0
  130. package/dist/plugin.js.map +1 -0
  131. package/dist/security/attestor.d.ts +10 -0
  132. package/dist/security/attestor.d.ts.map +1 -0
  133. package/dist/security/attestor.js +24 -0
  134. package/dist/security/attestor.js.map +1 -0
  135. package/dist/security/claim.d.ts +25 -0
  136. package/dist/security/claim.d.ts.map +1 -0
  137. package/dist/security/claim.js +159 -0
  138. package/dist/security/claim.js.map +1 -0
  139. package/dist/security/control.d.ts +38 -0
  140. package/dist/security/control.d.ts.map +1 -0
  141. package/dist/security/control.js +117 -0
  142. package/dist/security/control.js.map +1 -0
  143. package/dist/security/registry.d.ts +70 -0
  144. package/dist/security/registry.d.ts.map +1 -0
  145. package/dist/security/registry.js +315 -0
  146. package/dist/security/registry.js.map +1 -0
  147. package/docs/plans/README.md +73 -0
  148. package/docs/plans/architecture.md +243 -0
  149. package/docs/plans/data-and-injection.md +392 -0
  150. package/docs/plans/networks.md +455 -0
  151. package/docs/plans/peer-node.md +221 -0
  152. package/docs/plans/security.md +364 -0
  153. package/docs/plans/shared-data.md +475 -0
  154. package/docs/plans/spike-findings.md +148 -0
  155. package/docs/plans/v1-design.md +304 -0
  156. package/icon.svg +24 -0
  157. package/package.json +107 -4
  158. package/public/icon.svg +24 -0
  159. package/public/index.html +618 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,71 @@
1
+ # Changelog
2
+
3
+ ## 0.3.0 — 2026-11-06
4
+
5
+ - Add a Public network card to the webapp with status, peers/elected relay and
6
+ per-data-set public sharing toggles. Toggles persist to the plugin
7
+ configuration and apply live.
8
+
9
+ ## 0.2.2 — 2026-11-06
10
+
11
+ - Render the identity/status panel as readable fields instead of a JSON blob.
12
+ - Report the package version at runtime; the status was hard-coded to 0.1.0.
13
+
14
+ ## 0.2.1 — 2026-11-06
15
+
16
+ - Fix the webapp API base to the actual plugin route
17
+ (`/plugins/signalk-p2p-plugin`), which was returning HTTP 404.
18
+
19
+ ## 0.2.0 — 2026-11-02
20
+
21
+ - The admin interface is now a Signal K webapp, listed under Webapps while the
22
+ plugin is enabled. The admin-gated `/plugins/signalk-p2p-plugin/admin` route remains.
23
+
24
+ ## 0.1.1 — 2026-11-02
25
+
26
+ Fix the Windows path assertion in the peer config test; no runtime changes.
27
+
28
+ ## 0.1.0 — 2026-11-02
29
+
30
+ First public release. Validated over WAN through a VPS peer; not yet validated
31
+ on real boats or Starlink links.
32
+
33
+ - Design plans under `docs/plans/`.
34
+ - Repository scaffold: TypeScript ESM plugin, identity, configuration schema,
35
+ snapshot/static codecs, and merge rules.
36
+ - Spike harness for payload size and Hypercore replication measurements.
37
+ - Standalone Node.js peer (`signalk-p2p-peer`) with Hyperswarm discovery,
38
+ Protomux live channel, batching, history replay and a systemd deployment.
39
+ - Live path in the plugin: self snapshots/static/depth publishing, LiveMessage
40
+ batching, and injection of remote vessels with loop prevention.
41
+ - Ed25519-signed LiveMessages with receiver verification; unsigned and tampered
42
+ messages are rejected.
43
+ - Public claim registry: persisted `selfId → key` claims, attestor-signed
44
+ attestations/revocations, TOFU fallback, and receiver authorization.
45
+ - Admin attestor API (`/identity`, `/claims`, `/claims/attest`,
46
+ `/claims/revoke`) and a configurable attestation threshold.
47
+ - Peer election: signed capability advertisements, weighted rendezvous epochs,
48
+ relay advertisement, status reporting and a WAN smoke test.
49
+ - Routing enforcement: clients target the elected aggregator, only it forwards,
50
+ with deduplication and a full-mesh fallback.
51
+ - Private groups: X25519 box keys, signed roster snapshots, invite tokens, join
52
+ requests and admin approval with selfId/MMSI uniqueness, AES-256-GCM group data,
53
+ and removal with epoch rekey. Admin group API and a network smoke test.
54
+ - Standalone peer group relay via `--group-invite`: joins the roster, forwards
55
+ encrypted group data and follows rekeys.
56
+ - AIS sharing: collects locally heard targets only, supports the four modes,
57
+ caps to the nearest targets, publishes observation records, and drops AIS
58
+ observations in favour of fresh self records.
59
+ - Roster/attestor hardening: attestation signatures are persisted and revalidated,
60
+ expired or retired attestors no longer count, group invites are single-use, and
61
+ viewers cannot publish.
62
+ - Multi-admin quorum: multi-signature roster proposals, approval and threshold
63
+ APIs, and serialized group persistence.
64
+ - Roster catch-up requests and a minimal admin page for claims, groups,
65
+ join requests and proposals.
66
+ - Extended shared data: magnetic course/heading, variation, attitude, rate of
67
+ turn, speed through water and GNSS DOP/satellites in the snapshot; environment,
68
+ tanks, destination, anchor, propulsion and systems in a change-triggered Values
69
+ record.
70
+ - WAN validation through a VPS peer, plus `smoke:client` and `smoke:plugin`
71
+ scripts.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,102 @@
1
- # Temporary Holding Version
1
+ # Signal K P2P
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Peer-to-peer vessel data between Signal K instances.** One global public mesh,
4
+ joined by default, plus any number of private, encrypted groups.
5
+
6
+ > **Status: v0.1.0 — first public release.** The core path
7
+ > (publish → relay → inject) and the security, election, group and AIS features
8
+ > are implemented and validated over WAN through a VPS peer. It has not yet been
9
+ > validated on real boats or Starlink links; treat this release as a field-test
10
+ > candidate.
11
+
12
+ ## Features
13
+
14
+ - Share position, navigation (including magnetic course/heading, attitude, rate of
15
+ turn, speed through water and GNSS DOP/satellites), depth, environment, tanks,
16
+ destination, anchor, propulsion and systems, per network.
17
+ - Join the global `all-vessels` network automatically (opt-out, with four consent
18
+ modes), or only share with selected groups.
19
+ - Create private groups with encrypted data, invite links, roles, admin-approved
20
+ MMSIs, member removal and key rotation.
21
+ - Carry other vessels you hear over AIS into a shared map, with four AIS modes and
22
+ nearest-target caps; AIS observations are never re-published.
23
+ - Signed messages, claim/attestation authorization, and one authorized writer per
24
+ vessel context, so a peer can never overwrite another vessel's data.
25
+ - Relay through elected peers with no fixed relays, plus an optional standalone
26
+ Node.js peer for a VPS bootstrap when most boats are behind CGNAT.
27
+ - An admin webapp for claims, groups, join requests and proposals. The Groups
28
+ view includes a Public network card with status, peers/elected relay and
29
+ per-data-set public sharing toggles. It appears under **Webapps** while the
30
+ plugin is enabled, and is also served at
31
+ `/plugins/signalk-p2p-plugin/admin` (admin login required).
32
+
33
+ ## Install
34
+
35
+ From the Signal K App Store: search for **Signal K P2P**, install, restart the
36
+ server, then enable the plugin. Or install into the server's configuration
37
+ directory:
38
+
39
+ ```bash
40
+ cd ~/.signalk
41
+ npm install signalk-p2p-plugin
42
+ ```
43
+
44
+ Requires Node `>=22.5` (a Signal K server on Node 22.5 or newer).
45
+
46
+ After enabling the plugin, open **Signal K P2P** from the Webapps menu. The UI
47
+ calls the admin-gated API, so you must be signed in as an administrator.
48
+
49
+ Default sharing is conservative: position, navigation, depth and AIS are on for
50
+ the public mesh; environment, tanks, destination, anchor, propulsion and systems
51
+ are off publicly until you enable them. See
52
+ [`shared-data.md`](docs/plans/shared-data.md) for the data sets and defaults.
53
+
54
+ ## Standalone peer
55
+
56
+ Run a relay on a VPS or always-on host when most boats are behind CGNAT:
57
+
58
+ ```bash
59
+ npm install -g signalk-p2p-plugin
60
+ signalk-p2p-peer --help
61
+ ```
62
+
63
+ See [`deploy/README.md`](deploy/README.md) for the systemd unit and an example
64
+ configuration.
65
+
66
+ ## Design
67
+
68
+ | Document | Contents |
69
+ | ----------------------------------------------------------- | ----------------------------------------------- |
70
+ | [`architecture.md`](docs/plans/architecture.md) | Stack, live/durable split, identity, invariants |
71
+ | [`shared-data.md`](docs/plans/shared-data.md) | Data sets, defaults, rates, AIS modes |
72
+ | [`networks.md`](docs/plans/networks.md) | Public mesh, adaptive sharding, groups |
73
+ | [`security.md`](docs/plans/security.md) | Write authorization, claims, MMSI verification |
74
+ | [`data-and-injection.md`](docs/plans/data-and-injection.md) | Wire records, merge, injection |
75
+ | [`v1-design.md`](docs/plans/v1-design.md) | Build order, spike, risks |
76
+ | [`spike-findings.md`](docs/plans/spike-findings.md) | Measured payload and replication costs |
77
+ | [`peer-node.md`](docs/plans/peer-node.md) | Standalone Node.js peer / VPS relay |
78
+
79
+ ## Development
80
+
81
+ ```bash
82
+ npm install
83
+ npm run build # TypeScript -> dist/
84
+ npm test # vitest
85
+ npm run peer # standalone peer/relay (dev)
86
+ npm run peer:start # compiled standalone peer
87
+ npm run smoke:client # connect to a running peer (-- --listen to observe)
88
+ npm run smoke:plugin # two mock Signal K instances through the live path
89
+ npm run smoke:election # collect capabilities and print the elected relay
90
+ npm run smoke:group # full group lifecycle over the network
91
+ npm run spike # payload + replication measurements
92
+ npm run spike:swarm # Hyperswarm idle/payload measurement
93
+ npm run format
94
+ npm run lint
95
+ ```
96
+
97
+ To deploy the standalone peer on a VPS, see
98
+ [`deploy/README.md`](deploy/README.md).
99
+
100
+ ## License
101
+
102
+ Licensed under the [Apache License, Version 2.0](LICENSE).
@@ -0,0 +1,83 @@
1
+ # Deploying a standalone peer
2
+
3
+ A peer is an ordinary Hyperswarm peer. It is useful on an always-on, reachable
4
+ host (a VPS, a marina server, a club box) so boats behind CGNAT can reach the
5
+ mesh. It is not a central authority and can be replaced by an elected peer.
6
+
7
+ Tested on Fedora 44 with Node 22.23.1.
8
+
9
+ ## 1. Install Node
10
+
11
+ Node `>=22.5` is required. On Fedora:
12
+
13
+ ```bash
14
+ dnf -y install nodejs npm
15
+ node --version
16
+ ```
17
+
18
+ ## 2. Install the package
19
+
20
+ From a checkout, build a tarball and install it into `/opt`:
21
+
22
+ ```bash
23
+ npm pack
24
+ scp signalk-p2p-plugin-*.tgz root@your-host:/tmp/
25
+ ```
26
+
27
+ On the host:
28
+
29
+ ```bash
30
+ id -u signalk-p2p >/dev/null 2>&1 || \
31
+ useradd --system --home-dir /var/lib/signalk-p2p --shell /sbin/nologin signalk-p2p
32
+ install -d -o signalk-p2p -g signalk-p2p /opt/signalk-p2p /var/lib/signalk-p2p
33
+ install -d /etc/signalk-p2p
34
+ cd /opt/signalk-p2p
35
+ npm init -y
36
+ npm install --omit=dev /tmp/signalk-p2p-plugin-*.tgz
37
+ chown -R signalk-p2p:signalk-p2p /opt/signalk-p2p /var/lib/signalk-p2p
38
+ ```
39
+
40
+ ## 3. Configure and run
41
+
42
+ ```bash
43
+ cp deploy/peer.example.json /etc/signalk-p2p/peer.json
44
+ cp deploy/signalk-p2p-peer.service /etc/systemd/system/
45
+ systemctl daemon-reload
46
+ systemctl enable --now signalk-p2p-peer
47
+ journalctl -u signalk-p2p-peer -f
48
+ ```
49
+
50
+ The peer prints its identity fingerprint and the topic it joined. The Ed25519
51
+ identity is created in `/var/lib/signalk-p2p/identity/ed25519.pem` (mode 0600).
52
+
53
+ ## 4. Firewall
54
+
55
+ Hyperswarm uses UDP. If you set `"port": 49737`, allow UDP 49737 inbound so other
56
+ peers can dial it:
57
+
58
+ ```bash
59
+ firewall-cmd --permanent --add-port=49737/udp
60
+ firewall-cmd --reload
61
+ ```
62
+
63
+ Without a fixed port the DHT uses an ephemeral UDP port; outbound UDP must still
64
+ be allowed. No TCP is required.
65
+
66
+ ## 6. Private group relay
67
+
68
+ Add `"groupInvites": ["<token>"]` to the config (or pass `--group-invite <token>`)
69
+ to join and relay a private group. The peer sends a join request from its
70
+ synthetic selfId; an admin must approve it (a `viewer` role is enough, because a
71
+ relay does not publish vessel data).
72
+
73
+ ## 5. Verify
74
+
75
+ From another machine on a different network:
76
+
77
+ ```bash
78
+ npm run smoke:client -- --listen # in one terminal
79
+ npm run smoke:client # in another
80
+ ```
81
+
82
+ The listener should print the sender's `smoke-…` batch. This exercises public DHT
83
+ discovery, NAT traversal, the Protomux live channel, and relay forwarding.
@@ -0,0 +1,9 @@
1
+ {
2
+ "dataDir": "/var/lib/signalk-p2p",
3
+ "topic": "signalk-p2p/all-vessels/v1",
4
+ "batchIntervalMs": 2000,
5
+ "maxBatchBytes": 65536,
6
+ "historyBatches": 10,
7
+ "port": 49737,
8
+ "groupInvites": []
9
+ }
@@ -0,0 +1,23 @@
1
+ [Unit]
2
+ Description=Signal K P2P peer
3
+ After=network-online.target
4
+ Wants=network-online.target
5
+
6
+ [Service]
7
+ Type=simple
8
+ User=signalk-p2p
9
+ Group=signalk-p2p
10
+ WorkingDirectory=/var/lib/signalk-p2p
11
+ ExecStart=/opt/signalk-p2p/node_modules/.bin/signalk-p2p-peer --config /etc/signalk-p2p/peer.json
12
+ Restart=always
13
+ RestartSec=5
14
+ # Remove DEBUG in production; keep it while validating peer connections.
15
+ Environment=DEBUG=1
16
+ NoNewPrivileges=true
17
+ ProtectSystem=strict
18
+ ProtectHome=true
19
+ ReadWritePaths=/var/lib/signalk-p2p
20
+ LimitNOFILE=65536
21
+
22
+ [Install]
23
+ WantedBy=multi-user.target
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The admin UI is served both by the admin-gated plugin router at
3
+ * `/plugins/signalk-p2p-plugin/admin` and as the Signal K webapp at
4
+ * `/signalk-p2p-plugin/`. `public/index.html` is the single source.
5
+ */
6
+ export declare const ADMIN_PAGE: string;
7
+ //# sourceMappingURL=admin-page.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-page.d.ts","sourceRoot":"","sources":["../src/admin-page.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,UAAU,QAGtB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { readFileSync } from "node:fs";
2
+ /**
3
+ * The admin UI is served both by the admin-gated plugin router at
4
+ * `/plugins/signalk-p2p-plugin/admin` and as the Signal K webapp at
5
+ * `/signalk-p2p-plugin/`. `public/index.html` is the single source.
6
+ */
7
+ export const ADMIN_PAGE = readFileSync(new URL("../public/index.html", import.meta.url), "utf8");
8
+ //# sourceMappingURL=admin-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-page.js","sourceRoot":"","sources":["../src/admin-page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CACpC,IAAI,GAAG,CAAC,sBAAsB,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,EAChD,MAAM,CACP,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { AisTarget } from "./store.js";
2
+ /**
3
+ * Build AIS observation records for a set of local targets. Static details are
4
+ * only emitted when they change, to keep repeat batches small.
5
+ */
6
+ export declare function buildAisRecords(targets: AisTarget[], sentStatic: Map<number, string>): Buffer[];
7
+ //# sourceMappingURL=publish.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../src/ais/publish.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,SAAS,EAAE,EACpB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,MAAM,EAAE,CAkDV"}
@@ -0,0 +1,41 @@
1
+ import { encodeAisSnapshot, encodeAisStatic } from "../data/ais.js";
2
+ import { encodeEnvelope } from "../data/envelope.js";
3
+ /**
4
+ * Build AIS observation records for a set of local targets. Static details are
5
+ * only emitted when they change, to keep repeat batches small.
6
+ */
7
+ export function buildAisRecords(targets, sentStatic) {
8
+ const records = [];
9
+ for (const target of targets) {
10
+ if (target.latitude === undefined || target.longitude === undefined) {
11
+ continue;
12
+ }
13
+ records.push(encodeEnvelope("ais-snapshot", encodeAisSnapshot({
14
+ mmsi: target.mmsi,
15
+ timestamp: target.lastSeen,
16
+ latitude: target.latitude,
17
+ longitude: target.longitude,
18
+ courseOverGround: target.courseOverGround,
19
+ speedOverGround: target.speedOverGround,
20
+ heading: target.heading,
21
+ navState: target.navState,
22
+ aisClass: target.aisClass,
23
+ })));
24
+ if (target.name !== undefined ||
25
+ target.callsign !== undefined ||
26
+ target.shipType !== undefined) {
27
+ const key = `${target.name ?? ""}\u0000${target.callsign ?? ""}\u0000${target.shipType ?? ""}`;
28
+ if (sentStatic.get(target.mmsi) !== key) {
29
+ records.push(encodeEnvelope("ais-static", encodeAisStatic({
30
+ mmsi: target.mmsi,
31
+ shipType: target.shipType,
32
+ name: target.name,
33
+ callsign: target.callsign,
34
+ })));
35
+ sentStatic.set(target.mmsi, key);
36
+ }
37
+ }
38
+ }
39
+ return records;
40
+ }
41
+ //# sourceMappingURL=publish.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish.js","sourceRoot":"","sources":["../../src/ais/publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAoB,EACpB,UAA+B;IAE/B,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YACpE,SAAS;QACX,CAAC;QACD,OAAO,CAAC,IAAI,CACV,cAAc,CACZ,cAAc,EACd,iBAAiB,CAAC;YAChB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,SAAS,EAAE,MAAM,CAAC,QAAQ;YAC1B,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;YACzC,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC1B,CAAC,CACH,CACF,CAAC;QAEF,IACE,MAAM,CAAC,IAAI,KAAK,SAAS;YACzB,MAAM,CAAC,QAAQ,KAAK,SAAS;YAC7B,MAAM,CAAC,QAAQ,KAAK,SAAS,EAC7B,CAAC;YACD,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC,IAAI,IAAI,EAAE,SAAS,MAAM,CAAC,QAAQ,IAAI,EAAE,SAC5D,MAAM,CAAC,QAAQ,IAAI,EACrB,EAAE,CAAC;YACH,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;gBACxC,OAAO,CAAC,IAAI,CACV,cAAc,CACZ,YAAY,EACZ,eAAe,CAAC;oBACd,IAAI,EAAE,MAAM,CAAC,IAAI;oBACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,IAAI,EAAE,MAAM,CAAC,IAAI;oBACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ;iBAC1B,CAAC,CACH,CACF,CAAC;gBACF,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,41 @@
1
+ import type { Delta } from "@signalk/server-api";
2
+ import type { AisClass } from "../data/ais.js";
3
+ import { type NavState } from "../data/types.js";
4
+ export interface AisTarget {
5
+ mmsi: number;
6
+ name?: string;
7
+ callsign?: string;
8
+ shipType?: number;
9
+ latitude?: number;
10
+ longitude?: number;
11
+ courseOverGround?: number;
12
+ speedOverGround?: number;
13
+ heading?: number;
14
+ navState?: NavState;
15
+ aisClass?: AisClass;
16
+ /** Unix seconds when this target was last heard locally. */
17
+ lastSeen: number;
18
+ }
19
+ /**
20
+ * Collects AIS targets heard by this vessel's own receiver. It deliberately
21
+ * reads only local sources: P2P-injected data is excluded by the subscription
22
+ * and filtered again here, so a received observation is never re-published.
23
+ */
24
+ export declare class AisTargetStore {
25
+ private readonly selfMmsi?;
26
+ private readonly targets;
27
+ constructor(selfMmsi?: number | undefined);
28
+ applyDelta(delta: Delta, now: number): void;
29
+ private applyPath;
30
+ /**
31
+ * Targets that can be shared: heard locally, with a position, an AIS class,
32
+ * and recently seen. The nearest to `position` come first.
33
+ */
34
+ nearest(position: {
35
+ latitude: number;
36
+ longitude: number;
37
+ } | undefined, maxTargets: number, now: number, maxAgeSeconds?: number): AisTarget[];
38
+ prune(now: number, maxAgeSeconds?: number): void;
39
+ clear(): void;
40
+ }
41
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/ais/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE7D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAID;;;;GAIG;AACH,qBAAa,cAAc;IAGb,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAFtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgC;IAExD,YAA6B,QAAQ,CAAC,EAAE,MAAM,YAAA,EAAI;IAElD,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAoB1C;IAED,OAAO,CAAC,SAAS;IA6DjB;;;OAGG;IACH,OAAO,CACL,QAAQ,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,EAC7D,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,MAAM,EACX,aAAa,SAAM,GAClB,SAAS,EAAE,CAuBb;IAED,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,SAAM,GAAG,IAAI,CAM5C;IAED,KAAK,IAAI,IAAI,CAEZ;CACF"}