Related-app discovery
import * as mod from "jsr:@nzip/lofi/recipes/related-app-discovery";
Opt-in presentation-only discovery for verified related applications.
discoverRelatedApplications
function
async function discoverRelatedApplications(options: DiscoverRelatedApplicationsOptions): Promise<RelatedApplicationDiscovery>
Discover installed companions and return only exact allow-list matches.
Use the result to adjust presentation such as redundant onboarding. It is intentionally unsuitable for authentication or authorization: unknown fields and versions are discarded, and errors degrade to the normal PWA experience.
isBoundedManifestString
function
function isBoundedManifestString(value: unknown): value is string
Bounded, trimmed, control-character-free manifest string field.
relatedApplicationPlatforms
const
const relatedApplicationPlatforms: ReadonlySet<string>;
The one shared related_applications grammar: manifest validation imports
these so the validator can never accept a declaration this recipe rejects.
DiscoverRelatedApplicationsOptions
type
type DiscoverRelatedApplicationsOptions = {
allow: readonly VerifiedRelatedApplication[];
client?: RelatedApplicationClient;
};
Options for matching browser results against product-owned declarations.
RelatedApplicationClient
type
type RelatedApplicationClient = {
getInstalledRelatedApps(): Promise<readonly unknown[]>;
};
Minimal browser discovery client used by the recipe.
RelatedApplicationDiscovery
type
type RelatedApplicationDiscovery = { status: "unsupported" | "none" | "failed"; installed: readonly [] } | { status: "installed"; installed: readonly VerifiedRelatedApplication[] };
Presentation-only discovery result.
VerifiedRelatedApplication
type
type VerifiedRelatedApplication = {
readonly platform: string;
readonly id?: string;
readonly url?: string;
};
A product-owned related application declaration.