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.
Simple browser file caching implementation to give your website/application wings.
npm install appsw
Append appsw
command after the default build command.
{
"scripts": {
"build": "my-build-command && appsw"
}
}
Argument | Type | Default | Usage |
---|---|---|---|
--appsw-root | String | build | Build directory path |
--type | String | runtime | static or runtime |
--uncompressed | false | Output uncompressed scripts | |
--debug | false | Add debugging logs in output scripts |
Example
appsw --appsw-root ./example --type runtime --uncompressed --debug
index.html
<body>
...
<script src="/service-worker-handler.js"></script>
</body>
An empty js file
service-worker-handler.js
can be kept to avoid unwanted 404 error in dev mode.
When the application updates its cache, a page reload may be required to use the latest files, which can cause a brief interruption for the user because of reload. To prevent this, the application should wait for the SW_READY
event.
window.addEventListener('APPSW_READY', () => {
console.log('AppSW ready!')
})
Only occurs when new version of the application is deployed.
runtime
vs static
static
cache else runtime
cache.offline.html
which will be visible when there is not internet connection.Add service-worker-append.js
file which will automatically append content in default service worker.
To stop using appsw
, first remove appsw
command from build script.
To disable appsw
service worker, update apphash.json
as:
{ "disable": true }
To completely remove service worker from your application, update apphash.json
as:
{ "unregister": true }
apphash.json
auto-generated: Keeps a track of cached files.service-worker.js
auto-generated: Main service worker file.service-worker-handler.js
auto-generated: Setup service worker, responsible for cache rotation & ready event.service-worker-append.js
: Contains custom code to be appended in the main service worker file.Cache-Control
header from your server to cache files.apphash.json
is updated accordingly; refer to the migration docs above.APPSW_READY
event is recommended for smooth user experience.FAQs
Application service worker generator
We found that appsw demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.