12 lines
929 B
TypeScript
12 lines
929 B
TypeScript
import type { BandwidthPeerTrustedSource } from "../../services/bandwidth-peer-observation.js"
|
|
import { assertRoutingBandwidthOriginalProvider, type createRoutingBandwidthOriginalProvider, type RoutingBandwidthOriginal } from "./routing-bandwidth-original.js"
|
|
|
|
/** Fixed production source for the v2 observer. Provider identity and its opaque
|
|
* original capability are checked at runtime; assembly cannot supply substitute
|
|
* authority/secret-reader callbacks. Every read rechecks the original first. */
|
|
export function createRoutingBandwidthPeerTrustedSource(provider: ReturnType<typeof createRoutingBandwidthOriginalProvider>, original: RoutingBandwidthOriginal): Readonly<BandwidthPeerTrustedSource> {
|
|
assertRoutingBandwidthOriginalProvider(provider)
|
|
const read = provider.readPeer.bind(provider)
|
|
return Object.freeze({ read: (peerRef, scope) => read(original, peerRef, scope) } satisfies BandwidthPeerTrustedSource)
|
|
}
|