@serfab/cadre-core 1.22.0 → 1.24.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.
- package/README.md +216 -294
- package/dist/arachnode-stub.d.ts +12 -4
- package/dist/arachnode-stub.js +15 -8
- package/dist/arachnode-stub.js.map +1 -1
- package/dist/cadre-invite-protocol.js +5 -4
- package/dist/cadre-invite-protocol.js.map +1 -1
- package/dist/cadre-node.d.ts +159 -53
- package/dist/cadre-node.js +276 -89
- package/dist/cadre-node.js.map +1 -1
- package/dist/control-authorization.d.ts +14 -2
- package/dist/control-authorization.js +8 -3
- package/dist/control-authorization.js.map +1 -1
- package/dist/control-cohort.d.ts +27 -13
- package/dist/control-cohort.js +21 -14
- package/dist/control-cohort.js.map +1 -1
- package/dist/control-database.d.ts +18 -16
- package/dist/control-database.js +57 -22
- package/dist/control-database.js.map +1 -1
- package/dist/control-protocol-guard.d.ts +1 -1
- package/dist/control-protocol-guard.js +7 -3
- package/dist/control-protocol-guard.js.map +1 -1
- package/dist/control-read-retry.d.ts +49 -11
- package/dist/control-read-retry.js +56 -15
- package/dist/control-read-retry.js.map +1 -1
- package/dist/control-retry.d.ts +32 -3
- package/dist/control-retry.js +35 -4
- package/dist/control-retry.js.map +1 -1
- package/dist/control-schema-version.d.ts +5 -5
- package/dist/control-schema-version.js +5 -5
- package/dist/control-schema-version.js.map +1 -1
- package/dist/control-schema.d.ts +5 -5
- package/dist/control-schema.js +1032 -1011
- package/dist/control-schema.js.map +1 -1
- package/dist/control-write-retry.d.ts +54 -65
- package/dist/control-write-retry.js +134 -158
- package/dist/control-write-retry.js.map +1 -1
- package/dist/delegate-admission.d.ts +1 -1
- package/dist/delegate-admission.js +1 -1
- package/dist/edge-node/config.d.ts +4 -3
- package/dist/edge-node/config.js +11 -9
- package/dist/edge-node/config.js.map +1 -1
- package/dist/edge-node/dissolve.d.ts +4 -4
- package/dist/edge-node/dissolve.js +4 -4
- package/dist/edge-node/edge-join.d.ts +1 -1
- package/dist/edge-node/edge-join.js +1 -1
- package/dist/edge-node/edge-node.js +2 -2
- package/dist/edge-node/edge-node.js.map +1 -1
- package/dist/edge-node/index.d.ts +1 -0
- package/dist/edge-node/index.js +1 -0
- package/dist/edge-node/index.js.map +1 -1
- package/dist/edge-node/join-credential.d.ts +1 -1
- package/dist/edge-node/join-credential.js +1 -1
- package/dist/edge-node/lazy-raw-storage.js +12 -0
- package/dist/edge-node/lazy-raw-storage.js.map +1 -1
- package/dist/edge-node/listen-addrs.d.ts +21 -0
- package/dist/edge-node/listen-addrs.js +25 -0
- package/dist/edge-node/listen-addrs.js.map +1 -0
- package/dist/edge-node/owner-grant.d.ts +1 -1
- package/dist/edge-node/owner-grant.js +1 -1
- package/dist/edge-node/platform.d.ts +5 -4
- package/dist/edge-node/platform.js.map +1 -1
- package/dist/edge-node/strand-move.d.ts +1 -1
- package/dist/edge-node/strand-move.js +1 -1
- package/dist/edge-node/strands.js +27 -11
- package/dist/edge-node/strands.js.map +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.js +18 -7
- package/dist/index.js.map +1 -1
- package/dist/invitation-bootstrap.d.ts +28 -5
- package/dist/invitation-bootstrap.js +41 -8
- package/dist/invitation-bootstrap.js.map +1 -1
- package/dist/link-budget.d.ts +53 -4
- package/dist/link-budget.js +58 -5
- package/dist/link-budget.js.map +1 -1
- package/dist/machine-removal.d.ts +2 -2
- package/dist/machine-removal.js +4 -3
- package/dist/machine-removal.js.map +1 -1
- package/dist/membership-connection-gater.d.ts +2 -2
- package/dist/membership-connection-gater.js +2 -2
- package/dist/membership-view.d.ts +2 -2
- package/dist/membership-view.js +6 -3
- package/dist/membership-view.js.map +1 -1
- package/dist/node-claim-payload.d.ts +15 -7
- package/dist/node-claim-payload.js +25 -9
- package/dist/node-claim-payload.js.map +1 -1
- package/dist/node-class.d.ts +36 -0
- package/dist/node-class.js +26 -0
- package/dist/node-class.js.map +1 -0
- package/dist/node-default-transports.d.ts +50 -3
- package/dist/node-default-transports.js +48 -3
- package/dist/node-default-transports.js.map +1 -1
- package/dist/node-roles.d.ts +118 -0
- package/dist/node-roles.js +142 -0
- package/dist/node-roles.js.map +1 -0
- package/dist/node-transports.d.ts +6 -2
- package/dist/node-transports.js +39 -7
- package/dist/node-transports.js.map +1 -1
- package/dist/owner-anchor-sync.js +1 -1
- package/dist/owner-key-export.js +1 -1
- package/dist/owner-key-flows.d.ts +1 -1
- package/dist/owner-key-store.js +1 -1
- package/dist/owner-signer.js +1 -1
- package/dist/peer-authorization.d.ts +3 -1
- package/dist/peer-authorization.js +3 -1
- package/dist/peer-authorization.js.map +1 -1
- package/dist/peer-dial.d.ts +74 -10
- package/dist/peer-dial.js +89 -17
- package/dist/peer-dial.js.map +1 -1
- package/dist/peer-join-backfill.js +4 -4
- package/dist/peer-join-backfill.js.map +1 -1
- package/dist/peer-record.d.ts +34 -9
- package/dist/peer-record.js +66 -13
- package/dist/peer-record.js.map +1 -1
- package/dist/pending-join-runner.d.ts +1 -1
- package/dist/pending-join-runner.js +1 -1
- package/dist/provider/client.d.ts +6 -5
- package/dist/provider/client.js +3 -3
- package/dist/provider/client.js.map +1 -1
- package/dist/provider/descriptor.d.ts +1 -1
- package/dist/provider/descriptor.js +1 -1
- package/dist/provider/oauth.d.ts +1 -1
- package/dist/provider/oauth.js +1 -1
- package/dist/provider/rent-node.d.ts +4 -3
- package/dist/provider/rent-node.js +3 -3
- package/dist/provider/rent-node.js.map +1 -1
- package/dist/relay-addrs.d.ts +62 -7
- package/dist/relay-addrs.js +74 -11
- package/dist/relay-addrs.js.map +1 -1
- package/dist/relay-reservation.d.ts +1 -1
- package/dist/relay-reservation.js +1 -1
- package/dist/relay-server.d.ts +6 -5
- package/dist/relay-server.js +5 -5
- package/dist/relay-server.js.map +1 -1
- package/dist/schema-verification.d.ts +13 -10
- package/dist/schema-verification.js +32 -24
- package/dist/schema-verification.js.map +1 -1
- package/dist/sealed-party-key.js +1 -1
- package/dist/seed-bootstrap.d.ts +4 -3
- package/dist/seed-bootstrap.js +6 -7
- package/dist/seed-bootstrap.js.map +1 -1
- package/dist/strand-addr-protocol.d.ts +8 -6
- package/dist/strand-addr-protocol.js +12 -10
- package/dist/strand-addr-protocol.js.map +1 -1
- package/dist/strand-app-schema-report.d.ts +16 -2
- package/dist/strand-app-schema-report.js +15 -0
- package/dist/strand-app-schema-report.js.map +1 -1
- package/dist/strand-cohort.d.ts +1 -4
- package/dist/strand-cohort.js.map +1 -1
- package/dist/strand-commit-durability.d.ts +1 -1
- package/dist/strand-database.d.ts +13 -6
- package/dist/strand-database.js +17 -9
- package/dist/strand-database.js.map +1 -1
- package/dist/strand-first-sync-gate.d.ts +3 -2
- package/dist/strand-first-sync-gate.js +3 -2
- package/dist/strand-first-sync-gate.js.map +1 -1
- package/dist/strand-formation-deadlines.d.ts +2 -2
- package/dist/strand-formation-deadlines.js +2 -2
- package/dist/strand-formation-protocol.d.ts +1 -1
- package/dist/strand-formation-protocol.js +51 -16
- package/dist/strand-formation-protocol.js.map +1 -1
- package/dist/strand-instance-manager.d.ts +134 -42
- package/dist/strand-instance-manager.js +331 -76
- package/dist/strand-instance-manager.js.map +1 -1
- package/dist/strand-membership-reconciler.d.ts +8 -3
- package/dist/strand-membership-reconciler.js +8 -3
- package/dist/strand-membership-reconciler.js.map +1 -1
- package/dist/strand-membership-writer.d.ts +2 -2
- package/dist/strand-membership-writer.js +41 -39
- package/dist/strand-membership-writer.js.map +1 -1
- package/dist/strand-move.js +1 -1
- package/dist/strand-network-config.d.ts +15 -5
- package/dist/strand-network-config.js +7 -6
- package/dist/strand-network-config.js.map +1 -1
- package/dist/strand-party-key-rotation.d.ts +7 -3
- package/dist/strand-party-key-rotation.js +7 -3
- package/dist/strand-party-key-rotation.js.map +1 -1
- package/dist/strand-party-machines.d.ts +19 -8
- package/dist/strand-party-machines.js +26 -11
- package/dist/strand-party-machines.js.map +1 -1
- package/dist/strand-party-peers.d.ts +36 -14
- package/dist/strand-party-peers.js +24 -15
- package/dist/strand-party-peers.js.map +1 -1
- package/dist/strand-peer-redial.d.ts +1 -1
- package/dist/strand-peer-redial.js +1 -1
- package/dist/strand-reactivity.d.ts +20 -17
- package/dist/strand-reactivity.js +31 -18
- package/dist/strand-reactivity.js.map +1 -1
- package/dist/strand-revocation-enforcer.d.ts +3 -3
- package/dist/strand-revocation-enforcer.js +3 -3
- package/dist/strand-wake-protocol.d.ts +19 -7
- package/dist/strand-wake-protocol.js +22 -10
- package/dist/strand-wake-protocol.js.map +1 -1
- package/dist/strand-watcher.d.ts +1 -1
- package/dist/strand-watcher.js +1 -1
- package/dist/table-change-watch.js +1 -1
- package/dist/types.d.ts +127 -57
- package/dist/types.js.map +1 -1
- package/dist/webrtc-upgrade.d.ts +254 -0
- package/dist/webrtc-upgrade.js +355 -0
- package/dist/webrtc-upgrade.js.map +1 -0
- package/package.json +9 -9
- package/src/announce-addrs.ts +93 -93
- package/src/arachnode-stub.ts +18 -10
- package/src/bootstrap-peer-store-file.ts +44 -44
- package/src/bootstrap-peer-store.ts +214 -214
- package/src/cadre-invite-protocol.ts +741 -740
- package/src/cadre-node.ts +12462 -12252
- package/src/claim-proof.ts +147 -147
- package/src/control-authorization.ts +290 -276
- package/src/control-cohort.ts +223 -204
- package/src/control-database.ts +72 -28
- package/src/control-formation-recorder.ts +359 -359
- package/src/control-protocol-guard.ts +370 -366
- package/src/control-read-retry.ts +222 -180
- package/src/control-retry.ts +36 -4
- package/src/control-schema-version.ts +301 -301
- package/src/control-schema.ts +1108 -1087
- package/src/control-write-retry.ts +639 -669
- package/src/delegate-admission.ts +351 -351
- package/src/describe-thrown.ts +60 -60
- package/src/ed25519-key.ts +185 -185
- package/src/edge-node/config.ts +13 -10
- package/src/edge-node/dissolve.ts +252 -252
- package/src/edge-node/edge-join.ts +320 -320
- package/src/edge-node/edge-node.ts +1095 -1095
- package/src/edge-node/index.ts +60 -59
- package/src/edge-node/join-credential.ts +16 -16
- package/src/edge-node/lazy-raw-storage.ts +194 -178
- package/src/edge-node/listen-addrs.ts +26 -0
- package/src/edge-node/node-local.ts +84 -84
- package/src/edge-node/options.ts +195 -195
- package/src/edge-node/owner-grant.ts +63 -63
- package/src/edge-node/platform.ts +5 -4
- package/src/edge-node/strand-move.ts +266 -266
- package/src/edge-node/strands.ts +27 -12
- package/src/enrolled-machine-store-file.ts +43 -43
- package/src/enrolled-machine-store.ts +280 -280
- package/src/fetch-impl.ts +23 -23
- package/src/file-durable-slot.ts +64 -64
- package/src/file-safe-name.ts +32 -32
- package/src/formation-approval.ts +604 -604
- package/src/formation-token.ts +63 -63
- package/src/fs-atomic.ts +92 -92
- package/src/index.ts +987 -957
- package/src/invitation-bootstrap.ts +152 -118
- package/src/joined-strand-store.ts +553 -553
- package/src/key-store-file.ts +142 -142
- package/src/link-budget.ts +61 -5
- package/src/machine-removal.ts +211 -210
- package/src/member-redemption.ts +643 -643
- package/src/membership-connection-gater.ts +650 -650
- package/src/membership-view.ts +147 -144
- package/src/node-claim-payload.ts +34 -12
- package/src/node-class.ts +47 -0
- package/src/node-default-transports.ts +65 -3
- package/src/node-roles.ts +220 -0
- package/src/node-transports.ts +86 -49
- package/src/owner-anchor-sync.ts +172 -172
- package/src/owner-grant-protocol.ts +547 -547
- package/src/owner-key-export.ts +348 -348
- package/src/owner-key-flows.ts +109 -109
- package/src/owner-key-store.ts +1 -1
- package/src/owner-keys.ts +179 -179
- package/src/owner-signer.ts +92 -92
- package/src/peer-addr-book.ts +252 -252
- package/src/peer-authorization.ts +584 -582
- package/src/peer-dial.ts +698 -605
- package/src/peer-join-backfill.ts +961 -961
- package/src/peer-record.ts +71 -16
- package/src/pending-join-runner.ts +798 -798
- package/src/primary-lan-address.ts +47 -47
- package/src/provider/client.ts +327 -326
- package/src/provider/descriptor.ts +129 -129
- package/src/provider/index.ts +59 -59
- package/src/provider/oauth.ts +285 -285
- package/src/provider/rent-node.ts +276 -275
- package/src/relay-addrs.ts +90 -12
- package/src/relay-reservation.ts +1 -1
- package/src/relay-server.ts +99 -98
- package/src/schema-verification.ts +38 -23
- package/src/sealed-party-key.ts +190 -190
- package/src/seed-bootstrap.ts +8 -11
- package/src/seed-trust-policy.ts +353 -353
- package/src/self-address-update.ts +19 -19
- package/src/strand-addr-protocol.ts +17 -14
- package/src/strand-app-schema-report.ts +147 -122
- package/src/strand-cohort.ts +1 -5
- package/src/strand-commit-durability.ts +165 -165
- package/src/strand-database.ts +522 -510
- package/src/strand-first-sync-gate.ts +3 -2
- package/src/strand-formation-deadlines.ts +227 -227
- package/src/strand-formation-manager.ts +731 -731
- package/src/strand-formation-protocol.ts +1174 -1138
- package/src/strand-fret-addrs.ts +179 -179
- package/src/strand-instance-manager.ts +381 -85
- package/src/strand-membership-reconciler.ts +1315 -1310
- package/src/strand-membership-writer.ts +2152 -2150
- package/src/strand-move.ts +1 -1
- package/src/strand-network-config.ts +16 -6
- package/src/strand-offline.ts +178 -178
- package/src/strand-party-key-rotation.ts +440 -436
- package/src/strand-party-machines.ts +308 -293
- package/src/strand-party-peers.ts +151 -129
- package/src/strand-peer-redial.ts +1 -1
- package/src/strand-reactivity.ts +36 -19
- package/src/strand-revocation-enforcer.ts +758 -758
- package/src/strand-wake-protocol.ts +406 -394
- package/src/strand-watcher.ts +1 -1
- package/src/table-change-watch.ts +285 -285
- package/src/timed-step.ts +28 -28
- package/src/timeout-scheduler.ts +29 -29
- package/src/trusted-owner-store.ts +242 -242
- package/src/types.ts +3182 -3112
- package/src/webrtc-upgrade.ts +439 -0
package/src/relay-addrs.ts
CHANGED
|
@@ -53,11 +53,12 @@
|
|
|
53
53
|
* other. A node with configured relays is built with that discovery switched off
|
|
54
54
|
* altogether when it has a transport list to wrap (`node-transports.ts`), because it
|
|
55
55
|
* CAN reach a relay-capable peer in its own namespace and take the configured relay's
|
|
56
|
-
* slot. See `relay-reservation.ts`'s module doc and `docs/
|
|
56
|
+
* slot. See `relay-reservation.ts`'s module doc and `docs/network/relay.md`.
|
|
57
57
|
*/
|
|
58
58
|
|
|
59
59
|
import { multiaddr, type Component } from '@multiformats/multiaddr';
|
|
60
60
|
import { circuitRelayTargetOrThrow } from './delegate-admission.js';
|
|
61
|
+
import { resolveStunServers, type StunServer } from './relay-stun.js';
|
|
61
62
|
import type { NetworkConfig } from './types.js';
|
|
62
63
|
import type { RelayReservationState } from './relay-reservation.js';
|
|
63
64
|
|
|
@@ -83,6 +84,19 @@ export const DEFAULT_DIRECT_LISTEN_ADDR = '/ip4/0.0.0.0/tcp/0';
|
|
|
83
84
|
*/
|
|
84
85
|
export const RELAY_SEARCH_LISTEN_ADDR = '/p2p-circuit';
|
|
85
86
|
|
|
87
|
+
/**
|
|
88
|
+
* The WebRTC listen entry, for every host that offers one: the edge apps
|
|
89
|
+
* (`edge-node/listen-addrs.ts`) and `cadre-cli`'s `network.webrtc`. One home for the
|
|
90
|
+
* spelling {@link listenTransportKind} classifies, like the two constants around it —
|
|
91
|
+
* a host that mis-spells it gets a refusal naming the transport instead of a listener.
|
|
92
|
+
*
|
|
93
|
+
* It binds no socket: the transport registers libp2p's signalling handler and derives
|
|
94
|
+
* this node's address from each relay reservation it holds, which is why the entry is
|
|
95
|
+
* worth adding to a machine reachable only through a relay and worth nothing on one with
|
|
96
|
+
* a public address.
|
|
97
|
+
*/
|
|
98
|
+
export const WEBRTC_LISTEN_ADDR = '/webrtc';
|
|
99
|
+
|
|
86
100
|
/**
|
|
87
101
|
* The circuit-listen multiaddr for each configured relay: `<relayAddr>/p2p-circuit`.
|
|
88
102
|
* An entry that already carries `/p2p-circuit` is passed through unchanged.
|
|
@@ -126,7 +140,7 @@ export function resolveListenAddrs(network: NetworkConfig | undefined): string[]
|
|
|
126
140
|
if (!listenAddrs && relayEntries.length === 0) {
|
|
127
141
|
return undefined;
|
|
128
142
|
}
|
|
129
|
-
// An explicitly empty `listenAddrs` (
|
|
143
|
+
// An explicitly empty `listenAddrs` (a device that names no listener of its own) stays
|
|
130
144
|
// empty — but a relay named alongside it still gets its listen entry, since
|
|
131
145
|
// acquiring a slot is the whole point of configuring a relay.
|
|
132
146
|
return dedupe([...(listenAddrs ?? [DEFAULT_DIRECT_LISTEN_ADDR]), ...relayEntries]);
|
|
@@ -143,6 +157,37 @@ export interface ListenTransportOptions {
|
|
|
143
157
|
* {@link WS_TRANSPORT_SWITCH_PORT}.
|
|
144
158
|
*/
|
|
145
159
|
wsPort?: number;
|
|
160
|
+
/**
|
|
161
|
+
* Present when some listen entry names `/webrtc` — the switch that makes
|
|
162
|
+
* `nodeDefaultTransports` add `@libp2p/webrtc`'s transport
|
|
163
|
+
* (`node-default-transports.ts`). Unlike {@link wsPort} the value is real: it is the
|
|
164
|
+
* ICE servers that transport needs, derived once here from `network.relayAddrs` and
|
|
165
|
+
* `network.stunUrls` (`relay-stun.ts` → `resolveStunServers`), so the factory reads one
|
|
166
|
+
* field instead of re-deriving them from a `NetworkConfig` it is not given.
|
|
167
|
+
*
|
|
168
|
+
* May be EMPTY, and an empty array is still the switch: WebRTC with no STUN server
|
|
169
|
+
* offers host and LAN candidates only, which is enough between two machines on one
|
|
170
|
+
* network. Absent is the only "no WebRTC" answer.
|
|
171
|
+
*/
|
|
172
|
+
webrtcIceServers?: StunServer[];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* The subset of a resolved {@link ListenTransportOptions} that is a `createLibp2pNode` option,
|
|
177
|
+
* for the two sites that spread it into one (`cadre-node.ts`, `strand-instance-manager.ts`).
|
|
178
|
+
*
|
|
179
|
+
* `wsPort` is db-p2p's own switch, so it goes through. {@link ListenTransportOptions.webrtcIceServers}
|
|
180
|
+
* does not: it is read only by `network.defaultTransports`, and db-p2p knows no such key —
|
|
181
|
+
* handing it one is the drift the strand builder already avoids for `relayAddrs`. One home for
|
|
182
|
+
* that distinction rather than a correct spread at each site.
|
|
183
|
+
*
|
|
184
|
+
* NOTE: the allow-list is the destructuring, so a THIRD {@link ListenTransportOptions} field that
|
|
185
|
+
* is a db-p2p option has to be added here too or it is dropped in silence. Deliberate — the
|
|
186
|
+
* opposite default would leak a cadre-only field into db-p2p's options, which is the failure the
|
|
187
|
+
* function exists to prevent.
|
|
188
|
+
*/
|
|
189
|
+
export function listenTransportNodeOptions({ wsPort }: ListenTransportOptions): { wsPort?: number } {
|
|
190
|
+
return wsPort === undefined ? {} : { wsPort };
|
|
146
191
|
}
|
|
147
192
|
|
|
148
193
|
/**
|
|
@@ -199,11 +244,18 @@ const WS_TRANSPORT_SWITCH_PORT = 0;
|
|
|
199
244
|
* case where cadre passes the transport list itself (`node-transports.ts`, to switch
|
|
200
245
|
* relay discovery off); when the embedder gave none, that list comes from
|
|
201
246
|
* `network.defaultTransports`, which reads the same switch.
|
|
202
|
-
* - **
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
247
|
+
* - **WebRTC is derived ONLY for a node that passed `network.defaultTransports`.** That
|
|
248
|
+
* field is a Node host's injected transport list
|
|
249
|
+
* (`@serfab/cadre-core/node-default-transports`), and it is the only thing in this repo
|
|
250
|
+
* that can supply `@libp2p/webrtc`'s Node build — whose module graph loads
|
|
251
|
+
* `node-datachannel`'s native addon, so this file's graph, which every React Native and
|
|
252
|
+
* browser bundle reaches, must not import it. Without that field a `/webrtc` entry is
|
|
253
|
+
* refused exactly as before.
|
|
254
|
+
* - **Everything else is REFUSED.** Deriving `/quic-v1` or `/webtransport` would mean
|
|
255
|
+
* importing transport packages into every `cadre-core` consumer including the React
|
|
256
|
+
* Native and browser bundles (against the cross-platform rule in `AGENTS.md`) and
|
|
257
|
+
* duplicating policy `libp2p-node.ts` owns. So name the address, name the transport it
|
|
258
|
+
* needs, and refuse to start — matching how `network.relayAddrs` and
|
|
207
259
|
* `network.announceAddrs` already treat an operator typo.
|
|
208
260
|
*
|
|
209
261
|
* Returns `{}` unconditionally when `network.transports` is set: a programmatic embedder
|
|
@@ -227,7 +279,8 @@ const WS_TRANSPORT_SWITCH_PORT = 0;
|
|
|
227
279
|
* {@link resolveListenAddrs}, or the strand derivation, after any per-node rewriting —
|
|
228
280
|
* so the check reads what this node will actually bind.
|
|
229
281
|
* @throws {UnbindableListenAddressError} when a listen entry names a transport outside
|
|
230
|
-
* {tcp, ws/wss, p2p-circuit}
|
|
282
|
+
* {tcp, ws/wss, p2p-circuit}, or names `/webrtc` on a node that passed no
|
|
283
|
+
* `network.defaultTransports`.
|
|
231
284
|
*/
|
|
232
285
|
export function resolveTransportOptions(
|
|
233
286
|
network: NetworkConfig | undefined,
|
|
@@ -237,11 +290,21 @@ export function resolveTransportOptions(
|
|
|
237
290
|
return {};
|
|
238
291
|
}
|
|
239
292
|
const kinds = (listenAddrs ?? []).map((addr) => [addr, listenTransportKind(addr)] as const);
|
|
240
|
-
|
|
293
|
+
// A `/webrtc` entry is bindable only through an injected default transport list, so
|
|
294
|
+
// without one it joins the refusal rather than being accepted and silently unbound.
|
|
295
|
+
const webrtcBindable = network?.defaultTransports !== undefined;
|
|
296
|
+
const unsupported = kinds
|
|
297
|
+
.filter(([, kind]) => kind === 'unsupported' || (kind === 'webrtc' && !webrtcBindable))
|
|
298
|
+
.map(([addr]) => addr);
|
|
241
299
|
if (unsupported.length > 0) {
|
|
242
300
|
throw new UnbindableListenAddressError(unsupported);
|
|
243
301
|
}
|
|
244
|
-
return
|
|
302
|
+
return {
|
|
303
|
+
...(kinds.some(([, kind]) => kind === 'websockets') && { wsPort: WS_TRANSPORT_SWITCH_PORT }),
|
|
304
|
+
...(kinds.some(([, kind]) => kind === 'webrtc') && {
|
|
305
|
+
webrtcIceServers: resolveStunServers(network?.relayAddrs ?? [], network?.stunUrls)
|
|
306
|
+
})
|
|
307
|
+
};
|
|
245
308
|
}
|
|
246
309
|
|
|
247
310
|
/**
|
|
@@ -249,6 +312,10 @@ export function resolveTransportOptions(
|
|
|
249
312
|
* default transports can bind. Names each offending address alongside the libp2p
|
|
250
313
|
* transport package it would need — what the operator has without this is a node that
|
|
251
314
|
* starts and silently never listens there.
|
|
315
|
+
*
|
|
316
|
+
* A `/webrtc` entry reaches this only on a node that passed no
|
|
317
|
+
* `network.defaultTransports`, so it gets the extra sentence naming the setting that
|
|
318
|
+
* does supply WebRTC on a Node host.
|
|
252
319
|
*/
|
|
253
320
|
export class UnbindableListenAddressError extends Error {
|
|
254
321
|
constructor(readonly listenAddrs: readonly string[]) {
|
|
@@ -256,7 +323,10 @@ export class UnbindableListenAddressError extends Error {
|
|
|
256
323
|
'network.listenAddrs names an address this node has no transport for: ' +
|
|
257
324
|
`${listenAddrs.map((a) => `${a} — ${unbindableReason(a)}`).join('; ')}. ` +
|
|
258
325
|
'Default transports bind TCP (including /unix/<path>), WebSocket (/ws, /wss) and circuit-relay addresses only. ' +
|
|
259
|
-
'Either drop the address, or supply the transport programmatically via network.transports.'
|
|
326
|
+
'Either drop the address, or supply the transport programmatically via network.transports.' +
|
|
327
|
+
(listenAddrs.some((a) => listenTransportKind(a) === 'webrtc')
|
|
328
|
+
? ' A /webrtc listener needs a Node host that passes network.defaultTransports (cadre-cli: network.webrtc).'
|
|
329
|
+
: '')
|
|
260
330
|
);
|
|
261
331
|
this.name = 'UnbindableListenAddressError';
|
|
262
332
|
}
|
|
@@ -275,7 +345,7 @@ export class UnbindableListenAddressError extends Error {
|
|
|
275
345
|
* (`strand-network-config.ts`): libp2p reports a bad listen addr itself, and this check
|
|
276
346
|
* must only ever ADD a denial.
|
|
277
347
|
*/
|
|
278
|
-
function listenTransportKind(listenAddr: string): 'tcp' | 'websockets' | 'circuit' | 'ignored' | 'unsupported' {
|
|
348
|
+
function listenTransportKind(listenAddr: string): 'tcp' | 'websockets' | 'webrtc' | 'circuit' | 'ignored' | 'unsupported' {
|
|
279
349
|
let stack: readonly string[];
|
|
280
350
|
try {
|
|
281
351
|
stack = transportStack(listenAddr);
|
|
@@ -294,6 +364,14 @@ function listenTransportKind(listenAddr: string): 'tcp' | 'websockets' | 'circui
|
|
|
294
364
|
if (outermost === 'ws' || outermost === 'wss') {
|
|
295
365
|
return 'websockets';
|
|
296
366
|
}
|
|
367
|
+
// Read from the outermost component like every other kind here, so `/webrtc` and a
|
|
368
|
+
// `…/p2p-circuit/webrtc` entry classify alike — they need the same transport, and the
|
|
369
|
+
// relayed form is the shape libp2p itself derives for a `/webrtc` listener once the
|
|
370
|
+
// reservation lands. `/webrtc-direct` is deliberately NOT this kind: it is a separate
|
|
371
|
+
// libp2p transport (`webRTCDirect`) that nothing here supplies.
|
|
372
|
+
if (outermost === 'webrtc') {
|
|
373
|
+
return 'webrtc';
|
|
374
|
+
}
|
|
297
375
|
// Only a BARE tcp or unix stack is TCP. `@libp2p/tcp` binds both — its `listenFilter`
|
|
298
376
|
// accepts an exact TCP match OR a `/unix/<path>` address (a named pipe on Windows) —
|
|
299
377
|
// and nothing layered on top of either, which is why `/tcp/<port>/<anything else>` is
|
package/src/relay-reservation.ts
CHANGED
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
*
|
|
76
76
|
* ⚠️ WHY LIBP2P'S RELAY DISCOVERY IS SWITCHED OFF. Discovery does reach SOME
|
|
77
77
|
* peers: every connected peer whose identify lists the relay-hop protocol, and a
|
|
78
|
-
*
|
|
78
|
+
* `'server'` member's strand node runs the relay server in the same
|
|
79
79
|
* `/optimystic/strand-<id>/…` namespace as this node's strand node (control nodes
|
|
80
80
|
* share `/optimystic/control-<partyId>/…` the same way). Discovery reserves on such
|
|
81
81
|
* a peer as soon as it connects, and that takes one of the slots the configured
|
package/src/relay-server.ts
CHANGED
|
@@ -1,98 +1,99 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The circuit-relay SERVER a party-run node runs — whether it runs one, and with which
|
|
3
|
-
* `@libp2p/circuit-relay-v2` init — resolved once from `NetworkConfig` for both node
|
|
4
|
-
* kinds: the control node (`cadre-node.ts` → `buildControlNodeOptions`) and every strand
|
|
5
|
-
* node (`strand-instance-manager.ts` → `buildStrandRuntime`). One function decides both
|
|
6
|
-
* answers so the two build sites cannot drift apart.
|
|
7
|
-
*
|
|
8
|
-
* WHY cadre sets an init at all. libp2p's server defaults `applyDefaultLimit` to true,
|
|
9
|
-
* which stamps every reservation with `Limit { data: 128 KiB, duration: 2 min }`; libp2p
|
|
10
|
-
* marks each connection relayed under it "limited" and resets it once either cap is
|
|
11
|
-
* reached, and db-p2p's database protocols refuse a limited connection outright (they do
|
|
12
|
-
* not set `runOnLimitedConnection`). A party-run relay exists to carry that party's own
|
|
13
|
-
* database traffic, so the cap cut off every sync and chat history forwarded through it
|
|
14
|
-
* (gotchoices/sereus#19). The dedicated relays (`ops/docker/libp2p-infra`, and the
|
|
15
|
-
* `startDedicatedRelay` test fixture that stands in for it) already turn the limit off;
|
|
16
|
-
* this is the same policy for the party-run kind.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import type { CircuitRelayServerInit, ServerReservationStoreInit } from '@libp2p/circuit-relay-v2';
|
|
20
|
-
import type { NetworkConfig
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* strands each
|
|
30
|
-
* strands each
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* The circuit-relay SERVER a party-run node runs — whether it runs one, and with which
|
|
3
|
+
* `@libp2p/circuit-relay-v2` init — resolved once from `NetworkConfig` for both node
|
|
4
|
+
* kinds: the control node (`cadre-node.ts` → `buildControlNodeOptions`) and every strand
|
|
5
|
+
* node (`strand-instance-manager.ts` → `buildStrandRuntime`). One function decides both
|
|
6
|
+
* answers so the two build sites cannot drift apart.
|
|
7
|
+
*
|
|
8
|
+
* WHY cadre sets an init at all. libp2p's server defaults `applyDefaultLimit` to true,
|
|
9
|
+
* which stamps every reservation with `Limit { data: 128 KiB, duration: 2 min }`; libp2p
|
|
10
|
+
* marks each connection relayed under it "limited" and resets it once either cap is
|
|
11
|
+
* reached, and db-p2p's database protocols refuse a limited connection outright (they do
|
|
12
|
+
* not set `runOnLimitedConnection`). A party-run relay exists to carry that party's own
|
|
13
|
+
* database traffic, so the cap cut off every sync and chat history forwarded through it
|
|
14
|
+
* (gotchoices/sereus#19). The dedicated relays (`ops/docker/libp2p-infra`, and the
|
|
15
|
+
* `startDedicatedRelay` test fixture that stands in for it) already turn the limit off;
|
|
16
|
+
* this is the same policy for the party-run kind.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import type { CircuitRelayServerInit, ServerReservationStoreInit } from '@libp2p/circuit-relay-v2';
|
|
20
|
+
import type { NetworkConfig } from './types.js';
|
|
21
|
+
import type { NodeRoles } from './node-roles.js';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Default size of a party-run relay's reservation store, raised from libp2p's 15.
|
|
25
|
+
*
|
|
26
|
+
* A NAT'd machine reserves one slot for its control node and one for each strand it
|
|
27
|
+
* serves, all on the same relay (`strand-network-config.ts` hands strand nodes the
|
|
28
|
+
* control node's `network.relayAddrs`), so the store needs
|
|
29
|
+
* `NAT'd machines × (1 + strands each)` slots. At libp2p's 15, three phones serving four
|
|
30
|
+
* strands each already fill it. 128 covers, for example, ten NAT'd machines serving eleven
|
|
31
|
+
* strands each with the unauthorized-reservation budget's 8 slots
|
|
32
|
+
* (`MAX_UNAUTHORIZED_RELAY_RESERVATIONS`) still free on top — one party's worth, where the
|
|
33
|
+
* dedicated relay's 500 is sized for many parties. A reservation costs the server a map
|
|
34
|
+
* entry and a timer, not a connection's worth of state, so the headroom is cheap.
|
|
35
|
+
*/
|
|
36
|
+
export const PARTY_RELAY_MAX_RESERVATIONS = 128;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* How long a party-run relay holds a reservation that is not refreshed: libp2p's own
|
|
40
|
+
* default (2 h), set EXPLICITLY so that cadre, not a libp2p constant it cannot import,
|
|
41
|
+
* owns the value the unauthorized-reservation budget has to agree with (see
|
|
42
|
+
* {@link ResolvedRelayServer.init}).
|
|
43
|
+
*/
|
|
44
|
+
export const PARTY_RELAY_RESERVATION_TTL_MS = 2 * 60 * 60 * 1000;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The reservation-store settings every party-run relay resolves unless the caller
|
|
48
|
+
* overrides them one key at a time through `network.relayServerInit.reservations`.
|
|
49
|
+
* `applyDefaultLimit: false` is the point of this module — see the module doc.
|
|
50
|
+
*/
|
|
51
|
+
const PARTY_RELAY_RESERVATION_DEFAULTS = {
|
|
52
|
+
applyDefaultLimit: false,
|
|
53
|
+
maxReservations: PARTY_RELAY_MAX_RESERVATIONS,
|
|
54
|
+
reservationTtl: PARTY_RELAY_RESERVATION_TTL_MS
|
|
55
|
+
} as const satisfies ServerReservationStoreInit;
|
|
56
|
+
|
|
57
|
+
/** Reservation settings with the three keys cadre always resolves made definite. */
|
|
58
|
+
export type ResolvedRelayReservations = ServerReservationStoreInit
|
|
59
|
+
& Required<Pick<ServerReservationStoreInit, keyof typeof PARTY_RELAY_RESERVATION_DEFAULTS>>;
|
|
60
|
+
|
|
61
|
+
/** What {@link resolveRelayServer} decides for one node. */
|
|
62
|
+
export interface ResolvedRelayServer {
|
|
63
|
+
/** Does this node run the relay server? Passed as db-p2p's `relay`. */
|
|
64
|
+
enabled: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* The server's init, passed as db-p2p's `relayServerInit` when {@link enabled}: the
|
|
67
|
+
* party-run defaults with the caller's `network.relayServerInit` merged over them.
|
|
68
|
+
* `reservations.reservationTtl` is always set, which is what lets the control node's
|
|
69
|
+
* unauthorized-reservation budget expire its entries on the server's own clock.
|
|
70
|
+
*/
|
|
71
|
+
init: CircuitRelayServerInit & { reservations: ResolvedRelayReservations };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Resolve the relay server for a node built from `network` with `roles`.
|
|
76
|
+
*
|
|
77
|
+
* `enabled`: an explicit `network.enableRelay` wins; otherwise an always-on node runs the
|
|
78
|
+
* server (those are the machines with the connectivity and uptime to be a relay).
|
|
79
|
+
*
|
|
80
|
+
* `init`: MERGED, not replaced. `reservations` is merged key by key over the party-run
|
|
81
|
+
* defaults, so a caller who sets only `maxReservations` does not silently get the data
|
|
82
|
+
* limit back; every other top-level key is taken from the caller as given. A key set to
|
|
83
|
+
* `undefined` counts as unset, so the default beneath it holds.
|
|
84
|
+
*/
|
|
85
|
+
export function resolveRelayServer(network: NetworkConfig | undefined, roles: NodeRoles): ResolvedRelayServer {
|
|
86
|
+
const override = network?.relayServerInit;
|
|
87
|
+
return {
|
|
88
|
+
enabled: network?.enableRelay ?? roles.alwaysOn,
|
|
89
|
+
init: {
|
|
90
|
+
...override,
|
|
91
|
+
reservations: { ...PARTY_RELAY_RESERVATION_DEFAULTS, ...definedEntries(override?.reservations) }
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** `obj` without its `undefined`-valued keys, so spreading it never erases a default. */
|
|
97
|
+
function definedEntries<T extends object>(obj: T | undefined): Partial<T> {
|
|
98
|
+
return Object.fromEntries(Object.entries(obj ?? {}).filter(([, value]) => value !== undefined)) as Partial<T>;
|
|
99
|
+
}
|
|
@@ -4,6 +4,9 @@ import type { SAppConfig } from './types.js';
|
|
|
4
4
|
|
|
5
5
|
const log = debug('sereus:cadre:schema-verify');
|
|
6
6
|
|
|
7
|
+
/** The `SAppConfig` fields the author's signature covers. */
|
|
8
|
+
export type SignedSAppFields = Pick<SAppConfig, 'schema' | 'version' | 'schemaVersion'>;
|
|
9
|
+
|
|
7
10
|
/**
|
|
8
11
|
* Error thrown when sApp schema signature verification fails.
|
|
9
12
|
*/
|
|
@@ -11,59 +14,65 @@ export class SchemaVerificationError extends Error {
|
|
|
11
14
|
constructor(
|
|
12
15
|
public readonly sAppId: string,
|
|
13
16
|
public readonly version: string,
|
|
17
|
+
schemaVersion: number,
|
|
14
18
|
reason: string
|
|
15
19
|
) {
|
|
16
|
-
super(`sApp schema verification failed for ${sAppId} v${version}: ${reason}`);
|
|
20
|
+
super(`sApp schema verification failed for ${sAppId} v${version} (schema version ${String(schemaVersion)}): ${reason}`);
|
|
17
21
|
this.name = 'SchemaVerificationError';
|
|
18
22
|
}
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
/**
|
|
22
|
-
* Compute the canonical digest of
|
|
23
|
-
* The payload is deterministic JSON
|
|
26
|
+
* Compute the canonical digest of the signed sApp fields for signing/verification.
|
|
27
|
+
* The payload is deterministic JSON, keys in this order:
|
|
28
|
+
* `{"schema":"...","schemaVersion":N,"version":"..."}`.
|
|
24
29
|
*/
|
|
25
|
-
function schemaDigest(schema
|
|
26
|
-
const payload = JSON.stringify({ schema, version });
|
|
30
|
+
function schemaDigest({ schema, schemaVersion, version }: SignedSAppFields): string {
|
|
31
|
+
const payload = JSON.stringify({ schema, schemaVersion, version });
|
|
27
32
|
return digest([payload], 'sha256', 'base64url') as string;
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
/**
|
|
31
|
-
* Sign an sApp schema with the author's ed25519
|
|
32
|
-
* Used by sApp authors when publishing their schema.
|
|
36
|
+
* Sign an sApp schema, its release version and its schema version with the author's ed25519
|
|
37
|
+
* private key. Used by sApp authors when publishing their schema.
|
|
33
38
|
*
|
|
34
|
-
* @param
|
|
35
|
-
* @param version - Schema version string
|
|
39
|
+
* @param sApp - The declarative schema DDL, the release version string and the schema version
|
|
36
40
|
* @param authorPrivateKey - Author's ed25519 private key (base64url)
|
|
37
41
|
* @returns Signature (base64url)
|
|
38
42
|
*/
|
|
39
|
-
export function signSchema(
|
|
40
|
-
|
|
41
|
-
return sign(d, authorPrivateKey, 'ed25519', 'base64url', 'base64url', 'base64url') as string;
|
|
43
|
+
export function signSchema(sApp: SignedSAppFields, authorPrivateKey: string): string {
|
|
44
|
+
return sign(schemaDigest(sApp), authorPrivateKey, 'ed25519', 'base64url', 'base64url', 'base64url') as string;
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
/**
|
|
45
48
|
* Verify an sApp schema signature against the author's ed25519 public key.
|
|
46
49
|
*
|
|
47
|
-
* @param
|
|
48
|
-
* @param version - Schema version string
|
|
50
|
+
* @param sApp - The declarative schema DDL, the release version string and the schema version
|
|
49
51
|
* @param signature - Signature to verify (base64url)
|
|
50
52
|
* @param authorPublicKey - Author's ed25519 public key (base64url)
|
|
51
53
|
* @returns true if the signature is valid
|
|
52
54
|
*/
|
|
53
|
-
export function verifySchema(
|
|
55
|
+
export function verifySchema(sApp: SignedSAppFields, signature: string, authorPublicKey: string): boolean {
|
|
54
56
|
try {
|
|
55
|
-
|
|
56
|
-
return verify(d, signature, authorPublicKey, 'ed25519', 'base64url', 'base64url', 'base64url');
|
|
57
|
+
return verify(schemaDigest(sApp), signature, authorPublicKey, 'ed25519', 'base64url', 'base64url', 'base64url');
|
|
57
58
|
} catch (error) {
|
|
58
59
|
log('Schema verification error: %o', error);
|
|
59
60
|
return false;
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
|
|
64
|
+
/** A schema version is a positive safe integer; anything else could not be compared against a strand's. */
|
|
65
|
+
function isValidSchemaVersion(schemaVersion: unknown): boolean {
|
|
66
|
+
return Number.isSafeInteger(schemaVersion) && (schemaVersion as number) >= 1;
|
|
67
|
+
}
|
|
68
|
+
|
|
63
69
|
/**
|
|
64
70
|
* Assert that an SAppConfig has a valid schema signature.
|
|
65
71
|
* Throws SchemaVerificationError on failure.
|
|
66
72
|
*
|
|
73
|
+
* A `schemaVersion` that is not a positive safe integer is refused with reason
|
|
74
|
+
* `'invalid schemaVersion'` under either policy.
|
|
75
|
+
*
|
|
67
76
|
* Fail-closed by default: when `options.requireSignature` is not explicitly
|
|
68
77
|
* `false`, an absent signature is rejected with reason `'missing signature'`,
|
|
69
78
|
* distinct from the `'invalid signature'` (tampered/wrong-key) case. The
|
|
@@ -72,28 +81,34 @@ export function verifySchema(schema: string, version: string, signature: string,
|
|
|
72
81
|
*
|
|
73
82
|
* @param sAppConfig - The sApp configuration to verify
|
|
74
83
|
* @param options - Verification policy; `requireSignature` defaults to `true`
|
|
75
|
-
* @throws SchemaVerificationError if the signature is missing (when required) or invalid
|
|
84
|
+
* @throws SchemaVerificationError if the schema version is malformed, or the signature is missing (when required) or invalid
|
|
76
85
|
*/
|
|
77
86
|
export function assertSchemaSignature(
|
|
78
87
|
sAppConfig: SAppConfig,
|
|
79
88
|
options?: { requireSignature?: boolean }
|
|
80
89
|
): void {
|
|
81
|
-
const { id, version,
|
|
90
|
+
const { id, version, schemaVersion, signature } = sAppConfig;
|
|
82
91
|
const requireSignature = options?.requireSignature ?? true;
|
|
92
|
+
const refuse = (reason: string): SchemaVerificationError =>
|
|
93
|
+
new SchemaVerificationError(id ?? '', version, schemaVersion, reason);
|
|
94
|
+
|
|
95
|
+
if (!isValidSchemaVersion(schemaVersion)) {
|
|
96
|
+
throw refuse('invalid schemaVersion');
|
|
97
|
+
}
|
|
83
98
|
|
|
84
99
|
if (!signature) {
|
|
85
100
|
if (requireSignature) {
|
|
86
|
-
throw
|
|
101
|
+
throw refuse('missing signature');
|
|
87
102
|
}
|
|
88
103
|
log('No signature provided for %s v%s — skipping verification (policy relaxed)', id, version);
|
|
89
104
|
return;
|
|
90
105
|
}
|
|
91
106
|
|
|
92
107
|
if (!id) {
|
|
93
|
-
throw
|
|
108
|
+
throw refuse('missing author public key');
|
|
94
109
|
}
|
|
95
110
|
|
|
96
|
-
if (!verifySchema(
|
|
97
|
-
throw
|
|
111
|
+
if (!verifySchema(sAppConfig, signature, id)) {
|
|
112
|
+
throw refuse('invalid signature');
|
|
98
113
|
}
|
|
99
114
|
}
|