Skip to content

Instantly share code, notes, and snippets.

@Peeeep
Last active December 5, 2023 17:27
Show Gist options
  • Save Peeeep/c116db94316e645b63a9ea1028f1458e to your computer and use it in GitHub Desktop.
Save Peeeep/c116db94316e645b63a9ea1028f1458e to your computer and use it in GitHub Desktop.
TypeScript types for .well-known/apple-app-site-association (Universal Links)
type Component = {
/** The pattern to match with the URL path component. The default is `*`, which matches everything. */
"/"?: string;
/** The pattern or dictionary to match with the URL query component. The default is `*`, which matches everything. */
"?"?: string | Record<string, string>;
/** The pattern to match with the URL fragment component. The default is `*`, which matches everything. */
"#"?: string;
/** A Boolean value that indicates whether to stop pattern matching and prevent the universal link from opening if the URL matches the associated pattern. The default is `false`. */
exclude?: boolean;
/** Text that the system ignores. Use this to provide information about the URLs a pattern matches. */
comment?: string;
/** A Boolean value that indicates whether pattern matching is case-sensitive. The default is `true`. */
caseSensitive?: boolean;
/** A Boolean value that indicates whether URLs are percent-encoded. The default is `true`. */
percentEncoded?: boolean;
};
type Details = {
/** An array of application identifiers that specify the apps that can handle the universal links in the `components` array. */
appIDs: string[];
/** An array of components that define the universal link URLs an app can handle. */
components?: Component[];
/** A dictionary for defining the default settings to use for all universal links pattern matching in the `components` array. */
defaults?: Component;
};
export type AppleAppSiteAssociation = {
activitycontinuation?: { appIDs: string[] };
appclips?: { appIDs: string[] };
applinks?: {
/** The global pattern-matching settings to use as defaults for all universal links in the domain. */
defaults?: Component;
/** An array of `Details` objects that define the apps and the universal links they handle for the domain. */
details: Details[];
/** Custom variables to use for simplifying complex pattern matches. Each name acts as a variable that the system replaces with each string in the associated string array. */
substitutionVariables?: Record<string, string[]>;
};
webcredentials?: { appIDs: string[] };
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment