npaw-plugin-nwf
Version:
NPAW's Plugin
44 lines (43 loc) • 2 kB
TypeScript
/**
* Source hierarchy used by `P2PManifestRegistry` to pick the canonical swarm
* identifier for a given piece of content. Higher-priority sources override
* lower ones. Order and raw string values are wire-compatible with Android
* and iOS (`canonical_swarm_source` field on the tracker Join payload).
*/
export declare const SwarmIdentitySource: {
readonly VIDEO_ID: "VIDEO_ID";
readonly HLS_MASTER: "HLS_MASTER";
readonly DASH_MPD: "DASH_MPD";
readonly URL_FALLBACK: "URL_FALLBACK";
};
export type SwarmIdentitySourceValue = (typeof SwarmIdentitySource)[keyof typeof SwarmIdentitySource];
/**
* Resolved identity for a content item. `canonicalId` is the swarm-grouping key
* used in `npaw-peer-group`; `source` records where it came from so the tracker
* can surface lineage in its UI; `rawResourceUrl` is kept for logs/telemetry.
*/
export type SwarmIdentity = {
canonicalId: string;
source: SwarmIdentitySourceValue;
rawResourceUrl: string;
};
/**
* Priority of a `SwarmIdentitySource`. Higher wins when the registry sees
* multiple candidate identities for the same content. Matches iOS
* `swarmIdentityPriority` and the `when` chain in Android `generateInfoHash`.
*/
export declare function swarmIdentityPriority(source: SwarmIdentitySourceValue): number;
/**
* Decision returned by `P2PManifestRegistry.observeResolvedSegment` (side-effect
* path) and `querySwarmAccess` (read-only path).
* - `allowPeerAccess`: whether the caller is allowed to request this segment
* from the peer mesh (blocked until rendition stability has been reached).
* - `announceCapture`: whether the CDN-origin capture of this segment should
* be announced to peers as ACQUIRING (early announcement). Can be `false`
* while peer access is allowed, when the min-upload bandwidth gate trips.
*/
export type SwarmAccessDecision = {
allowPeerAccess: boolean;
announceCapture: boolean;
};
export declare const DENIED_SWARM_ACCESS: SwarmAccessDecision;