diff --git a/resolvers/Device.js b/resolvers/Device.js index cdb3a408..8fc6fabc 100644 --- a/resolvers/Device.js +++ b/resolvers/Device.js @@ -77,6 +77,39 @@ const Device = { return hardwareSerial }, + async extensions (root, args, context) { + const { browser = "all" } = args + let chrome = [] + let firefox = [] + let safari = [] + + if (['all', 'chrome'].includes(browser)) { + chrome = await OSQuery.all('chrome_extensions').then(results => + results.map(({ name, version, identifier, path, author }) => + ({ name, path, version, identifier, author, browser: 'chrome' }) + ) + ) + } + + if (['all', 'firefox'].includes(browser)) { + firefox = await OSQuery.all('firefox_addons').then(results => + results.map(({ name, version, identifier, path, creator: author }) => + ({ name, path, version, identifier, author, browser: 'firefox' }) + ) + ) + } + + if (['all', 'safari'].includes(browser)) { + safari = await OSQuery.all('safari_extensions').then(results => + results.map(({ name, version, identifier, path, creator: author }) => + ({ name, path, version, identifier, author, browser: 'safari' }) + ) + ) + } + + return chrome.concat(firefox).concat(safari) + }, + async applications (root, args, context) { const os = PlatformResolvers[context.platform] if ('applications' in os) { diff --git a/schema.graphql b/schema.graphql index 798ba0d0..45282f39 100644 --- a/schema.graphql +++ b/schema.graphql @@ -36,6 +36,8 @@ type Device { hardwareSerial: String # installed applications applications: [Application] + # browser extensions + extensions(browser: Browser): [Extension] # current IP addresses ipAddresses: [IpAddress] # interface_details @@ -88,6 +90,15 @@ type Application { installDate: String } +type Extension { + name: String! + path: String! + version: String! + author: String! + identifier: String! + browser: String! +} + # A DevicePolicy is a description of the desired state of a set of pre-selected device features input DevicePolicy { # current operation system version, use [semver](https://www.nodesource.com/blog/semver-a-primer/) strings to define requirement @@ -240,6 +251,13 @@ input VersionBracket { nudge: Semver } +enum Browser { + chrome + firefox + safari + all +} + # possible states that a device 'feature' can be in enum FeatureState { PASS