UNPKG

frida-js

Version:

Pure-JS bindings to control Frida from node.js & browsers.

65 lines (64 loc) 3.47 kB
import { Readable } from 'stream'; interface FridaDownloadOptions { /** * The Frida version to download - either a version like '16.0.19' or 'latest' */ version: string; /** * The target Frida platform. Not all platforms are available, and these do not exactly match * Node'js os.platform() values. If no platform is specified, this defaults to the current platform. * * If the platform + arch combination requested is not available, an error will be raised during * the download process. */ platform?: 'android' | 'freebsd' | 'linux' | 'macos' | 'qnx' | 'windows'; /** * The target Frida architecture. Not all architecture are available, and these do not exactly match * Node'js os.arch() values. If no arch is specified, this defaults to the current architecture. * * If the platform + arch combination requested is not available, an error will be raised during * the download process. */ arch?: 'arm' | 'arm64' | 'arm64e' | 'arm64-musl' | 'armeabi' | 'x86' | 'x86_64' | 'x86_64-musl' | 'armhf' | 'mips' | 'mipsel' | 'mips64' | 'mips64el'; /** * Optionally a GitHub token can be provided. If set it will be used to download Frida, thereby * avoiding some GitHub rate limiting that can otherwise block downloads. If not set, a token * from process.env.GITHUB_TOKEN will be used if available, or the request will be sent * anonymously. */ ghToken?: string; /** * Optionally an SRI hash can be provided, which will be checked against the resulting server * binary that's streamed. If the download does not match the hash at completion, the * stream will thrown an error. This should be in the standard Subresource Integrity Hash format. * * This can only be used for fully specified download versions, as using the latest version, * or automatic arch/platform logic, can never guarantee returning the same hash every time. * To protect against this, if this is specified but any of version, platform & arch are * not, an error will be thrown. * * Note that this is the hash of the binary itself, after extraction (the same output as the * returned stream) not just the hash of the initial download. * * To get the hash for a given set of download options, pass the options to * `calculateFridaSRI({ version, arch, platform })` to fetch & calculate a current hash directly. */ sri?: string; } export declare function downloadFridaServer(options: FridaDownloadOptions): Promise<Readable>; export declare function getFridaReleaseDetails(version?: string, ghToken?: string): Promise<any>; export type CalculateSRIOptions = Pick<FridaDownloadOptions, 'ghToken'> & Required<Pick<FridaDownloadOptions, 'version' | 'arch' | 'platform'>>; /** * Calculates an SRI value for the given parameters, on a trust-on-first-download basis. * * This fetches and extracts the Frida server for the given parameters, and calculates the * SRI details for the given content. Optionally, specific preferred hash algorithms can * be provided if required. * * This returns a promise, resolving to an array of strings, one for each algorithm used. * Any of these values can be used as an SRI argument for `downloadFridaServer`. */ export declare function calculateFridaSRI(options: CalculateSRIOptions, hashOptions?: { algorithms?: string[]; }): Promise<string[]>; export {};