Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
add-to-homescreen-control
Advanced tools
Library that allows you to control new Add to Home Screen prompt behavior
This library allows you to programatically show Add to Home Screen banner. this feature is available from Chrome 68 but the library works on the older versions aswell. It's recomennded to read useful information section before using this library to avoid common problems and gotchas.
enable(): void
- enables capturing of beforeinstallprompt
event and all the librarys behavior. You need to invoke this function as fast as you can to use all the other parts of this library.
prompt(): Promise
- shows the Add to Home Screen banner (if the criteria are met) and resolves when user decides either to install or decline on Add to Home Screen. The resolved Promise value is an object with two values:
outcome: string
- outcome of the homescreen installation. Contains accepted
if the app was succesfully installed, otherwise contains dismissed
string.platform: string
- platform used for installationcanPrompt(): boolean
- returns true
if the ATHS criteria are met and prompt()
method can be fired
npm i add-to-homescreen-control -d
import ATHS from 'add-to-homescreen-control'
ATHS.enable()
prompt()
method. The banner will appear only if the criteria are met. You can handle unmet criteria in two ways:prompt()
returns a Promise (recommended):ATHS.prompt()
.then(({ outcome }) => console.log('user interacted with ATHS banner with outcome of', outcome))
.catch(err => console.log(err))
canPrompt
property to check if the prompt()
method is available:Here you can find example usage of this library (with local import)
Add to Home Screen behavior is supported by most of the modern browsers but the banner encouraging users to install the app will be displayed only in Google Chrome. The process of adding website to the homescreen is different for every browser and this library is focused mostly on Chrome since the ATHS banner is present only there.
Before ATHS prompt can be shown the following criteria needs to be met:
index.html
includes Web App Manifest with at least following propertiesshort_name
, name
, start_url
, icons
(at least 192px and 512px), display
(standalone, fullscreen, minimal-ui)You can succesfully use librarys prompt()
method only if this criteria are met. Otherwise it'll end up as a rejected promise.
You can use canPrompt
variable to detect if the criteria are already met.
This criteria are different for other browsers.
x
on a banner it can't be shown again for a significant amount of time (currently ~3 months)FAQs
Library that allows you to control new Add to Home Screen prompt behavior
The npm package add-to-homescreen-control receives a total of 3 weekly downloads. As such, add-to-homescreen-control popularity was classified as not popular.
We found that add-to-homescreen-control demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.