web-ext 7.4.0 → 7.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/lib/cmd/build.js +0 -1
- package/lib/cmd/build.js.map +1 -1
- package/lib/cmd/docs.js +0 -1
- package/lib/cmd/docs.js.map +1 -1
- package/lib/cmd/index.js +0 -3
- package/lib/cmd/index.js.map +1 -1
- package/lib/cmd/lint.js +0 -1
- package/lib/cmd/lint.js.map +1 -1
- package/lib/cmd/run.js +0 -1
- package/lib/cmd/run.js.map +1 -1
- package/lib/cmd/sign.js +14 -4
- package/lib/cmd/sign.js.map +1 -1
- package/lib/config.js +0 -1
- package/lib/config.js.map +1 -1
- package/lib/errors.js +0 -1
- package/lib/errors.js.map +1 -1
- package/lib/extension-runners/base.js +0 -2
- package/lib/extension-runners/base.js.map +1 -1
- package/lib/extension-runners/chromium.js +0 -3
- package/lib/extension-runners/chromium.js.map +1 -1
- package/lib/extension-runners/firefox-android.js +0 -3
- package/lib/extension-runners/firefox-android.js.map +1 -1
- package/lib/extension-runners/firefox-desktop.js +0 -4
- package/lib/extension-runners/firefox-desktop.js.map +1 -1
- package/lib/extension-runners/index.js +0 -2
- package/lib/extension-runners/index.js.map +1 -1
- package/lib/firefox/index.js +0 -1
- package/lib/firefox/index.js.map +1 -1
- package/lib/firefox/package-identifiers.js +0 -2
- package/lib/firefox/package-identifiers.js.map +1 -1
- package/lib/firefox/preferences.js +0 -1
- package/lib/firefox/preferences.js.map +1 -1
- package/lib/firefox/rdp-client.js +0 -1
- package/lib/firefox/rdp-client.js.map +1 -1
- package/lib/firefox/remote.js +0 -1
- package/lib/firefox/remote.js.map +1 -1
- package/lib/main.js +0 -1
- package/lib/main.js.map +1 -1
- package/lib/program.js +13 -5
- package/lib/program.js.map +1 -1
- package/lib/util/adb.js +0 -1
- package/lib/util/adb.js.map +1 -1
- package/lib/util/artifacts.js +0 -1
- package/lib/util/artifacts.js.map +1 -1
- package/lib/util/desktop-notifier.js +0 -1
- package/lib/util/desktop-notifier.js.map +1 -1
- package/lib/util/file-exists.js +0 -1
- package/lib/util/file-exists.js.map +1 -1
- package/lib/util/file-filter.js +0 -1
- package/lib/util/file-filter.js.map +1 -1
- package/lib/util/is-directory.js +0 -1
- package/lib/util/is-directory.js.map +1 -1
- package/lib/util/logger.js +0 -1
- package/lib/util/logger.js.map +1 -1
- package/lib/util/manifest.js +0 -1
- package/lib/util/manifest.js.map +1 -1
- package/lib/util/promisify.js +0 -2
- package/lib/util/promisify.js.map +1 -1
- package/lib/util/stdin.js +0 -2
- package/lib/util/stdin.js.map +1 -1
- package/lib/util/submit-addon.js +12 -4
- package/lib/util/submit-addon.js.map +1 -1
- package/lib/util/temp-dir.js +0 -1
- package/lib/util/temp-dir.js.map +1 -1
- package/lib/util/updates.js +0 -1
- package/lib/util/updates.js.map +1 -1
- package/lib/watcher.js +0 -1
- package/lib/watcher.js.map +1 -1
- package/package.json +22 -22
package/lib/firefox/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["nodeFs","path","promisify","default","defaultFxRunner","FirefoxProfile","fs","fromEvent","isDirectory","isErrorWithCode","UsageError","WebExtError","getPrefs","defaultPrefGetter","getManifestId","findFreeTcpPort","defaultRemotePortFinder","createLogger","log","import","meta","url","defaultAsyncFsStat","stat","bind","defaultUserProfileCopier","copyFromUserProfile","defaultFirefoxEnv","XPCOM_DEBUG_BREAK","NS_TRACE_MALLOC_DISABLE_STACKS","run","profile","fxRunner","findRemotePort","firefoxBinary","binaryArgs","extensions","devtools","debug","remotePort","startsWith","flatpakAppId","substring","map","sourceDir","concat","results","binary","listen","foreground","env","process","verbose","firefox","args","join","on","error","info","stderr","data","toString","trim","stdout","debuggerPort","DEFAULT_PROFILES_NAMES","isDefaultProfile","profilePathOrName","ProfileFinder","Finder","fsStat","includes","baseProfileDir","locateUserDirectory","profilesIniPath","finder","readProfiles","normalizedProfileDirPath","normalize","resolve","sep","profiles","Name","Default","profileFullPath","IsRelative","Path","configureProfile","app","customPrefs","prefs","Object","keys","forEach","pref","setPreference","length","customPrefsStr","JSON","stringify","custom","updatePreferences","Promise","defaultCreateProfileFinder","userDirectoryPath","FxProfile","getPath","profileName","hasProfileName","filter","profileDef","warn","useProfile","profilePath","configureThisProfile","isFirefoxDefaultProfile","createProfileFinder","isForbiddenProfile","destinationDirectory","getProfilePath","profileIsDirPath","createProfile","copyProfile","profileDirectory","copy","copyByName","dirExists","name","installExtension","asProxy","manifestData","extensionPath","asyncFsStat","extensionsDir","mkdir","id","isDir","destPath","writeStream","createWriteStream","write","end","readStream","createReadStream","pipe","all"],"sources":["../../src/firefox/index.js"],"sourcesContent":["/* @flow */\nimport nodeFs from 'fs';\nimport path from 'path';\nimport { promisify } from 'util';\n\nimport { default as defaultFxRunner } from 'fx-runner';\nimport FirefoxProfile from 'firefox-profile';\nimport { fs } from 'mz';\nimport fromEvent from 'promise-toolbox/fromEvent';\n\nimport isDirectory from '../util/is-directory.js';\nimport { isErrorWithCode, UsageError, WebExtError } from '../errors.js';\nimport { getPrefs as defaultPrefGetter } from './preferences.js';\nimport { getManifestId } from '../util/manifest.js';\nimport { findFreeTcpPort as defaultRemotePortFinder } from './remote.js';\nimport { createLogger } from '../util/logger.js';\n// Import flow types\nimport type {\n PreferencesAppName,\n PreferencesGetterFn,\n FirefoxPreferences,\n} from './preferences';\nimport type { ExtensionManifest } from '../util/manifest.js';\nimport type { Extension } from '../extension-runners/base.js';\n\nconst log = createLogger(import.meta.url);\n\nconst defaultAsyncFsStat: typeof fs.stat = fs.stat.bind(fs);\n\nconst defaultUserProfileCopier = FirefoxProfile.copyFromUserProfile;\n\nexport const defaultFirefoxEnv = {\n XPCOM_DEBUG_BREAK: 'stack',\n NS_TRACE_MALLOC_DISABLE_STACKS: '1',\n};\n\n// defaultRemotePortFinder types and implementation.\n\nexport type RemotePortFinderFn = () => Promise<number>;\n\n// Declare the needed 'fx-runner' module flow types.\n\nexport type FirefoxRunnerParams = {|\n binary: ?string,\n profile?: string,\n 'new-instance'?: boolean,\n 'no-remote'?: boolean,\n foreground?: boolean,\n listen: number,\n 'binary-args'?: Array<string> | string,\n 'binary-args-first'?: boolean,\n env?: {\n // This match the flowtype signature for process.env (and prevent flow\n // from complaining about differences between their type signature)\n [key: string]: string | void,\n },\n verbose?: boolean,\n|};\n\nexport interface FirefoxProcess extends events$EventEmitter {\n stderr: events$EventEmitter;\n stdout: events$EventEmitter;\n kill: Function;\n}\n\nexport type FirefoxRunnerResults = {|\n process: FirefoxProcess,\n binary: string,\n args: Array<string>,\n|};\n\nexport type FirefoxRunnerFn = (\n params: FirefoxRunnerParams\n) => Promise<FirefoxRunnerResults>;\n\nexport type FirefoxInfo = {|\n firefox: FirefoxProcess,\n debuggerPort: number,\n|};\n\n// Run command types and implementaion.\n\nexport type FirefoxRunOptions = {\n fxRunner?: FirefoxRunnerFn,\n findRemotePort?: RemotePortFinderFn,\n firefoxBinary?: string,\n binaryArgs?: Array<string>,\n args?: Array<any>,\n extensions: Array<Extension>,\n devtools: boolean,\n};\n\n/*\n * Runs Firefox with the given profile object and resolves a promise on exit.\n */\nexport async function run(\n profile: FirefoxProfile,\n {\n fxRunner = defaultFxRunner,\n findRemotePort = defaultRemotePortFinder,\n firefoxBinary,\n binaryArgs,\n extensions,\n devtools,\n }: FirefoxRunOptions = {}\n): Promise<FirefoxInfo> {\n log.debug(`Running Firefox with profile at ${profile.path()}`);\n\n const remotePort = await findRemotePort();\n\n if (firefoxBinary && firefoxBinary.startsWith('flatpak:')) {\n const flatpakAppId = firefoxBinary.substring(8);\n log.debug(`Configuring Firefox with flatpak: appId=${flatpakAppId}`);\n\n // This should be resolved by the fx-runner.\n firefoxBinary = 'flatpak';\n binaryArgs = [\n 'run',\n `--filesystem=${profile.path()}`,\n ...extensions.map(({ sourceDir }) => `--filesystem=${sourceDir}:ro`),\n // We need to share the network namespace because we want to connect to\n // Firefox with the remote protocol. There is no way to tell flatpak to\n // only expose a port AFAIK.\n '--share=network',\n // Kill the entire sandbox when the launching process dies, which is what\n // we want since exiting web-ext involves `kill` and the process executed\n // here is `flatpak run`.\n '--die-with-parent',\n flatpakAppId,\n ].concat(...(binaryArgs || []));\n }\n\n const results = await fxRunner({\n // if this is falsey, fxRunner tries to find the default one.\n binary: firefoxBinary,\n 'binary-args': binaryArgs,\n // For Flatpak we need to respect the order of the command arguments because\n // we have arguments for Flapack (first) and then Firefox.\n 'binary-args-first': firefoxBinary === 'flatpak',\n // This ensures a new instance of Firefox is created. It has nothing\n // to do with the devtools remote debugger.\n 'no-remote': true,\n listen: remotePort,\n foreground: true,\n profile: profile.path(),\n env: {\n ...process.env,\n ...defaultFirefoxEnv,\n },\n verbose: true,\n });\n\n const firefox = results.process;\n\n log.debug(`Executing Firefox binary: ${results.binary}`);\n log.debug(`Firefox args: ${results.args.join(' ')}`);\n\n firefox.on('error', (error) => {\n // TODO: show a nice error when it can't find Firefox.\n // if (/No such file/.test(err) || err.code === 'ENOENT') {\n log.error(`Firefox error: ${error}`);\n throw error;\n });\n\n if (!devtools) {\n log.info('Use --verbose or --devtools to see logging');\n }\n if (devtools) {\n log.info('More info about WebExtensions debugging:');\n log.info('https://extensionworkshop.com/documentation/develop/debugging/');\n }\n\n firefox.stderr.on('data', (data) => {\n log.debug(`Firefox stderr: ${data.toString().trim()}`);\n });\n\n firefox.stdout.on('data', (data) => {\n log.debug(`Firefox stdout: ${data.toString().trim()}`);\n });\n\n firefox.on('close', () => {\n log.debug('Firefox closed');\n });\n\n return { firefox, debuggerPort: remotePort };\n}\n\n// isDefaultProfile types and implementation.\n\nconst DEFAULT_PROFILES_NAMES = ['default', 'dev-edition-default'];\n\nexport type IsDefaultProfileFn = (\n profilePathOrName: string,\n ProfileFinder?: typeof FirefoxProfile.Finder,\n fsStat?: typeof fs.stat\n) => Promise<boolean>;\n\n/*\n * Tests if a profile is a default Firefox profile (both as a profile name or\n * profile path).\n *\n * Returns a promise that resolves to true if the profile is one of default Firefox profile.\n */\nexport async function isDefaultProfile(\n profilePathOrName: string,\n ProfileFinder?: typeof FirefoxProfile.Finder = FirefoxProfile.Finder,\n fsStat?: typeof fs.stat = fs.stat\n): Promise<boolean> {\n if (DEFAULT_PROFILES_NAMES.includes(profilePathOrName)) {\n return true;\n }\n\n const baseProfileDir = ProfileFinder.locateUserDirectory();\n const profilesIniPath = path.join(baseProfileDir, 'profiles.ini');\n try {\n await fsStat(profilesIniPath);\n } catch (error) {\n if (isErrorWithCode('ENOENT', error)) {\n log.debug(`profiles.ini not found: ${error}`);\n\n // No profiles exist yet, default to false (the default profile name contains a\n // random generated component).\n return false;\n }\n\n // Re-throw any unexpected exception.\n throw error;\n }\n\n // Check for profile dir path.\n const finder = new ProfileFinder(baseProfileDir);\n const readProfiles = promisify((...args) => finder.readProfiles(...args));\n\n await readProfiles();\n\n const normalizedProfileDirPath = path.normalize(\n path.join(path.resolve(profilePathOrName), path.sep)\n );\n\n for (const profile of finder.profiles) {\n // Check if the profile dir path or name is one of the default profiles\n // defined in the profiles.ini file.\n if (\n DEFAULT_PROFILES_NAMES.includes(profile.Name) ||\n profile.Default === '1'\n ) {\n let profileFullPath;\n\n // Check for profile name.\n if (profile.Name === profilePathOrName) {\n return true;\n }\n\n // Check for profile path.\n if (profile.IsRelative === '1') {\n profileFullPath = path.join(baseProfileDir, profile.Path, path.sep);\n } else {\n profileFullPath = path.join(profile.Path, path.sep);\n }\n\n if (path.normalize(profileFullPath) === normalizedProfileDirPath) {\n return true;\n }\n }\n }\n\n // Profile directory not found.\n return false;\n}\n\n// configureProfile types and implementation.\n\nexport type ConfigureProfileOptions = {\n app?: PreferencesAppName,\n getPrefs?: PreferencesGetterFn,\n customPrefs?: FirefoxPreferences,\n};\n\nexport type ConfigureProfileFn = (\n profile: FirefoxProfile,\n options?: ConfigureProfileOptions\n) => Promise<FirefoxProfile>;\n\n/*\n * Configures a profile with common preferences that are required to\n * activate extension development.\n *\n * Returns a promise that resolves with the original profile object.\n */\nexport function configureProfile(\n profile: FirefoxProfile,\n {\n app = 'firefox',\n getPrefs = defaultPrefGetter,\n customPrefs = {},\n }: ConfigureProfileOptions = {}\n): Promise<FirefoxProfile> {\n // Set default preferences. Some of these are required for the add-on to\n // operate, such as disabling signatures.\n const prefs = getPrefs(app);\n Object.keys(prefs).forEach((pref) => {\n profile.setPreference(pref, prefs[pref]);\n });\n if (Object.keys(customPrefs).length > 0) {\n const customPrefsStr = JSON.stringify(customPrefs, null, 2);\n log.info(`Setting custom Firefox preferences: ${customPrefsStr}`);\n Object.keys(customPrefs).forEach((custom) => {\n profile.setPreference(custom, customPrefs[custom]);\n });\n }\n profile.updatePreferences();\n return Promise.resolve(profile);\n}\n\nexport type getProfileFn = (profileName: string) => Promise<string | void>;\n\nexport type CreateProfileFinderParams = {\n userDirectoryPath?: string,\n FxProfile?: typeof FirefoxProfile,\n};\n\nexport function defaultCreateProfileFinder({\n userDirectoryPath,\n FxProfile = FirefoxProfile,\n}: CreateProfileFinderParams = {}): getProfileFn {\n const finder = new FxProfile.Finder(userDirectoryPath);\n const readProfiles = promisify((...args) => finder.readProfiles(...args));\n const getPath = promisify((...args) => finder.getPath(...args));\n return async (profileName: string): Promise<string | void> => {\n try {\n await readProfiles();\n const hasProfileName =\n finder.profiles.filter((profileDef) => profileDef.Name === profileName)\n .length !== 0;\n if (hasProfileName) {\n return await getPath(profileName);\n }\n } catch (error) {\n if (!isErrorWithCode('ENOENT', error)) {\n throw error;\n }\n log.warn('Unable to find Firefox profiles.ini');\n }\n };\n}\n\n// useProfile types and implementation.\n\nexport type UseProfileParams = {\n app?: PreferencesAppName,\n configureThisProfile?: ConfigureProfileFn,\n isFirefoxDefaultProfile?: IsDefaultProfileFn,\n customPrefs?: FirefoxPreferences,\n createProfileFinder?: typeof defaultCreateProfileFinder,\n};\n\n// Use the target path as a Firefox profile without cloning it\n\nexport async function useProfile(\n profilePath: string,\n {\n app,\n configureThisProfile = configureProfile,\n isFirefoxDefaultProfile = isDefaultProfile,\n customPrefs = {},\n createProfileFinder = defaultCreateProfileFinder,\n }: UseProfileParams = {}\n): Promise<FirefoxProfile> {\n const isForbiddenProfile = await isFirefoxDefaultProfile(profilePath);\n if (isForbiddenProfile) {\n throw new UsageError(\n 'Cannot use --keep-profile-changes on a default profile' +\n ` (\"${profilePath}\")` +\n ' because web-ext will make it insecure and unsuitable for daily use.' +\n '\\nSee https://github.com/mozilla/web-ext/issues/1005'\n );\n }\n\n let destinationDirectory;\n const getProfilePath = createProfileFinder();\n\n const profileIsDirPath = await isDirectory(profilePath);\n if (profileIsDirPath) {\n log.debug(`Using profile directory \"${profilePath}\"`);\n destinationDirectory = profilePath;\n } else {\n log.debug(`Assuming ${profilePath} is a named profile`);\n destinationDirectory = await getProfilePath(profilePath);\n if (!destinationDirectory) {\n throw new UsageError(\n `The request \"${profilePath}\" profile name ` +\n 'cannot be resolved to a profile path'\n );\n }\n }\n\n const profile = new FirefoxProfile({ destinationDirectory });\n return await configureThisProfile(profile, { app, customPrefs });\n}\n\n// createProfile types and implementation.\n\nexport type CreateProfileParams = {\n app?: PreferencesAppName,\n configureThisProfile?: ConfigureProfileFn,\n customPrefs?: FirefoxPreferences,\n};\n\n/*\n * Creates a new temporary profile and resolves with the profile object.\n *\n * The profile will be deleted when the system process exits.\n */\nexport async function createProfile({\n app,\n configureThisProfile = configureProfile,\n customPrefs = {},\n}: CreateProfileParams = {}): Promise<FirefoxProfile> {\n const profile = new FirefoxProfile();\n return await configureThisProfile(profile, { app, customPrefs });\n}\n\n// copyProfile types and implementation.\n\nexport type CopyProfileOptions = {\n app?: PreferencesAppName,\n configureThisProfile?: ConfigureProfileFn,\n copyFromUserProfile?: Function,\n customPrefs?: FirefoxPreferences,\n};\n\n/*\n * Copies an existing Firefox profile and creates a new temporary profile.\n * The new profile will be configured with some preferences required to\n * activate extension development.\n *\n * It resolves with the new profile object.\n *\n * The temporary profile will be deleted when the system process exits.\n *\n * The existing profile can be specified as a directory path or a name of\n * one that exists in the current user's Firefox directory.\n */\nexport async function copyProfile(\n profileDirectory: string,\n {\n app,\n configureThisProfile = configureProfile,\n copyFromUserProfile = defaultUserProfileCopier,\n customPrefs = {},\n }: CopyProfileOptions = {}\n): Promise<FirefoxProfile> {\n const copy = promisify(FirefoxProfile.copy);\n const copyByName = promisify(copyFromUserProfile);\n\n try {\n const dirExists = await isDirectory(profileDirectory);\n\n let profile;\n\n if (dirExists) {\n log.debug(`Copying profile directory from \"${profileDirectory}\"`);\n profile = await copy({ profileDirectory });\n } else {\n log.debug(`Assuming ${profileDirectory} is a named profile`);\n profile = await copyByName({ name: profileDirectory });\n }\n\n return configureThisProfile(profile, { app, customPrefs });\n } catch (error) {\n throw new WebExtError(\n `Could not copy Firefox profile from ${profileDirectory}: ${error}`\n );\n }\n}\n\n// installExtension types and implementation.\n\nexport type InstallExtensionParams = {|\n asProxy?: boolean,\n manifestData: ExtensionManifest,\n profile: FirefoxProfile,\n extensionPath: string,\n asyncFsStat?: typeof defaultAsyncFsStat,\n|};\n\n/*\n * Installs an extension into the given Firefox profile object.\n * Resolves when complete.\n *\n * The extension is copied into a special location and you need to turn\n * on some preferences to allow this. See extensions.autoDisableScopes in\n * ./preferences.js.\n *\n * When asProxy is true, a special proxy file will be installed. This is a\n * text file that contains the path to the extension source.\n */\nexport async function installExtension({\n asProxy = false,\n manifestData,\n profile,\n extensionPath,\n asyncFsStat = defaultAsyncFsStat,\n}: InstallExtensionParams): Promise<any> {\n // This more or less follows\n // https://github.com/saadtazi/firefox-profile-js/blob/master/lib/firefox_profile.js#L531\n // (which is broken for web extensions).\n // TODO: maybe uplift a patch that supports web extensions instead?\n\n if (!profile.extensionsDir) {\n throw new WebExtError('profile.extensionsDir was unexpectedly empty');\n }\n\n try {\n await asyncFsStat(profile.extensionsDir);\n } catch (error) {\n if (isErrorWithCode('ENOENT', error)) {\n log.debug(`Creating extensions directory: ${profile.extensionsDir}`);\n await fs.mkdir(profile.extensionsDir);\n } else {\n throw error;\n }\n }\n\n const id = getManifestId(manifestData);\n if (!id) {\n throw new UsageError(\n 'An explicit extension ID is required when installing to ' +\n 'a profile (applications.gecko.id not found in manifest.json)'\n );\n }\n\n if (asProxy) {\n log.debug(`Installing as an extension proxy; source: ${extensionPath}`);\n\n const isDir = await isDirectory(extensionPath);\n if (!isDir) {\n throw new WebExtError(\n 'proxy install: extensionPath must be the extension source ' +\n `directory; got: ${extensionPath}`\n );\n }\n\n // Write a special extension proxy file containing the source\n // directory. See:\n // https://developer.mozilla.org/en-US/Add-ons/Setting_up_extension_development_environment#Firefox_extension_proxy_file\n const destPath = path.join(profile.extensionsDir, `${id}`);\n const writeStream = nodeFs.createWriteStream(destPath);\n writeStream.write(extensionPath);\n writeStream.end();\n return await fromEvent(writeStream, 'close');\n } else {\n // Write the XPI file to the profile.\n const readStream = nodeFs.createReadStream(extensionPath);\n const destPath = path.join(profile.extensionsDir, `${id}.xpi`);\n const writeStream = nodeFs.createWriteStream(destPath);\n\n log.debug(`Installing extension from ${extensionPath} to ${destPath}`);\n readStream.pipe(writeStream);\n\n return await Promise.all([\n fromEvent(readStream, 'close'),\n fromEvent(writeStream, 'close'),\n ]);\n }\n}\n"],"mappings":";AACA,OAAOA,MAAM,MAAM,IAAI;AACvB,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,SAAS,QAAQ,MAAM;AAEhC,SAASC,OAAO,IAAIC,eAAe,QAAQ,WAAW;AACtD,OAAOC,cAAc,MAAM,iBAAiB;AAC5C,SAASC,EAAE,QAAQ,IAAI;AACvB,OAAOC,SAAS,MAAM,2BAA2B;AAEjD,OAAOC,WAAW,MAAM,yBAAyB;AACjD,SAASC,eAAe,EAAEC,UAAU,EAAEC,WAAW,QAAQ,cAAc;AACvE,SAASC,QAAQ,IAAIC,iBAAiB,QAAQ,kBAAkB;AAChE,SAASC,aAAa,QAAQ,qBAAqB;AACnD,SAASC,eAAe,IAAIC,uBAAuB,QAAQ,aAAa;AACxE,SAASC,YAAY,QAAQ,mBAAmB;AACh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,IAAI7H,WAAW,CACnB,4DAA4D,GACzD,mBAAkBwH,aAAc,EAAC,CACrC;IACH;;IAEA;IACA;IACA;IACA,MAAMM,QAAQ,GAAGxI,IAAI,CAACsD,IAAI,CAACxB,OAAO,CAACsG,aAAa,EAAG,GAAEE,EAAG,EAAC,CAAC;IAC1D,MAAMG,WAAW,GAAG1I,MAAM,CAAC2I,iBAAiB,CAACF,QAAQ,CAAC;IACtDC,WAAW,CAACE,KAAK,CAACT,aAAa,CAAC;IAChCO,WAAW,CAACG,GAAG,EAAE;IACjB,OAAO,MAAMtI,SAAS,CAACmI,WAAW,EAAE,OAAO,CAAC;EAC9C,CAAC,MAAM;IACL;IACA,MAAMI,UAAU,GAAG9I,MAAM,CAAC+I,gBAAgB,CAACZ,aAAa,CAAC;IACzD,MAAMM,QAAQ,GAAGxI,IAAI,CAACsD,IAAI,CAACxB,OAAO,CAACsG,aAAa,EAAG,GAAEE,EAAG,MAAK,CAAC;IAC9D,MAAMG,WAAW,GAAG1I,MAAM,CAAC2I,iBAAiB,CAACF,QAAQ,CAAC;IAEtDvH,GAAG,CAACoB,KAAK,CAAE,6BAA4B6F,aAAc,OAAMM,QAAS,EAAC,CAAC;IACtEK,UAAU,CAACE,IAAI,CAACN,WAAW,CAAC;IAE5B,OAAO,MAAMpC,OAAO,CAAC2C,GAAG,CAAC,CACvB1I,SAAS,CAACuI,UAAU,EAAE,OAAO,CAAC,EAC9BvI,SAAS,CAACmI,WAAW,EAAE,OAAO,CAAC,CAChC,CAAC;EACJ;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["nodeFs","path","promisify","default","defaultFxRunner","FirefoxProfile","fs","fromEvent","isDirectory","isErrorWithCode","UsageError","WebExtError","getPrefs","defaultPrefGetter","getManifestId","findFreeTcpPort","defaultRemotePortFinder","createLogger","log","import","meta","url","defaultAsyncFsStat","stat","bind","defaultUserProfileCopier","copyFromUserProfile","defaultFirefoxEnv","XPCOM_DEBUG_BREAK","NS_TRACE_MALLOC_DISABLE_STACKS","run","profile","fxRunner","findRemotePort","firefoxBinary","binaryArgs","extensions","devtools","debug","remotePort","startsWith","flatpakAppId","substring","map","sourceDir","concat","results","binary","listen","foreground","env","process","verbose","firefox","args","join","on","error","info","stderr","data","toString","trim","stdout","debuggerPort","DEFAULT_PROFILES_NAMES","isDefaultProfile","profilePathOrName","ProfileFinder","Finder","fsStat","includes","baseProfileDir","locateUserDirectory","profilesIniPath","finder","readProfiles","normalizedProfileDirPath","normalize","resolve","sep","profiles","Name","Default","profileFullPath","IsRelative","Path","configureProfile","app","customPrefs","prefs","Object","keys","forEach","pref","setPreference","length","customPrefsStr","JSON","stringify","custom","updatePreferences","Promise","defaultCreateProfileFinder","userDirectoryPath","FxProfile","getPath","profileName","hasProfileName","filter","profileDef","warn","useProfile","profilePath","configureThisProfile","isFirefoxDefaultProfile","createProfileFinder","isForbiddenProfile","destinationDirectory","getProfilePath","profileIsDirPath","createProfile","copyProfile","profileDirectory","copy","copyByName","dirExists","name","installExtension","asProxy","manifestData","extensionPath","asyncFsStat","extensionsDir","mkdir","id","isDir","destPath","writeStream","createWriteStream","write","end","readStream","createReadStream","pipe","all"],"sources":["../../src/firefox/index.js"],"sourcesContent":["/* @flow */\nimport nodeFs from 'fs';\nimport path from 'path';\nimport { promisify } from 'util';\n\nimport { default as defaultFxRunner } from 'fx-runner';\nimport FirefoxProfile from 'firefox-profile';\nimport { fs } from 'mz';\nimport fromEvent from 'promise-toolbox/fromEvent';\n\nimport isDirectory from '../util/is-directory.js';\nimport { isErrorWithCode, UsageError, WebExtError } from '../errors.js';\nimport { getPrefs as defaultPrefGetter } from './preferences.js';\nimport { getManifestId } from '../util/manifest.js';\nimport { findFreeTcpPort as defaultRemotePortFinder } from './remote.js';\nimport { createLogger } from '../util/logger.js';\n// Import flow types\nimport type {\n PreferencesAppName,\n PreferencesGetterFn,\n FirefoxPreferences,\n} from './preferences';\nimport type { ExtensionManifest } from '../util/manifest.js';\nimport type { Extension } from '../extension-runners/base.js';\n\nconst log = createLogger(import.meta.url);\n\nconst defaultAsyncFsStat: typeof fs.stat = fs.stat.bind(fs);\n\nconst defaultUserProfileCopier = FirefoxProfile.copyFromUserProfile;\n\nexport const defaultFirefoxEnv = {\n XPCOM_DEBUG_BREAK: 'stack',\n NS_TRACE_MALLOC_DISABLE_STACKS: '1',\n};\n\n// defaultRemotePortFinder types and implementation.\n\nexport type RemotePortFinderFn = () => Promise<number>;\n\n// Declare the needed 'fx-runner' module flow types.\n\nexport type FirefoxRunnerParams = {|\n binary: ?string,\n profile?: string,\n 'new-instance'?: boolean,\n 'no-remote'?: boolean,\n foreground?: boolean,\n listen: number,\n 'binary-args'?: Array<string> | string,\n 'binary-args-first'?: boolean,\n env?: {\n // This match the flowtype signature for process.env (and prevent flow\n // from complaining about differences between their type signature)\n [key: string]: string | void,\n },\n verbose?: boolean,\n|};\n\nexport interface FirefoxProcess extends events$EventEmitter {\n stderr: events$EventEmitter;\n stdout: events$EventEmitter;\n kill: Function;\n}\n\nexport type FirefoxRunnerResults = {|\n process: FirefoxProcess,\n binary: string,\n args: Array<string>,\n|};\n\nexport type FirefoxRunnerFn = (\n params: FirefoxRunnerParams\n) => Promise<FirefoxRunnerResults>;\n\nexport type FirefoxInfo = {|\n firefox: FirefoxProcess,\n debuggerPort: number,\n|};\n\n// Run command types and implementaion.\n\nexport type FirefoxRunOptions = {\n fxRunner?: FirefoxRunnerFn,\n findRemotePort?: RemotePortFinderFn,\n firefoxBinary?: string,\n binaryArgs?: Array<string>,\n args?: Array<any>,\n extensions: Array<Extension>,\n devtools: boolean,\n};\n\n/*\n * Runs Firefox with the given profile object and resolves a promise on exit.\n */\nexport async function run(\n profile: FirefoxProfile,\n {\n fxRunner = defaultFxRunner,\n findRemotePort = defaultRemotePortFinder,\n firefoxBinary,\n binaryArgs,\n extensions,\n devtools,\n }: FirefoxRunOptions = {}\n): Promise<FirefoxInfo> {\n log.debug(`Running Firefox with profile at ${profile.path()}`);\n\n const remotePort = await findRemotePort();\n\n if (firefoxBinary && firefoxBinary.startsWith('flatpak:')) {\n const flatpakAppId = firefoxBinary.substring(8);\n log.debug(`Configuring Firefox with flatpak: appId=${flatpakAppId}`);\n\n // This should be resolved by the fx-runner.\n firefoxBinary = 'flatpak';\n binaryArgs = [\n 'run',\n `--filesystem=${profile.path()}`,\n ...extensions.map(({ sourceDir }) => `--filesystem=${sourceDir}:ro`),\n // We need to share the network namespace because we want to connect to\n // Firefox with the remote protocol. There is no way to tell flatpak to\n // only expose a port AFAIK.\n '--share=network',\n // Kill the entire sandbox when the launching process dies, which is what\n // we want since exiting web-ext involves `kill` and the process executed\n // here is `flatpak run`.\n '--die-with-parent',\n flatpakAppId,\n ].concat(...(binaryArgs || []));\n }\n\n const results = await fxRunner({\n // if this is falsey, fxRunner tries to find the default one.\n binary: firefoxBinary,\n 'binary-args': binaryArgs,\n // For Flatpak we need to respect the order of the command arguments because\n // we have arguments for Flapack (first) and then Firefox.\n 'binary-args-first': firefoxBinary === 'flatpak',\n // This ensures a new instance of Firefox is created. It has nothing\n // to do with the devtools remote debugger.\n 'no-remote': true,\n listen: remotePort,\n foreground: true,\n profile: profile.path(),\n env: {\n ...process.env,\n ...defaultFirefoxEnv,\n },\n verbose: true,\n });\n\n const firefox = results.process;\n\n log.debug(`Executing Firefox binary: ${results.binary}`);\n log.debug(`Firefox args: ${results.args.join(' ')}`);\n\n firefox.on('error', (error) => {\n // TODO: show a nice error when it can't find Firefox.\n // if (/No such file/.test(err) || err.code === 'ENOENT') {\n log.error(`Firefox error: ${error}`);\n throw error;\n });\n\n if (!devtools) {\n log.info('Use --verbose or --devtools to see logging');\n }\n if (devtools) {\n log.info('More info about WebExtensions debugging:');\n log.info('https://extensionworkshop.com/documentation/develop/debugging/');\n }\n\n firefox.stderr.on('data', (data) => {\n log.debug(`Firefox stderr: ${data.toString().trim()}`);\n });\n\n firefox.stdout.on('data', (data) => {\n log.debug(`Firefox stdout: ${data.toString().trim()}`);\n });\n\n firefox.on('close', () => {\n log.debug('Firefox closed');\n });\n\n return { firefox, debuggerPort: remotePort };\n}\n\n// isDefaultProfile types and implementation.\n\nconst DEFAULT_PROFILES_NAMES = ['default', 'dev-edition-default'];\n\nexport type IsDefaultProfileFn = (\n profilePathOrName: string,\n ProfileFinder?: typeof FirefoxProfile.Finder,\n fsStat?: typeof fs.stat\n) => Promise<boolean>;\n\n/*\n * Tests if a profile is a default Firefox profile (both as a profile name or\n * profile path).\n *\n * Returns a promise that resolves to true if the profile is one of default Firefox profile.\n */\nexport async function isDefaultProfile(\n profilePathOrName: string,\n ProfileFinder?: typeof FirefoxProfile.Finder = FirefoxProfile.Finder,\n fsStat?: typeof fs.stat = fs.stat\n): Promise<boolean> {\n if (DEFAULT_PROFILES_NAMES.includes(profilePathOrName)) {\n return true;\n }\n\n const baseProfileDir = ProfileFinder.locateUserDirectory();\n const profilesIniPath = path.join(baseProfileDir, 'profiles.ini');\n try {\n await fsStat(profilesIniPath);\n } catch (error) {\n if (isErrorWithCode('ENOENT', error)) {\n log.debug(`profiles.ini not found: ${error}`);\n\n // No profiles exist yet, default to false (the default profile name contains a\n // random generated component).\n return false;\n }\n\n // Re-throw any unexpected exception.\n throw error;\n }\n\n // Check for profile dir path.\n const finder = new ProfileFinder(baseProfileDir);\n const readProfiles = promisify((...args) => finder.readProfiles(...args));\n\n await readProfiles();\n\n const normalizedProfileDirPath = path.normalize(\n path.join(path.resolve(profilePathOrName), path.sep)\n );\n\n for (const profile of finder.profiles) {\n // Check if the profile dir path or name is one of the default profiles\n // defined in the profiles.ini file.\n if (\n DEFAULT_PROFILES_NAMES.includes(profile.Name) ||\n profile.Default === '1'\n ) {\n let profileFullPath;\n\n // Check for profile name.\n if (profile.Name === profilePathOrName) {\n return true;\n }\n\n // Check for profile path.\n if (profile.IsRelative === '1') {\n profileFullPath = path.join(baseProfileDir, profile.Path, path.sep);\n } else {\n profileFullPath = path.join(profile.Path, path.sep);\n }\n\n if (path.normalize(profileFullPath) === normalizedProfileDirPath) {\n return true;\n }\n }\n }\n\n // Profile directory not found.\n return false;\n}\n\n// configureProfile types and implementation.\n\nexport type ConfigureProfileOptions = {\n app?: PreferencesAppName,\n getPrefs?: PreferencesGetterFn,\n customPrefs?: FirefoxPreferences,\n};\n\nexport type ConfigureProfileFn = (\n profile: FirefoxProfile,\n options?: ConfigureProfileOptions\n) => Promise<FirefoxProfile>;\n\n/*\n * Configures a profile with common preferences that are required to\n * activate extension development.\n *\n * Returns a promise that resolves with the original profile object.\n */\nexport function configureProfile(\n profile: FirefoxProfile,\n {\n app = 'firefox',\n getPrefs = defaultPrefGetter,\n customPrefs = {},\n }: ConfigureProfileOptions = {}\n): Promise<FirefoxProfile> {\n // Set default preferences. Some of these are required for the add-on to\n // operate, such as disabling signatures.\n const prefs = getPrefs(app);\n Object.keys(prefs).forEach((pref) => {\n profile.setPreference(pref, prefs[pref]);\n });\n if (Object.keys(customPrefs).length > 0) {\n const customPrefsStr = JSON.stringify(customPrefs, null, 2);\n log.info(`Setting custom Firefox preferences: ${customPrefsStr}`);\n Object.keys(customPrefs).forEach((custom) => {\n profile.setPreference(custom, customPrefs[custom]);\n });\n }\n profile.updatePreferences();\n return Promise.resolve(profile);\n}\n\nexport type getProfileFn = (profileName: string) => Promise<string | void>;\n\nexport type CreateProfileFinderParams = {\n userDirectoryPath?: string,\n FxProfile?: typeof FirefoxProfile,\n};\n\nexport function defaultCreateProfileFinder({\n userDirectoryPath,\n FxProfile = FirefoxProfile,\n}: CreateProfileFinderParams = {}): getProfileFn {\n const finder = new FxProfile.Finder(userDirectoryPath);\n const readProfiles = promisify((...args) => finder.readProfiles(...args));\n const getPath = promisify((...args) => finder.getPath(...args));\n return async (profileName: string): Promise<string | void> => {\n try {\n await readProfiles();\n const hasProfileName =\n finder.profiles.filter((profileDef) => profileDef.Name === profileName)\n .length !== 0;\n if (hasProfileName) {\n return await getPath(profileName);\n }\n } catch (error) {\n if (!isErrorWithCode('ENOENT', error)) {\n throw error;\n }\n log.warn('Unable to find Firefox profiles.ini');\n }\n };\n}\n\n// useProfile types and implementation.\n\nexport type UseProfileParams = {\n app?: PreferencesAppName,\n configureThisProfile?: ConfigureProfileFn,\n isFirefoxDefaultProfile?: IsDefaultProfileFn,\n customPrefs?: FirefoxPreferences,\n createProfileFinder?: typeof defaultCreateProfileFinder,\n};\n\n// Use the target path as a Firefox profile without cloning it\n\nexport async function useProfile(\n profilePath: string,\n {\n app,\n configureThisProfile = configureProfile,\n isFirefoxDefaultProfile = isDefaultProfile,\n customPrefs = {},\n createProfileFinder = defaultCreateProfileFinder,\n }: UseProfileParams = {}\n): Promise<FirefoxProfile> {\n const isForbiddenProfile = await isFirefoxDefaultProfile(profilePath);\n if (isForbiddenProfile) {\n throw new UsageError(\n 'Cannot use --keep-profile-changes on a default profile' +\n ` (\"${profilePath}\")` +\n ' because web-ext will make it insecure and unsuitable for daily use.' +\n '\\nSee https://github.com/mozilla/web-ext/issues/1005'\n );\n }\n\n let destinationDirectory;\n const getProfilePath = createProfileFinder();\n\n const profileIsDirPath = await isDirectory(profilePath);\n if (profileIsDirPath) {\n log.debug(`Using profile directory \"${profilePath}\"`);\n destinationDirectory = profilePath;\n } else {\n log.debug(`Assuming ${profilePath} is a named profile`);\n destinationDirectory = await getProfilePath(profilePath);\n if (!destinationDirectory) {\n throw new UsageError(\n `The request \"${profilePath}\" profile name ` +\n 'cannot be resolved to a profile path'\n );\n }\n }\n\n const profile = new FirefoxProfile({ destinationDirectory });\n return await configureThisProfile(profile, { app, customPrefs });\n}\n\n// createProfile types and implementation.\n\nexport type CreateProfileParams = {\n app?: PreferencesAppName,\n configureThisProfile?: ConfigureProfileFn,\n customPrefs?: FirefoxPreferences,\n};\n\n/*\n * Creates a new temporary profile and resolves with the profile object.\n *\n * The profile will be deleted when the system process exits.\n */\nexport async function createProfile({\n app,\n configureThisProfile = configureProfile,\n customPrefs = {},\n}: CreateProfileParams = {}): Promise<FirefoxProfile> {\n const profile = new FirefoxProfile();\n return await configureThisProfile(profile, { app, customPrefs });\n}\n\n// copyProfile types and implementation.\n\nexport type CopyProfileOptions = {\n app?: PreferencesAppName,\n configureThisProfile?: ConfigureProfileFn,\n copyFromUserProfile?: Function,\n customPrefs?: FirefoxPreferences,\n};\n\n/*\n * Copies an existing Firefox profile and creates a new temporary profile.\n * The new profile will be configured with some preferences required to\n * activate extension development.\n *\n * It resolves with the new profile object.\n *\n * The temporary profile will be deleted when the system process exits.\n *\n * The existing profile can be specified as a directory path or a name of\n * one that exists in the current user's Firefox directory.\n */\nexport async function copyProfile(\n profileDirectory: string,\n {\n app,\n configureThisProfile = configureProfile,\n copyFromUserProfile = defaultUserProfileCopier,\n customPrefs = {},\n }: CopyProfileOptions = {}\n): Promise<FirefoxProfile> {\n const copy = promisify(FirefoxProfile.copy);\n const copyByName = promisify(copyFromUserProfile);\n\n try {\n const dirExists = await isDirectory(profileDirectory);\n\n let profile;\n\n if (dirExists) {\n log.debug(`Copying profile directory from \"${profileDirectory}\"`);\n profile = await copy({ profileDirectory });\n } else {\n log.debug(`Assuming ${profileDirectory} is a named profile`);\n profile = await copyByName({ name: profileDirectory });\n }\n\n return configureThisProfile(profile, { app, customPrefs });\n } catch (error) {\n throw new WebExtError(\n `Could not copy Firefox profile from ${profileDirectory}: ${error}`\n );\n }\n}\n\n// installExtension types and implementation.\n\nexport type InstallExtensionParams = {|\n asProxy?: boolean,\n manifestData: ExtensionManifest,\n profile: FirefoxProfile,\n extensionPath: string,\n asyncFsStat?: typeof defaultAsyncFsStat,\n|};\n\n/*\n * Installs an extension into the given Firefox profile object.\n * Resolves when complete.\n *\n * The extension is copied into a special location and you need to turn\n * on some preferences to allow this. See extensions.autoDisableScopes in\n * ./preferences.js.\n *\n * When asProxy is true, a special proxy file will be installed. This is a\n * text file that contains the path to the extension source.\n */\nexport async function installExtension({\n asProxy = false,\n manifestData,\n profile,\n extensionPath,\n asyncFsStat = defaultAsyncFsStat,\n}: InstallExtensionParams): Promise<any> {\n // This more or less follows\n // https://github.com/saadtazi/firefox-profile-js/blob/master/lib/firefox_profile.js#L531\n // (which is broken for web extensions).\n // TODO: maybe uplift a patch that supports web extensions instead?\n\n if (!profile.extensionsDir) {\n throw new WebExtError('profile.extensionsDir was unexpectedly empty');\n }\n\n try {\n await asyncFsStat(profile.extensionsDir);\n } catch (error) {\n if (isErrorWithCode('ENOENT', error)) {\n log.debug(`Creating extensions directory: ${profile.extensionsDir}`);\n await fs.mkdir(profile.extensionsDir);\n } else {\n throw error;\n }\n }\n\n const id = getManifestId(manifestData);\n if (!id) {\n throw new UsageError(\n 'An explicit extension ID is required when installing to ' +\n 'a profile (applications.gecko.id not found in manifest.json)'\n );\n }\n\n if (asProxy) {\n log.debug(`Installing as an extension proxy; source: ${extensionPath}`);\n\n const isDir = await isDirectory(extensionPath);\n if (!isDir) {\n throw new WebExtError(\n 'proxy install: extensionPath must be the extension source ' +\n `directory; got: ${extensionPath}`\n );\n }\n\n // Write a special extension proxy file containing the source\n // directory. See:\n // https://developer.mozilla.org/en-US/Add-ons/Setting_up_extension_development_environment#Firefox_extension_proxy_file\n const destPath = path.join(profile.extensionsDir, `${id}`);\n const writeStream = nodeFs.createWriteStream(destPath);\n writeStream.write(extensionPath);\n writeStream.end();\n return await fromEvent(writeStream, 'close');\n } else {\n // Write the XPI file to the profile.\n const readStream = nodeFs.createReadStream(extensionPath);\n const destPath = path.join(profile.extensionsDir, `${id}.xpi`);\n const writeStream = nodeFs.createWriteStream(destPath);\n\n log.debug(`Installing extension from ${extensionPath} to ${destPath}`);\n readStream.pipe(writeStream);\n\n return await Promise.all([\n fromEvent(readStream, 'close'),\n fromEvent(writeStream, 'close'),\n ]);\n }\n}\n"],"mappings":"AACA,OAAOA,MAAM,MAAM,IAAI;AACvB,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,SAAS,QAAQ,MAAM;AAEhC,SAASC,OAAO,IAAIC,eAAe,QAAQ,WAAW;AACtD,OAAOC,cAAc,MAAM,iBAAiB;AAC5C,SAASC,EAAE,QAAQ,IAA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CAChC,CAAC;EACJ;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-identifiers.js","names":["defaultApkComponents"],"sources":["../../src/firefox/package-identifiers.js"],"sourcesContent":["/* @flow */\n\nexport default [\n 'org.mozilla.fennec',\n 'org.mozilla.fenix',\n 'org.mozilla.geckoview_example',\n 'org.mozilla.geckoview',\n 'org.mozilla.firefox',\n 'org.mozilla.reference.browser',\n];\n\nexport const defaultApkComponents = {\n 'org.mozilla.reference.browser': '.BrowserActivity',\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"package-identifiers.js","names":["defaultApkComponents"],"sources":["../../src/firefox/package-identifiers.js"],"sourcesContent":["/* @flow */\n\nexport default [\n 'org.mozilla.fennec',\n 'org.mozilla.fenix',\n 'org.mozilla.geckoview_example',\n 'org.mozilla.geckoview',\n 'org.mozilla.firefox',\n 'org.mozilla.reference.browser',\n];\n\nexport const defaultApkComponents = {\n 'org.mozilla.reference.browser': '.BrowserActivity',\n};\n"],"mappings":"AAEA,eAAe,CACb,oBAAoB,EACpB,mBAAmB,EACnB,+BAA+B,EAC/B,uBAAuB,EACvB,qBAAqB,EACrB,+BAA+B,CAChC;AAED,OAAO,MAAMA,oBAAoB,GAAG;EAClC,+BAA+B,EAAE;AACnC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preferences.js","names":["WebExtError","UsageError","createLogger","log","import","meta","url","nonOverridablePreferences","prefsCommon","prefsFennec","prefsFirefox","prefs","common","fennec","firefox","getPrefs","app","appPrefs","coerceCLICustomPreference","cliPrefs","customPrefs","pref","prefsAry","split","length","key","value","slice","join","test","parseInt","includes","warn"],"sources":["../../src/firefox/preferences.js"],"sourcesContent":["/* @flow */\nimport { WebExtError, UsageError } from '../errors.js';\nimport { createLogger } from '../util/logger.js';\n\nconst log = createLogger(import.meta.url);\n\nexport const nonOverridablePreferences = [\n 'devtools.debugger.remote-enabled',\n 'devtools.debugger.prompt-connection',\n 'xpinstall.signatures.required',\n];\n\n// Flow Types\n\nexport type FirefoxPreferences = {\n [key: string]: boolean | string | number,\n};\n\nexport type PreferencesAppName = 'firefox' | 'fennec';\n\n// Preferences Maps\n\nconst prefsCommon: FirefoxPreferences = {\n // Allow debug output via dump to be printed to the system console\n 'browser.dom.window.dump.enabled': true,\n\n // From:\n // https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/internals/preferences.html#data-choices-notification\n // This is the data submission master kill switch. If disabled, no policy is shown or upload takes place, ever.\n 'datareporting.policy.dataSubmissionEnabled': false,\n\n // Allow remote connections to the debugger.\n 'devtools.debugger.remote-enabled': true,\n // Disable the prompt for allowing connections.\n 'devtools.debugger.prompt-connection': false,\n // Allow extensions to log messages on browser's console.\n 'devtools.browserconsole.contentMessages': true,\n\n // Turn off platform logging because it is a lot of info.\n 'extensions.logging.enabled': false,\n\n // Disable extension updates and notifications.\n 'extensions.checkCompatibility.nightly': false,\n 'extensions.update.enabled': false,\n 'extensions.update.notifyUser': false,\n\n // From:\n // http://hg.mozilla.org/mozilla-central/file/1dd81c324ac7/build/automation.py.in//l372\n // Only load extensions from the application and user profile.\n // AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_APPLICATION\n 'extensions.enabledScopes': 5,\n // Disable metadata caching for installed add-ons by default.\n 'extensions.getAddons.cache.enabled': false,\n // Disable intalling any distribution add-ons.\n 'extensions.installDistroAddons': false,\n // Allow installing extensions dropped into the profile folder.\n 'extensions.autoDisableScopes': 10,\n\n // Disable app update.\n 'app.update.enabled': false,\n\n // Allow unsigned add-ons.\n 'xpinstall.signatures.required': false,\n\n // browser.link.open_newwindow is changed from 3 to 2 in:\n // https://github.com/saadtazi/firefox-profile-js/blob/cafc793d940a779d280103ae17d02a92de862efc/lib/firefox_profile.js#L32\n // Restore original value to avoid https://github.com/mozilla/web-ext/issues/1592\n 'browser.link.open_newwindow': 3,\n};\n\n// Prefs specific to Firefox for Android.\nconst prefsFennec: FirefoxPreferences = {\n 'browser.console.showInPanel': true,\n 'browser.firstrun.show.uidiscovery': false,\n 'devtools.remote.usb.enabled': true,\n};\n\n// Prefs specific to Firefox for desktop.\nconst prefsFirefox: FirefoxPreferences = {\n 'browser.startup.homepage': 'about:blank',\n 'startup.homepage_welcome_url': 'about:blank',\n 'startup.homepage_welcome_url.additional': '',\n 'devtools.errorconsole.enabled': true,\n 'devtools.chrome.enabled': true,\n\n // From:\n // http://hg.mozilla.org/mozilla-central/file/1dd81c324ac7/build/automation.py.in//l388\n // Make url-classifier updates so rare that they won't affect tests.\n 'urlclassifier.updateinterval': 172800,\n // Point the url-classifier to a nonexistent local URL for fast failures.\n 'browser.safebrowsing.provider.0.gethashURL':\n 'http://localhost/safebrowsing-dummy/gethash',\n 'browser.safebrowsing.provider.0.keyURL':\n 'http://localhost/safebrowsing-dummy/newkey',\n 'browser.safebrowsing.provider.0.updateURL':\n 'http://localhost/safebrowsing-dummy/update',\n\n // Disable self repair/SHIELD\n 'browser.selfsupport.url': 'https://localhost/selfrepair',\n // Disable Reader Mode UI tour\n 'browser.reader.detectedFirstArticle': true,\n\n // Set the policy firstURL to an empty string to prevent\n // the privacy info page to be opened on every \"web-ext run\".\n // (See #1114 for rationale)\n 'datareporting.policy.firstRunURL': '',\n};\n\nconst prefs = {\n common: prefsCommon,\n fennec: prefsFennec,\n firefox: prefsFirefox,\n};\n\n// Module exports\n\nexport type PreferencesGetterFn = (\n appName: PreferencesAppName\n) => FirefoxPreferences;\n\nexport function getPrefs(\n app: PreferencesAppName = 'firefox'\n): FirefoxPreferences {\n const appPrefs = prefs[app];\n if (!appPrefs) {\n throw new WebExtError(`Unsupported application: ${app}`);\n }\n return {\n ...prefsCommon,\n ...appPrefs,\n };\n}\n\nexport function coerceCLICustomPreference(\n cliPrefs: Array<string>\n): FirefoxPreferences {\n const customPrefs = {};\n\n for (const pref of cliPrefs) {\n const prefsAry = pref.split('=');\n\n if (prefsAry.length < 2) {\n throw new UsageError(\n `Incomplete custom preference: \"${pref}\". ` +\n 'Syntax expected: \"prefname=prefvalue\".'\n );\n }\n\n const key = prefsAry[0];\n let value = prefsAry.slice(1).join('=');\n\n if (/[^\\w{@}.-]/.test(key)) {\n throw new UsageError(`Invalid custom preference name: ${key}`);\n }\n\n if (value === `${parseInt(value)}`) {\n value = parseInt(value, 10);\n } else if (value === 'true' || value === 'false') {\n value = value === 'true';\n }\n\n if (nonOverridablePreferences.includes(key)) {\n log.warn(`'${key}' preference cannot be customized.`);\n continue;\n }\n customPrefs[`${key}`] = value;\n }\n\n return customPrefs;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"preferences.js","names":["WebExtError","UsageError","createLogger","log","import","meta","url","nonOverridablePreferences","prefsCommon","prefsFennec","prefsFirefox","prefs","common","fennec","firefox","getPrefs","app","appPrefs","coerceCLICustomPreference","cliPrefs","customPrefs","pref","prefsAry","split","length","key","value","slice","join","test","parseInt","includes","warn"],"sources":["../../src/firefox/preferences.js"],"sourcesContent":["/* @flow */\nimport { WebExtError, UsageError } from '../errors.js';\nimport { createLogger } from '../util/logger.js';\n\nconst log = createLogger(import.meta.url);\n\nexport const nonOverridablePreferences = [\n 'devtools.debugger.remote-enabled',\n 'devtools.debugger.prompt-connection',\n 'xpinstall.signatures.required',\n];\n\n// Flow Types\n\nexport type FirefoxPreferences = {\n [key: string]: boolean | string | number,\n};\n\nexport type PreferencesAppName = 'firefox' | 'fennec';\n\n// Preferences Maps\n\nconst prefsCommon: FirefoxPreferences = {\n // Allow debug output via dump to be printed to the system console\n 'browser.dom.window.dump.enabled': true,\n\n // From:\n // https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/internals/preferences.html#data-choices-notification\n // This is the data submission master kill switch. If disabled, no policy is shown or upload takes place, ever.\n 'datareporting.policy.dataSubmissionEnabled': false,\n\n // Allow remote connections to the debugger.\n 'devtools.debugger.remote-enabled': true,\n // Disable the prompt for allowing connections.\n 'devtools.debugger.prompt-connection': false,\n // Allow extensions to log messages on browser's console.\n 'devtools.browserconsole.contentMessages': true,\n\n // Turn off platform logging because it is a lot of info.\n 'extensions.logging.enabled': false,\n\n // Disable extension updates and notifications.\n 'extensions.checkCompatibility.nightly': false,\n 'extensions.update.enabled': false,\n 'extensions.update.notifyUser': false,\n\n // From:\n // http://hg.mozilla.org/mozilla-central/file/1dd81c324ac7/build/automation.py.in//l372\n // Only load extensions from the application and user profile.\n // AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_APPLICATION\n 'extensions.enabledScopes': 5,\n // Disable metadata caching for installed add-ons by default.\n 'extensions.getAddons.cache.enabled': false,\n // Disable intalling any distribution add-ons.\n 'extensions.installDistroAddons': false,\n // Allow installing extensions dropped into the profile folder.\n 'extensions.autoDisableScopes': 10,\n\n // Disable app update.\n 'app.update.enabled': false,\n\n // Allow unsigned add-ons.\n 'xpinstall.signatures.required': false,\n\n // browser.link.open_newwindow is changed from 3 to 2 in:\n // https://github.com/saadtazi/firefox-profile-js/blob/cafc793d940a779d280103ae17d02a92de862efc/lib/firefox_profile.js#L32\n // Restore original value to avoid https://github.com/mozilla/web-ext/issues/1592\n 'browser.link.open_newwindow': 3,\n};\n\n// Prefs specific to Firefox for Android.\nconst prefsFennec: FirefoxPreferences = {\n 'browser.console.showInPanel': true,\n 'browser.firstrun.show.uidiscovery': false,\n 'devtools.remote.usb.enabled': true,\n};\n\n// Prefs specific to Firefox for desktop.\nconst prefsFirefox: FirefoxPreferences = {\n 'browser.startup.homepage': 'about:blank',\n 'startup.homepage_welcome_url': 'about:blank',\n 'startup.homepage_welcome_url.additional': '',\n 'devtools.errorconsole.enabled': true,\n 'devtools.chrome.enabled': true,\n\n // From:\n // http://hg.mozilla.org/mozilla-central/file/1dd81c324ac7/build/automation.py.in//l388\n // Make url-classifier updates so rare that they won't affect tests.\n 'urlclassifier.updateinterval': 172800,\n // Point the url-classifier to a nonexistent local URL for fast failures.\n 'browser.safebrowsing.provider.0.gethashURL':\n 'http://localhost/safebrowsing-dummy/gethash',\n 'browser.safebrowsing.provider.0.keyURL':\n 'http://localhost/safebrowsing-dummy/newkey',\n 'browser.safebrowsing.provider.0.updateURL':\n 'http://localhost/safebrowsing-dummy/update',\n\n // Disable self repair/SHIELD\n 'browser.selfsupport.url': 'https://localhost/selfrepair',\n // Disable Reader Mode UI tour\n 'browser.reader.detectedFirstArticle': true,\n\n // Set the policy firstURL to an empty string to prevent\n // the privacy info page to be opened on every \"web-ext run\".\n // (See #1114 for rationale)\n 'datareporting.policy.firstRunURL': '',\n};\n\nconst prefs = {\n common: prefsCommon,\n fennec: prefsFennec,\n firefox: prefsFirefox,\n};\n\n// Module exports\n\nexport type PreferencesGetterFn = (\n appName: PreferencesAppName\n) => FirefoxPreferences;\n\nexport function getPrefs(\n app: PreferencesAppName = 'firefox'\n): FirefoxPreferences {\n const appPrefs = prefs[app];\n if (!appPrefs) {\n throw new WebExtError(`Unsupported application: ${app}`);\n }\n return {\n ...prefsCommon,\n ...appPrefs,\n };\n}\n\nexport function coerceCLICustomPreference(\n cliPrefs: Array<string>\n): FirefoxPreferences {\n const customPrefs = {};\n\n for (const pref of cliPrefs) {\n const prefsAry = pref.split('=');\n\n if (prefsAry.length < 2) {\n throw new UsageError(\n `Incomplete custom preference: \"${pref}\". ` +\n 'Syntax expected: \"prefname=prefvalue\".'\n );\n }\n\n const key = prefsAry[0];\n let value = prefsAry.slice(1).join('=');\n\n if (/[^\\w{@}.-]/.test(key)) {\n throw new UsageError(`Invalid custom preference name: ${key}`);\n }\n\n if (value === `${parseInt(value)}`) {\n value = parseInt(value, 10);\n } else if (value === 'true' || value === 'false') {\n value = value === 'true';\n }\n\n if (nonOverridablePreferences.includes(key)) {\n log.warn(`'${key}' preference cannot be customized.`);\n continue;\n }\n customPrefs[`${key}`] = value;\n }\n\n return customPrefs;\n}\n"],"mappings":"AACA,SAASA,WAAW,EAAEC,UAAU,QAAQ,cAAc;AACtD,SAASC,YAAY,QAAQ,mBAAmB;AAEhD,MAAMC,GAAG,GAAGD,YAAY,CAACE,MAAM,CAACC,IAAI,CA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,yBAAyB,CAACwB,QAAQ,CAACN,GAAG,CAAC,EAAE;MAC3CtB,GAAG,CAAC6B,IAAI,CAAE,IAAGP,GAAI,oCAAmC,CAAC;MACrD;IACF;IACAL,WAAW,CAAE,GAAEK,GAAI,EAAC,CAAC,GAAGC,KAAK;EAC/B;EAEA,OAAON,WAAW;AACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rdp-client.js","names":["net","EventEmitter","domain","DEFAULT_PORT","DEFAULT_HOST","UNSOLICITED_EVENTS","Set","parseRDPMessage","data","str","toString","sepIdx","indexOf","byteLen","parseInt","slice","isNaN","error","Error","fatal","length","msg","rdpMessage","JSON","parse","connectToFirefox","port","client","FirefoxRDPClient","connect","then","constructor","_incoming","Buffer","alloc","_pending","_active","Map","_onData","args","onData","_onError","onError","_onEnd","onEnd","_onTimeout","onTimeout","Promise","resolve","reject","d","create","once","run","conn","createConnection","host","_rdpConnection","on","_expectReply","disconnect","off","end","_rejectAllRequests","activeDeferred","values","clear","deferred","request","requestProps","to","type","push","_flushPendingRequests","filter","has","stringify","from","write","err","targetActor","set","_handleMessage","rdpData","emit","get","delete","_readMessage","String","concat"],"sources":["../../src/firefox/rdp-client.js"],"sourcesContent":["/* @flow */\nimport net from 'net';\nimport EventEmitter from 'events';\nimport domain from 'domain';\n\nexport type RDPRequest = {\n to: string,\n type: string,\n};\n\nexport type RDPResult = {\n from: string,\n type: string,\n};\n\nexport type Deferred = {|\n resolve: Function,\n reject: Function,\n|};\n\ntype ParseResult = {|\n data: Buffer,\n rdpMessage?: Object,\n error?: Error,\n fatal?: boolean,\n|};\n\nexport const DEFAULT_PORT = 6000;\nexport const DEFAULT_HOST = '127.0.0.1';\n\nconst UNSOLICITED_EVENTS = new Set([\n 'tabNavigated',\n 'styleApplied',\n 'propertyChange',\n 'networkEventUpdate',\n 'networkEvent',\n 'propertyChange',\n 'newMutations',\n 'frameUpdate',\n 'tabListChanged',\n]);\n\n// Parse RDP packets: BYTE_LENGTH + ':' + DATA.\nexport function parseRDPMessage(data: Buffer): ParseResult {\n const str = data.toString();\n const sepIdx = str.indexOf(':');\n if (sepIdx < 1) {\n return { data };\n }\n\n const byteLen = parseInt(str.slice(0, sepIdx));\n if (isNaN(byteLen)) {\n const error = new Error('Error parsing RDP message length');\n return { data, error, fatal: true };\n }\n\n if (data.length - (sepIdx + 1) < byteLen) {\n // Can't parse yet, will retry once more data has been received.\n return { data };\n }\n\n data = data.slice(sepIdx + 1);\n const msg = data.slice(0, byteLen);\n data = data.slice(byteLen);\n\n try {\n return { data, rdpMessage: JSON.parse(msg.toString()) };\n } catch (error) {\n return { data, error, fatal: false };\n }\n}\n\nexport function connectToFirefox(port: number): Promise<FirefoxRDPClient> {\n const client = new FirefoxRDPClient();\n return client.connect(port).then(() => client);\n}\n\nexport default class FirefoxRDPClient extends EventEmitter {\n _incoming: Buffer;\n _pending: Array<{| request: RDPRequest, deferred: Deferred |}>;\n _active: Map<string, Deferred>;\n _rdpConnection: net.Socket;\n _onData: Function;\n _onError: Function;\n _onEnd: Function;\n _onTimeout: Function;\n\n constructor() {\n super();\n this._incoming = Buffer.alloc(0);\n this._pending = [];\n this._active = new Map();\n\n this._onData = (...args) => this.onData(...args);\n this._onError = (...args) => this.onError(...args);\n this._onEnd = (...args) => this.onEnd(...args);\n this._onTimeout = (...args) => this.onTimeout(...args);\n }\n\n connect(port: number): Promise<void> {\n return new Promise((resolve, reject) => {\n // Create a domain to wrap the errors that may be triggered\n // by creating the client connection (e.g. ECONNREFUSED)\n // so that we can reject the promise returned instead of\n // exiting the entire process.\n const d = domain.create();\n d.once('error', reject);\n d.run(() => {\n const conn = net.createConnection({\n port,\n host: DEFAULT_HOST,\n });\n\n this._rdpConnection = conn;\n conn.on('data', this._onData);\n conn.on('error', this._onError);\n conn.on('end', this._onEnd);\n conn.on('timeout', this._onTimeout);\n\n // Resolve once the expected initial root message\n // has been received.\n this._expectReply('root', { resolve, reject });\n });\n });\n }\n\n disconnect(): void {\n if (!this._rdpConnection) {\n return;\n }\n\n const conn = this._rdpConnection;\n conn.off('data', this._onData);\n conn.off('error', this._onError);\n conn.off('end', this._onEnd);\n conn.off('timeout', this._onTimeout);\n conn.end();\n\n this._rejectAllRequests(new Error('RDP connection closed'));\n }\n\n _rejectAllRequests(error: Error) {\n for (const activeDeferred of this._active.values()) {\n activeDeferred.reject(error);\n }\n this._active.clear();\n\n for (const { deferred } of this._pending) {\n deferred.reject(error);\n }\n this._pending = [];\n }\n\n async request(requestProps: string | RDPRequest): Promise<RDPResult> {\n let request: RDPRequest;\n\n if (typeof requestProps === 'string') {\n request = { to: 'root', type: requestProps };\n } else {\n request = requestProps;\n }\n\n if (request.to == null) {\n throw new Error(\n `Unexpected RDP request without target actor: ${request.type}`\n );\n }\n\n return new Promise((resolve, reject) => {\n const deferred = { resolve, reject };\n this._pending.push({ request, deferred });\n this._flushPendingRequests();\n });\n }\n\n _flushPendingRequests(): void {\n this._pending = this._pending.filter(({ request, deferred }) => {\n if (this._active.has(request.to)) {\n // Keep in the pending requests until there are no requests\n // active on the target RDP actor.\n return true;\n }\n\n const conn = this._rdpConnection;\n if (!conn) {\n throw new Error('RDP connection closed');\n }\n\n try {\n let str = JSON.stringify(request);\n str = `${Buffer.from(str).length}:${str}`;\n conn.write(str);\n this._expectReply(request.to, deferred);\n } catch (err) {\n deferred.reject(err);\n }\n\n // Remove the pending request from the queue.\n return false;\n });\n }\n\n _expectReply(targetActor: string, deferred: Deferred): void {\n if (this._active.has(targetActor)) {\n throw new Error(`${targetActor} does already have an active request`);\n }\n\n this._active.set(targetActor, deferred);\n }\n\n _handleMessage(rdpData: Object): void {\n if (rdpData.from == null) {\n if (rdpData.error) {\n this.emit('rdp-error', rdpData);\n return;\n }\n\n this.emit(\n 'error',\n new Error(\n `Received an RDP message without a sender actor: ${JSON.stringify(\n rdpData\n )}`\n )\n );\n return;\n }\n\n if (UNSOLICITED_EVENTS.has(rdpData.type)) {\n this.emit('unsolicited-event', rdpData);\n return;\n }\n\n if (this._active.has(rdpData.from)) {\n const deferred = this._active.get(rdpData.from);\n this._active.delete(rdpData.from);\n if (rdpData.error) {\n deferred?.reject(rdpData);\n } else {\n deferred?.resolve(rdpData);\n }\n this._flushPendingRequests();\n return;\n }\n\n this.emit(\n 'error',\n new Error(`Unexpected RDP message received: ${JSON.stringify(rdpData)}`)\n );\n }\n\n _readMessage(): boolean {\n const { data, rdpMessage, error, fatal } = parseRDPMessage(this._incoming);\n\n this._incoming = data;\n\n if (error) {\n this.emit(\n 'error',\n new Error(`Error parsing RDP packet: ${String(error)}`)\n );\n // Disconnect automatically on a fatal error.\n if (fatal) {\n this.disconnect();\n }\n // Caller can parse the next message if the error wasn't fatal\n // (e.g. the RDP packet that couldn't be parsed has been already\n // removed from the incoming data buffer).\n return !fatal;\n }\n\n if (!rdpMessage) {\n // Caller will need to wait more data to parse the next message.\n return false;\n }\n\n this._handleMessage(rdpMessage);\n // Caller can try to parse the next message from the remining data.\n return true;\n }\n\n onData(data: Buffer) {\n this._incoming = Buffer.concat([this._incoming, data]);\n while (this._readMessage()) {\n // Keep parsing and handling messages until readMessage\n // returns false.\n }\n }\n\n onError(error: Error) {\n this.emit('error', error);\n }\n\n onEnd() {\n this.emit('end');\n }\n\n onTimeout() {\n this.emit('timeout');\n }\n}\n"],"mappings":";AACA,OAAOA,GAAG,MAAM,KAAK;AACrB,OAAOC,YAAY,MAAM,QAAQ;AACjC,OAAOC,MAAM,MAAM,QAAQ;AAwB3B,OAAO,MAAMC,YAAY,GAAG,IAAI;AAChC,OAAO,MAAMC,YAAY,GAAG,WAAW;AAEvC,MAAMC,kBAAkB,GAAG,IAAIC,GAAG,CAAC,CACjC,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,gBAAgB,CACjB,CAAC;;AAEF;AACA,OAAO,SAASC,eAAe,CAACC,IAAY,EAAe;EACzD,MAAMC,GAAG,GAAGD,I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EventEmitter","domain","DEFAULT_PORT","DEFAULT_HOST","UNSOLICITED_EVENTS","Set","parseRDPMessage","data","str","toString","sepIdx","indexOf","byteLen","parseInt","slice","isNaN","error","Error","fatal","length","msg","rdpMessage","JSON","parse","connectToFirefox","port","client","FirefoxRDPClient","connect","then","constructor","_incoming","Buffer","alloc","_pending","_active","Map","_onData","args","onData","_onError","onError","_onEnd","onEnd","_onTimeout","onTimeout","Promise","resolve","reject","d","create","once","run","conn","createConnection","host","_rdpConnection","on","_expectReply","disconnect","off","end","_rejectAllRequests","activeDeferred","values","clear","deferred","request","requestProps","to","type","push","_flushPendingRequests","filter","has","stringify","from","write","err","targetActor","set","_handleMessage","rdpData","emit","get","delete","_readMessage","String","concat"],"sources":["../../src/firefox/rdp-client.js"],"sourcesContent":["/* @flow */\nimport net from 'net';\nimport EventEmitter from 'events';\nimport domain from 'domain';\n\nexport type RDPRequest = {\n to: string,\n type: string,\n};\n\nexport type RDPResult = {\n from: string,\n type: string,\n};\n\nexport type Deferred = {|\n resolve: Function,\n reject: Function,\n|};\n\ntype ParseResult = {|\n data: Buffer,\n rdpMessage?: Object,\n error?: Error,\n fatal?: boolean,\n|};\n\nexport const DEFAULT_PORT = 6000;\nexport const DEFAULT_HOST = '127.0.0.1';\n\nconst UNSOLICITED_EVENTS = new Set([\n 'tabNavigated',\n 'styleApplied',\n 'propertyChange',\n 'networkEventUpdate',\n 'networkEvent',\n 'propertyChange',\n 'newMutations',\n 'frameUpdate',\n 'tabListChanged',\n]);\n\n// Parse RDP packets: BYTE_LENGTH + ':' + DATA.\nexport function parseRDPMessage(data: Buffer): ParseResult {\n const str = data.toString();\n const sepIdx = str.indexOf(':');\n if (sepIdx < 1) {\n return { data };\n }\n\n const byteLen = parseInt(str.slice(0, sepIdx));\n if (isNaN(byteLen)) {\n const error = new Error('Error parsing RDP message length');\n return { data, error, fatal: true };\n }\n\n if (data.length - (sepIdx + 1) < byteLen) {\n // Can't parse yet, will retry once more data has been received.\n return { data };\n }\n\n data = data.slice(sepIdx + 1);\n const msg = data.slice(0, byteLen);\n data = data.slice(byteLen);\n\n try {\n return { data, rdpMessage: JSON.parse(msg.toString()) };\n } catch (error) {\n return { data, error, fatal: false };\n }\n}\n\nexport function connectToFirefox(port: number): Promise<FirefoxRDPClient> {\n const client = new FirefoxRDPClient();\n return client.connect(port).then(() => client);\n}\n\nexport default class FirefoxRDPClient extends EventEmitter {\n _incoming: Buffer;\n _pending: Array<{| request: RDPRequest, deferred: Deferred |}>;\n _active: Map<string, Deferred>;\n _rdpConnection: net.Socket;\n _onData: Function;\n _onError: Function;\n _onEnd: Function;\n _onTimeout: Function;\n\n constructor() {\n super();\n this._incoming = Buffer.alloc(0);\n this._pending = [];\n this._active = new Map();\n\n this._onData = (...args) => this.onData(...args);\n this._onError = (...args) => this.onError(...args);\n this._onEnd = (...args) => this.onEnd(...args);\n this._onTimeout = (...args) => this.onTimeout(...args);\n }\n\n connect(port: number): Promise<void> {\n return new Promise((resolve, reject) => {\n // Create a domain to wrap the errors that may be triggered\n // by creating the client connection (e.g. ECONNREFUSED)\n // so that we can reject the promise returned instead of\n // exiting the entire process.\n const d = domain.create();\n d.once('error', reject);\n d.run(() => {\n const conn = net.createConnection({\n port,\n host: DEFAULT_HOST,\n });\n\n this._rdpConnection = conn;\n conn.on('data', this._onData);\n conn.on('error', this._onError);\n conn.on('end', this._onEnd);\n conn.on('timeout', this._onTimeout);\n\n // Resolve once the expected initial root message\n // has been received.\n this._expectReply('root', { resolve, reject });\n });\n });\n }\n\n disconnect(): void {\n if (!this._rdpConnection) {\n return;\n }\n\n const conn = this._rdpConnection;\n conn.off('data', this._onData);\n conn.off('error', this._onError);\n conn.off('end', this._onEnd);\n conn.off('timeout', this._onTimeout);\n conn.end();\n\n this._rejectAllRequests(new Error('RDP connection closed'));\n }\n\n _rejectAllRequests(error: Error) {\n for (const activeDeferred of this._active.values()) {\n activeDeferred.reject(error);\n }\n this._active.clear();\n\n for (const { deferred } of this._pending) {\n deferred.reject(error);\n }\n this._pending = [];\n }\n\n async request(requestProps: string | RDPRequest): Promise<RDPResult> {\n let request: RDPRequest;\n\n if (typeof requestProps === 'string') {\n request = { to: 'root', type: requestProps };\n } else {\n request = requestProps;\n }\n\n if (request.to == null) {\n throw new Error(\n `Unexpected RDP request without target actor: ${request.type}`\n );\n }\n\n return new Promise((resolve, reject) => {\n const deferred = { resolve, reject };\n this._pending.push({ request, deferred });\n this._flushPendingRequests();\n });\n }\n\n _flushPendingRequests(): void {\n this._pending = this._pending.filter(({ request, deferred }) => {\n if (this._active.has(request.to)) {\n // Keep in the pending requests until there are no requests\n // active on the target RDP actor.\n return true;\n }\n\n const conn = this._rdpConnection;\n if (!conn) {\n throw new Error('RDP connection closed');\n }\n\n try {\n let str = JSON.stringify(request);\n str = `${Buffer.from(str).length}:${str}`;\n conn.write(str);\n this._expectReply(request.to, deferred);\n } catch (err) {\n deferred.reject(err);\n }\n\n // Remove the pending request from the queue.\n return false;\n });\n }\n\n _expectReply(targetActor: string, deferred: Deferred): void {\n if (this._active.has(targetActor)) {\n throw new Error(`${targetActor} does already have an active request`);\n }\n\n this._active.set(targetActor, deferred);\n }\n\n _handleMessage(rdpData: Object): void {\n if (rdpData.from == null) {\n if (rdpData.error) {\n this.emit('rdp-error', rdpData);\n return;\n }\n\n this.emit(\n 'error',\n new Error(\n `Received an RDP message without a sender actor: ${JSON.stringify(\n rdpData\n )}`\n )\n );\n return;\n }\n\n if (UNSOLICITED_EVENTS.has(rdpData.type)) {\n this.emit('unsolicited-event', rdpData);\n return;\n }\n\n if (this._active.has(rdpData.from)) {\n const deferred = this._active.get(rdpData.from);\n this._active.delete(rdpData.from);\n if (rdpData.error) {\n deferred?.reject(rdpData);\n } else {\n deferred?.resolve(rdpData);\n }\n this._flushPendingRequests();\n return;\n }\n\n this.emit(\n 'error',\n new Error(`Unexpected RDP message received: ${JSON.stringify(rdpData)}`)\n );\n }\n\n _readMessage(): boolean {\n const { data, rdpMessage, error, fatal } = parseRDPMessage(this._incoming);\n\n this._incoming = data;\n\n if (error) {\n this.emit(\n 'error',\n new Error(`Error parsing RDP packet: ${String(error)}`)\n );\n // Disconnect automatically on a fatal error.\n if (fatal) {\n this.disconnect();\n }\n // Caller can parse the next message if the error wasn't fatal\n // (e.g. the RDP packet that couldn't be parsed has been already\n // removed from the incoming data buffer).\n return !fatal;\n }\n\n if (!rdpMessage) {\n // Caller will need to wait more data to parse the next message.\n return false;\n }\n\n this._handleMessage(rdpMessage);\n // Caller can try to parse the next message from the remining data.\n return true;\n }\n\n onData(data: Buffer) {\n this._incoming = Buffer.concat([this._incoming, data]);\n while (this._readMessage()) {\n // Keep parsing and handling messages until readMessage\n // returns false.\n }\n }\n\n onError(error: Error) {\n this.emit('error', error);\n }\n\n onEnd() {\n this.emit('end');\n }\n\n onTimeout() {\n this.emit('timeout');\n }\n}\n"],"mappings":"AACA,OAAOA,GAAG,MAAM,KAAK;AACrB,OAAOC,YAAY,MAAM,QAAQ;AACjC,OAAOC,MAAM,MAAM,QAAQ;AAwB3B,OAAO,MAAMC,YAAY,GAAG,IAAI;AAChC,OAAO,MAAMC,YAAY,GAAG,WAAW;AAEvC,MAAMC,kBAAkB,GAAG,IAAIC,GAAG,CAAC,CACjC,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,gBAAgB,CACjB,CAAC;;AAEF;AACA,OAAO,SAASC,eAAeA,CAACC,IAAY,EAAe;EACzD,MAAMC,GAAG,GAAGD,IAAI,CAACE,QAAQ,EAAE;EAC3B,MAAMC,MAAM,GAAGF,GAAG,CAACG,OAAO,CAAC,GAAG,CAAC;EAC/B,IAAID,MAAM,GAAG,CAAC,EAAE;IACd,OAAO;MAAEH;IAAK,CAAC;EACjB;EAEA,MAAMK,OAAO,GAAGC,QAAQ,CAACL,GAAG,CAACM,KAAK,CAAC,CAAC,EAAEJ,MAAM,CAAC,CAAC;EAC9C,IAAIK,K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U;MAAEL,KAAK;MAAEE;IAAM,CAAC,GAAGZ,eAAe,CAAC,IAAI,CAACyB,SAAS,CAAC;IAE1E,IAAI,CAACA,SAAS,GAAGxB,IAAI;IAErB,IAAIS,KAAK,EAAE;MACT,IAAI,CAACmE,IAAI,CACP,OAAO,EACP,IAAIlE,KAAK,CAAE,6BAA4BsE,MAAM,CAACvE,KAAK,CAAE,EAAC,CAAC,CACxD;MACD;MACA,IAAIE,KAAK,EAAE;QACT,IAAI,CAACyC,UAAU,EAAE;MACnB;MACA;MACA;MACA;MACA,OAAO,CAACzC,KAAK;IACf;IAEA,IAAI,CAACG,UAAU,EAAE;MACf;MACA,OAAO,KAAK;IACd;IAEA,IAAI,CAAC4D,cAAc,CAAC5D,UAAU,CAAC;IAC/B;IACA,OAAO,IAAI;EACb;EAEAkB,MAAMA,CAAChC,IAAY,EAAE;IACnB,IAAI,CAACwB,SAAS,GAAGC,MAAM,CAACwD,MAAM,CAAC,CAAC,IAAI,CAACzD,SAAS,EAAExB,IAAI,CAAC,CAAC;IACtD,OAAO,IAAI,CAAC+E,YAAY,EAAE,EAAE;MAC1B;MACA;IAAA;EAEJ;EAEA7C,OAAOA,CAACzB,KAAY,EAAE;IACpB,IAAI,CAACmE,IAAI,CAAC,OAAO,EAAEnE,KAAK,CAAC;EAC3B;EAEA2B,KAAKA,CAAA,EAAG;IACN,IAAI,CAACwC,IAAI,CAAC,KAAK,CAAC;EAClB;EAEAtC,SAASA,CAAA,EAAG;IACV,IAAI,CAACsC,IAAI,CAAC,SAAS,CAAC;EACtB;AACF"}
|
package/lib/firefox/remote.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote.js","names":["net","FirefoxRDPClient","connectToFirefox","defaultFirefoxConnector","createLogger","isErrorWithCode","RemoteTempInstallNotSupported","UsageError","WebExtError","log","import","meta","url","requestErrorToMessage","err","Error","String","error","message","RemoteFirefox","constructor","client","checkedForAddonReloading","on","debug","info","JSON","stringify","rdpError","disconnect","addonRequest","addon","request","response","to","actor","type","getAddonsActor","addonsActor","Promise","reject","installTemporaryAddon","addonPath","openDevTools","getInstalledAddon","addonId","addons","id","map","a","checkForAddonReloading","requestTypes","indexOf","supportedRequestTypes","reloadAddon","process","stdout","write","Date","toTimeString","connect","port","connectWithMaxRetries","maxRetries","retryInterval","establishConnection","lastError","retries","resolve","setTimeout","stack","findFreeTcpPort","srv","createServer","listen","freeTcpPort","address","close"],"sources":["../../src/firefox/remote.js"],"sourcesContent":["/* @flow */\nimport net from 'net';\n\nimport FirefoxRDPClient, {\n connectToFirefox as defaultFirefoxConnector,\n} from './rdp-client.js';\nimport { createLogger } from '../util/logger.js';\nimport {\n isErrorWithCode,\n RemoteTempInstallNotSupported,\n UsageError,\n WebExtError,\n} from '../errors.js';\n\nconst log = createLogger(import.meta.url);\n\nexport type FirefoxConnectorFn = (port: number) => Promise<FirefoxRDPClient>;\n\nexport type FirefoxRDPAddonActor = {|\n id: string,\n actor: string,\n|};\n\nexport type FirefoxRDPResponseError = {|\n error: string,\n message: string,\n|};\n\nexport type FirefoxRDPResponseAddon = {|\n addon: FirefoxRDPAddonActor,\n|};\n\nexport type FirefoxRDPResponseRequestTypes = {|\n requestTypes: Array<string>,\n|};\n\n// NOTE: this type aliases Object to catch any other possible response.\nexport type FirefoxRDPResponseAny = Object;\n\nexport type FirefoxRDPResponseMaybe =\n | FirefoxRDPResponseRequestTypes\n | FirefoxRDPResponseAny;\n\n// Convert a request rejection to a message string.\nfunction requestErrorToMessage(err: Error | FirefoxRDPResponseError) {\n if (err instanceof Error) {\n return String(err);\n }\n return `${err.error}: ${err.message}`;\n}\n\nexport class RemoteFirefox {\n client: Object;\n checkedForAddonReloading: boolean;\n\n constructor(client: FirefoxRDPClient) {\n this.client = client;\n this.checkedForAddonReloading = false;\n\n client.on('disconnect', () => {\n log.debug('Received \"disconnect\" from Firefox client');\n });\n client.on('end', () => {\n log.debug('Received \"end\" from Firefox client');\n });\n client.on('unsolicited-event', (info) => {\n log.debug(`Received message from client: ${JSON.stringify(info)}`);\n });\n client.on('rdp-error', (rdpError) => {\n log.debug(`Received error from client: ${JSON.stringify(rdpError)}`);\n });\n client.on('error', (error) => {\n log.debug(`Received error from client: ${String(error)}`);\n });\n }\n\n disconnect() {\n this.client.disconnect();\n }\n\n async addonRequest(\n addon: FirefoxRDPAddonActor,\n request: string\n ): Promise<FirefoxRDPResponseMaybe> {\n try {\n const response = await this.client.request({\n to: addon.actor,\n type: request,\n });\n return response;\n } catch (err) {\n log.debug(`Client responded to '${request}' request with error:`, err);\n const message = requestErrorToMessage(err);\n throw new WebExtError(`Remote Firefox: addonRequest() error: ${message}`);\n }\n }\n\n async getAddonsActor(): Promise<string> {\n try {\n // getRoot should work since Firefox 55 (bug 1352157).\n const response = await this.client.request('getRoot');\n if (response.addonsActor == null) {\n return Promise.reject(\n new RemoteTempInstallNotSupported(\n 'This version of Firefox does not provide an add-ons actor for ' +\n 'remote installation.'\n )\n );\n }\n return response.addonsActor;\n } catch (err) {\n // Fallback to listTabs otherwise, Firefox 49 - 77 (bug 1618691).\n log.debug('Falling back to listTabs because getRoot failed', err);\n }\n\n try {\n const response = await this.client.request('listTabs');\n // addonsActor was added to listTabs in Firefox 49 (bug 1273183).\n if (response.addonsActor == null) {\n log.debug(\n 'listTabs returned a falsey addonsActor: ' +\n `${JSON.stringify(response)}`\n );\n return Promise.reject(\n new RemoteTempInstallNotSupported(\n 'This is an older version of Firefox that does not provide an ' +\n 'add-ons actor for remote installation. Try Firefox 49 or ' +\n 'higher.'\n )\n );\n }\n return response.addonsActor;\n } catch (err) {\n log.debug('listTabs error', err);\n const message = requestErrorToMessage(err);\n throw new WebExtError(`Remote Firefox: listTabs() error: ${message}`);\n }\n }\n\n async installTemporaryAddon(\n addonPath: string,\n openDevTools?: boolean\n ): Promise<FirefoxRDPResponseAddon> {\n const addonsActor = await this.getAddonsActor();\n\n try {\n const response = await this.client.request({\n to: addonsActor,\n type: 'installTemporaryAddon',\n addonPath,\n openDevTools,\n });\n log.debug(`installTemporaryAddon: ${JSON.stringify(response)}`);\n log.info(`Installed ${addonPath} as a temporary add-on`);\n return response;\n } catch (err) {\n const message = requestErrorToMessage(err);\n throw new WebExtError(`installTemporaryAddon: Error: ${message}`);\n }\n }\n\n async getInstalledAddon(addonId: string): Promise<FirefoxRDPAddonActor> {\n try {\n const response = await this.client.request('listAddons');\n for (const addon of response.addons) {\n if (addon.id === addonId) {\n return addon;\n }\n }\n log.debug(\n `Remote Firefox has these addons: ${response.addons.map((a) => a.id)}`\n );\n return Promise.reject(\n new WebExtError(\n 'The remote Firefox does not have your extension installed'\n )\n );\n } catch (err) {\n const message = requestErrorToMessage(err);\n throw new WebExtError(`Remote Firefox: listAddons() error: ${message}`);\n }\n }\n\n async checkForAddonReloading(\n addon: FirefoxRDPAddonActor\n ): Promise<FirefoxRDPAddonActor> {\n if (this.checkedForAddonReloading) {\n // We only need to check once if reload() is supported.\n return addon;\n } else {\n const response = await this.addonRequest(addon, 'requestTypes');\n\n if (response.requestTypes.indexOf('reload') === -1) {\n const supportedRequestTypes = JSON.stringify(response.requestTypes);\n log.debug(`Remote Firefox only supports: ${supportedRequestTypes}`);\n throw new UsageError(\n 'This Firefox version does not support add-on reloading. ' +\n 'Re-run with --no-reload'\n );\n } else {\n this.checkedForAddonReloading = true;\n return addon;\n }\n }\n }\n\n async reloadAddon(addonId: string): Promise<void> {\n const addon = await this.getInstalledAddon(addonId);\n await this.checkForAddonReloading(addon);\n await this.addonRequest(addon, 'reload');\n process.stdout.write(\n `\\rLast extension reload: ${new Date().toTimeString()}`\n );\n log.debug('\\n');\n }\n}\n\n// Connect types and implementation\n\nexport type ConnectOptions = {\n connectToFirefox: FirefoxConnectorFn,\n};\n\nexport async function connect(\n port: number,\n { connectToFirefox = defaultFirefoxConnector }: ConnectOptions = {}\n): Promise<RemoteFirefox> {\n log.debug(`Connecting to Firefox on port ${port}`);\n const client = await connectToFirefox(port);\n log.debug(`Connected to the remote Firefox debugger on port ${port}`);\n return new RemoteFirefox(client);\n}\n\n// ConnectWithMaxRetries types and implementation\n\nexport type ConnectWithMaxRetriesParams = {|\n maxRetries?: number,\n retryInterval?: number,\n port: number,\n|};\n\nexport type ConnectWithMaxRetriesDeps = {\n connectToFirefox: typeof connect,\n};\n\nexport async function connectWithMaxRetries(\n // A max of 250 will try connecting for 30 seconds.\n { maxRetries = 250, retryInterval = 120, port }: ConnectWithMaxRetriesParams,\n { connectToFirefox = connect }: ConnectWithMaxRetriesDeps = {}\n): Promise<RemoteFirefox> {\n async function establishConnection() {\n var lastError;\n\n for (let retries = 0; retries <= maxRetries; retries++) {\n try {\n return await connectToFirefox(port);\n } catch (error) {\n if (isErrorWithCode('ECONNREFUSED', error)) {\n // Wait for `retryInterval` ms.\n await new Promise((resolve) => {\n setTimeout(resolve, retryInterval);\n });\n\n lastError = error;\n log.debug(\n `Retrying Firefox (${retries}); connection error: ${error}`\n );\n } else {\n log.error(error.stack);\n throw error;\n }\n }\n }\n\n log.debug('Connect to Firefox debugger: too many retries');\n throw lastError;\n }\n\n log.debug('Connecting to the remote Firefox debugger');\n return establishConnection();\n}\n\nexport function findFreeTcpPort(): Promise<number> {\n return new Promise((resolve) => {\n const srv = net.createServer();\n // $FlowFixMe: signature for listen() is missing - see https://github.com/facebook/flow/pull/8290\n srv.listen(0, '127.0.0.1', () => {\n const freeTcpPort = srv.address().port;\n srv.close(() => resolve(freeTcpPort));\n });\n });\n}\n"],"mappings":";AACA,OAAOA,GAAG,MAAM,KAAK;AAErB,OAAOC,gBAAgB,IACrBC,gBAAgB,IAAIC,uBAAuB,QACtC,iBAAiB;AACxB,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SACEC,eAAe,EACfC,6BAA6B,EAC7BC,UAAU,EACVC,WAAW,QACN,cAAc;AAErB,MAAMC,GAAG,GAAGL,YAAY,CAACM,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC;AA6BzC;AACA,SAASC,qBAAqB,CAACC,GAAoC,EAAE;EACnE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,eAAe,GAAoB;EACjD,OAAO,IAAIhC,OAAO,CAAE6B,OAAO,IAAK;IAC9B,MAAMI,GAAG,GAAGxE,GAAG,CAACyE,YAAY,EAAE;IAC9B;IACAD,GAAG,CAACE,MAAM,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM;MAC/B,MAAMC,WAAW,GAAGH,GAAG,CAACI,OAAO,EAAE,CAACf,IAAI;MACtCW,GAAG,CAACK,KAAK,CAAC,MAAMT,OAAO,CAACO,WAAW,CAAC,CAAC;IACvC,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ"}
|
|
1
|
+
{"version":3,"file":"remote.js","names":["net","FirefoxRDPClient","connectToFirefox","defaultFirefoxConnector","createLogger","isErrorWithCode","RemoteTempInstallNotSupported","UsageError","WebExtError","log","import","meta","url","requestErrorToMessage","err","Error","String","error","message","RemoteFirefox","constructor","client","checkedForAddonReloading","on","debug","info","JSON","stringify","rdpError","disconnect","addonRequest","addon","request","response","to","actor","type","getAddonsActor","addonsActor","Promise","reject","installTemporaryAddon","addonPath","openDevTools","getInstalledAddon","addonId","addons","id","map","a","checkForAddonReloading","requestTypes","indexOf","supportedRequestTypes","reloadAddon","process","stdout","write","Date","toTimeString","connect","port","connectWithMaxRetries","maxRetries","retryInterval","establishConnection","lastError","retries","resolve","setTimeout","stack","findFreeTcpPort","srv","createServer","listen","freeTcpPort","address","close"],"sources":["../../src/firefox/remote.js"],"sourcesContent":["/* @flow */\nimport net from 'net';\n\nimport FirefoxRDPClient, {\n connectToFirefox as defaultFirefoxConnector,\n} from './rdp-client.js';\nimport { createLogger } from '../util/logger.js';\nimport {\n isErrorWithCode,\n RemoteTempInstallNotSupported,\n UsageError,\n WebExtError,\n} from '../errors.js';\n\nconst log = createLogger(import.meta.url);\n\nexport type FirefoxConnectorFn = (port: number) => Promise<FirefoxRDPClient>;\n\nexport type FirefoxRDPAddonActor = {|\n id: string,\n actor: string,\n|};\n\nexport type FirefoxRDPResponseError = {|\n error: string,\n message: string,\n|};\n\nexport type FirefoxRDPResponseAddon = {|\n addon: FirefoxRDPAddonActor,\n|};\n\nexport type FirefoxRDPResponseRequestTypes = {|\n requestTypes: Array<string>,\n|};\n\n// NOTE: this type aliases Object to catch any other possible response.\nexport type FirefoxRDPResponseAny = Object;\n\nexport type FirefoxRDPResponseMaybe =\n | FirefoxRDPResponseRequestTypes\n | FirefoxRDPResponseAny;\n\n// Convert a request rejection to a message string.\nfunction requestErrorToMessage(err: Error | FirefoxRDPResponseError) {\n if (err instanceof Error) {\n return String(err);\n }\n return `${err.error}: ${err.message}`;\n}\n\nexport class RemoteFirefox {\n client: Object;\n checkedForAddonReloading: boolean;\n\n constructor(client: FirefoxRDPClient) {\n this.client = client;\n this.checkedForAddonReloading = false;\n\n client.on('disconnect', () => {\n log.debug('Received \"disconnect\" from Firefox client');\n });\n client.on('end', () => {\n log.debug('Received \"end\" from Firefox client');\n });\n client.on('unsolicited-event', (info) => {\n log.debug(`Received message from client: ${JSON.stringify(info)}`);\n });\n client.on('rdp-error', (rdpError) => {\n log.debug(`Received error from client: ${JSON.stringify(rdpError)}`);\n });\n client.on('error', (error) => {\n log.debug(`Received error from client: ${String(error)}`);\n });\n }\n\n disconnect() {\n this.client.disconnect();\n }\n\n async addonRequest(\n addon: FirefoxRDPAddonActor,\n request: string\n ): Promise<FirefoxRDPResponseMaybe> {\n try {\n const response = await this.client.request({\n to: addon.actor,\n type: request,\n });\n return response;\n } catch (err) {\n log.debug(`Client responded to '${request}' request with error:`, err);\n const message = requestErrorToMessage(err);\n throw new WebExtError(`Remote Firefox: addonRequest() error: ${message}`);\n }\n }\n\n async getAddonsActor(): Promise<string> {\n try {\n // getRoot should work since Firefox 55 (bug 1352157).\n const response = await this.client.request('getRoot');\n if (response.addonsActor == null) {\n return Promise.reject(\n new RemoteTempInstallNotSupported(\n 'This version of Firefox does not provide an add-ons actor for ' +\n 'remote installation.'\n )\n );\n }\n return response.addonsActor;\n } catch (err) {\n // Fallback to listTabs otherwise, Firefox 49 - 77 (bug 1618691).\n log.debug('Falling back to listTabs because getRoot failed', err);\n }\n\n try {\n const response = await this.client.request('listTabs');\n // addonsActor was added to listTabs in Firefox 49 (bug 1273183).\n if (response.addonsActor == null) {\n log.debug(\n 'listTabs returned a falsey addonsActor: ' +\n `${JSON.stringify(response)}`\n );\n return Promise.reject(\n new RemoteTempInstallNotSupported(\n 'This is an older version of Firefox that does not provide an ' +\n 'add-ons actor for remote installation. Try Firefox 49 or ' +\n 'higher.'\n )\n );\n }\n return response.addonsActor;\n } catch (err) {\n log.debug('listTabs error', err);\n const message = requestErrorToMessage(err);\n throw new WebExtError(`Remote Firefox: listTabs() error: ${message}`);\n }\n }\n\n async installTemporaryAddon(\n addonPath: string,\n openDevTools?: boolean\n ): Promise<FirefoxRDPResponseAddon> {\n const addonsActor = await this.getAddonsActor();\n\n try {\n const response = await this.client.request({\n to: addonsActor,\n type: 'installTemporaryAddon',\n addonPath,\n openDevTools,\n });\n log.debug(`installTemporaryAddon: ${JSON.stringify(response)}`);\n log.info(`Installed ${addonPath} as a temporary add-on`);\n return response;\n } catch (err) {\n const message = requestErrorToMessage(err);\n throw new WebExtError(`installTemporaryAddon: Error: ${message}`);\n }\n }\n\n async getInstalledAddon(addonId: string): Promise<FirefoxRDPAddonActor> {\n try {\n const response = await this.client.request('listAddons');\n for (const addon of response.addons) {\n if (addon.id === addonId) {\n return addon;\n }\n }\n log.debug(\n `Remote Firefox has these addons: ${response.addons.map((a) => a.id)}`\n );\n return Promise.reject(\n new WebExtError(\n 'The remote Firefox does not have your extension installed'\n )\n );\n } catch (err) {\n const message = requestErrorToMessage(err);\n throw new WebExtError(`Remote Firefox: listAddons() error: ${message}`);\n }\n }\n\n async checkForAddonReloading(\n addon: FirefoxRDPAddonActor\n ): Promise<FirefoxRDPAddonActor> {\n if (this.checkedForAddonReloading) {\n // We only need to check once if reload() is supported.\n return addon;\n } else {\n const response = await this.addonRequest(addon, 'requestTypes');\n\n if (response.requestTypes.indexOf('reload') === -1) {\n const supportedRequestTypes = JSON.stringify(response.requestTypes);\n log.debug(`Remote Firefox only supports: ${supportedRequestTypes}`);\n throw new UsageError(\n 'This Firefox version does not support add-on reloading. ' +\n 'Re-run with --no-reload'\n );\n } else {\n this.checkedForAddonReloading = true;\n return addon;\n }\n }\n }\n\n async reloadAddon(addonId: string): Promise<void> {\n const addon = await this.getInstalledAddon(addonId);\n await this.checkForAddonReloading(addon);\n await this.addonRequest(addon, 'reload');\n process.stdout.write(\n `\\rLast extension reload: ${new Date().toTimeString()}`\n );\n log.debug('\\n');\n }\n}\n\n// Connect types and implementation\n\nexport type ConnectOptions = {\n connectToFirefox: FirefoxConnectorFn,\n};\n\nexport async function connect(\n port: number,\n { connectToFirefox = defaultFirefoxConnector }: ConnectOptions = {}\n): Promise<RemoteFirefox> {\n log.debug(`Connecting to Firefox on port ${port}`);\n const client = await connectToFirefox(port);\n log.debug(`Connected to the remote Firefox debugger on port ${port}`);\n return new RemoteFirefox(client);\n}\n\n// ConnectWithMaxRetries types and implementation\n\nexport type ConnectWithMaxRetriesParams = {|\n maxRetries?: number,\n retryInterval?: number,\n port: number,\n|};\n\nexport type ConnectWithMaxRetriesDeps = {\n connectToFirefox: typeof connect,\n};\n\nexport async function connectWithMaxRetries(\n // A max of 250 will try connecting for 30 seconds.\n { maxRetries = 250, retryInterval = 120, port }: ConnectWithMaxRetriesParams,\n { connectToFirefox = connect }: ConnectWithMaxRetriesDeps = {}\n): Promise<RemoteFirefox> {\n async function establishConnection() {\n var lastError;\n\n for (let retries = 0; retries <= maxRetries; retries++) {\n try {\n return await connectToFirefox(port);\n } catch (error) {\n if (isErrorWithCode('ECONNREFUSED', error)) {\n // Wait for `retryInterval` ms.\n await new Promise((resolve) => {\n setTimeout(resolve, retryInterval);\n });\n\n lastError = error;\n log.debug(\n `Retrying Firefox (${retries}); connection error: ${error}`\n );\n } else {\n log.error(error.stack);\n throw error;\n }\n }\n }\n\n log.debug('Connect to Firefox debugger: too many retries');\n throw lastError;\n }\n\n log.debug('Connecting to the remote Firefox debugger');\n return establishConnection();\n}\n\nexport function findFreeTcpPort(): Promise<number> {\n return new Promise((resolve) => {\n const srv = net.createServer();\n // $FlowFixMe: signature for listen() is missing - see https://github.com/facebook/flow/pull/8290\n srv.listen(0, '127.0.0.1', () => {\n const freeTcpPort = srv.address().port;\n srv.close(() => resolve(freeTcpPort));\n });\n });\n}\n"],"mappings":"AACA,OAAOA,GAAG,MAAM,KAAK;AAErB,OAAOC,gBAAgB,IACrBC,gBAAgB,IAAIC,uBAAuB,QACtC,iBAAiB;AACxB,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SACEC,eAAe,EACfC,6BAA6B,EAC7BC,UAAU,EACVC,WAAW,QACN,cAAc;AAErB,MAAMC,GAAG,GAAGL,YAAY,CAACM,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC;AA6BzC;AACA,SAASC,qBAAqBA,CAACC,GAAoC,EAAE;EACnE,IAAIA,GAAG,YAAYC,KAAK,EAAE;IACxB,OAAOC,MAAM,CAACF,GAAG,CAAC;EACpB;EACA,OAAQ,GAAEA,GAAG,CAACG,KAAM,KAAIH,GAAG,CAACI,OAAQ,EAAC;AACvC;AAEA,OAAO,MAAMC,aAAa,CAAC;EAIzBC,WAAWA,CAACC,MAAwB,EAAE;IACpC,IAAI,CAACA,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,wBAAwB,GAAG,KAAK;IAErCD,MAAM,CAACE,EAAE,CAAC,YAAY,EAAE,MAAM;MAC5Bd,GAAG,CAACe,KAAK,CAAC,2CAA2C,CAAC;IACxD,CAAC,CAAC;IACFH,MAAM,CAACE,EAAE,CAAC,KAAK,EAAE,MAAM;MACrBd,GAAG,CAACe,KAAK,CAAC,oCAAoC,CAAC;IACjD,CAAC,CAAC;IACFH,MAAM,CAACE,EAAE,CAAC,mBAAmB,EAAGE,IAAI,IAAK;MACvChB,GAAG,CAACe,KAAK,CAAE,iCAAgCE,IAAI,CAACC,SAAS,CAACF,IAAI,CAAE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,CAAC;MACrC,CAAC,CAAC,OAAO5C,KAAK,EAAE;QACd,IAAIZ,eAAe,CAAC,cAAc,EAAEY,KAAK,CAAC,EAAE;UAC1C;UACA,MAAM,IAAIsB,OAAO,CAAE6B,OAAO,IAAK;YAC7BC,UAAU,CAACD,OAAO,EAAEJ,aAAa,CAAC;UACpC,CAAC,CAAC;UAEFE,SAAS,GAAGjD,KAAK;UACjBR,GAAG,CAACe,KAAK,CACN,qBAAoB2C,OAAQ,wBAAuBlD,KAAM,EAAC,CAC5D;QACH,CAAC,MAAM;UACLR,GAAG,CAACQ,KAAK,CAACA,KAAK,CAACqD,KAAK,CAAC;UACtB,MAAMrD,KAAK;QACb;MACF;IACF;IAEAR,GAAG,CAACe,KAAK,CAAC,+CAA+C,CAAC;IAC1D,MAAM0C,SAAS;EACjB;EAEAzD,GAAG,CAACe,KAAK,CAAC,2CAA2C,CAAC;EACtD,OAAOyC,mBAAmB,EAAE;AAC9B;AAEA,OAAO,SAASM,eAAeA,CAAA,EAAoB;EACjD,OAAO,IAAIhC,OAAO,CAAE6B,OAAO,IAAK;IAC9B,MAAMI,GAAG,GAAGxE,GAAG,CAACyE,YAAY,EAAE;IAC9B;IACAD,GAAG,CAACE,MAAM,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM;MAC/B,MAAMC,WAAW,GAAGH,GAAG,CAACI,OAAO,EAAE,CAACf,IAAI;MACtCW,GAAG,CAACK,KAAK,CAAC,MAAMT,OAAO,CAACO,WAAW,CAAC,CAAC;IACvC,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ"}
|
package/lib/main.js
CHANGED
package/lib/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","names":["main","cmd"],"sources":["../src/main.js"],"sourcesContent":["/* @flow */\nimport { main } from './program.js';\nimport cmd from './cmd/index.js';\n\n// This only exposes main and cmd, while util/logger and util/adb are defined as\n// separate additional exports in the package.json.\nexport default { main, cmd };\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.js","names":["main","cmd"],"sources":["../src/main.js"],"sourcesContent":["/* @flow */\nimport { main } from './program.js';\nimport cmd from './cmd/index.js';\n\n// This only exposes main and cmd, while util/logger and util/adb are defined as\n// separate additional exports in the package.json.\nexport default { main, cmd };\n"],"mappings":"AACA,SAASA,IAAI,QAAQ,cAAc;AACnC,OAAOC,GAAG,MAAM,gBAAgB;;AAEhC;AACA;AACA,eAAe;EAAED,IAAI;EAAEC;AAAI,CAAC"}
|
package/lib/program.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import os from 'os';
|
|
3
2
|
import path from 'path';
|
|
4
3
|
import { readFileSync } from 'fs';
|
|
@@ -17,6 +16,8 @@ const envPrefix = 'WEB_EXT';
|
|
|
17
16
|
// Default to "development" (the value actually assigned will be interpolated
|
|
18
17
|
// by babel-plugin-transform-inline-environment-variables).
|
|
19
18
|
const defaultGlobalEnv = "production" || 'development';
|
|
19
|
+
export const AMO_BASE_URL = 'https://addons.mozilla.org/api/v5/';
|
|
20
|
+
|
|
20
21
|
/*
|
|
21
22
|
* The command line program.
|
|
22
23
|
*/
|
|
@@ -216,7 +217,8 @@ export class Program {
|
|
|
216
217
|
this.enableVerboseMode(logStream, version);
|
|
217
218
|
}
|
|
218
219
|
let adjustedArgv = {
|
|
219
|
-
...argv
|
|
220
|
+
...argv,
|
|
221
|
+
webextVersion: version
|
|
220
222
|
};
|
|
221
223
|
try {
|
|
222
224
|
if (cmd === undefined) {
|
|
@@ -426,7 +428,7 @@ Example: $0 --help run.
|
|
|
426
428
|
}).command('sign', 'Sign the extension so it can be installed in Firefox', commands.sign, {
|
|
427
429
|
'amo-base-url': {
|
|
428
430
|
describe: 'Signing API URL prefix - only used with `use-submission-api`',
|
|
429
|
-
default:
|
|
431
|
+
default: AMO_BASE_URL,
|
|
430
432
|
demandOption: true,
|
|
431
433
|
type: 'string'
|
|
432
434
|
},
|
|
@@ -465,8 +467,14 @@ Example: $0 --help run.
|
|
|
465
467
|
describe: 'Number of milliseconds to wait before giving up',
|
|
466
468
|
type: 'number'
|
|
467
469
|
},
|
|
470
|
+
'disable-progress-bar': {
|
|
471
|
+
describe: 'Disable the progress bar in sign-addon',
|
|
472
|
+
demandOption: false,
|
|
473
|
+
type: 'boolean'
|
|
474
|
+
},
|
|
468
475
|
channel: {
|
|
469
|
-
describe: 'The channel for which to sign the addon. Either ' + "'listed' or 'unlisted'"
|
|
476
|
+
describe: 'The channel for which to sign the addon. Either ' + "'listed' or 'unlisted'",
|
|
477
|
+
type: 'string'
|
|
470
478
|
},
|
|
471
479
|
'amo-metadata': {
|
|
472
480
|
describe: 'Path to a JSON file containing an object with metadata ' + 'to be passed to the API. ' + 'See https://addons-server.readthedocs.io' + '/en/latest/topics/api/addons.html for details. ' + 'Only used with `use-submission-api`',
|
|
@@ -483,7 +491,7 @@ Example: $0 --help run.
|
|
|
483
491
|
},
|
|
484
492
|
firefox: {
|
|
485
493
|
alias: ['f', 'firefox-binary'],
|
|
486
|
-
describe: 'Path or alias to a Firefox executable such as firefox-bin ' + 'or firefox.exe. ' + 'If not specified, the default Firefox will be used. ' + 'You can specify the following aliases in lieu of a path: ' + 'firefox, beta, nightly, firefoxdeveloperedition. ' + 'For Flatpak, use `flatpak:org.mozilla.firefox` where ' + '`org.mozilla.firefox` is the application ID.',
|
|
494
|
+
describe: 'Path or alias to a Firefox executable such as firefox-bin ' + 'or firefox.exe. ' + 'If not specified, the default Firefox will be used. ' + 'You can specify the following aliases in lieu of a path: ' + 'firefox, beta, nightly, firefoxdeveloperedition (or deved). ' + 'For Flatpak, use `flatpak:org.mozilla.firefox` where ' + '`org.mozilla.firefox` is the application ID.',
|
|
487
495
|
demandOption: false,
|
|
488
496
|
type: 'string'
|
|
489
497
|
},
|