Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dsw

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dsw - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

sandbox/manifest.json

9

dsw.js

@@ -492,4 +492,11 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

var url = new URL(event.request.url);
var pathName = new URL(url).pathname;
var pathName = url.pathname;
// in case we want to enforce https
if (PWASettings.enforceSSL) {
if (url.protocol != 'https:' && url.hostname != 'localhost') {
event.respondWith(Response.redirect(event.request.url.replace('http:', 'https:'), 302));
}
}
var i = 0,

@@ -496,0 +503,0 @@ l = (DSWManager.rules['*'] || []).length;

28

index.js

@@ -5,4 +5,6 @@ #!/usr/bin/env node

console.info('1/5 => Starting up');
console.info('1/6 => Starting up');
const TMP_FILE = './.tmp-dsw-lib.js';
const MANIFEST = '/webapp-manifest.json';
let fs = require('fs'),

@@ -12,3 +14,2 @@ dswPath = './' + (process.argv[2] || ''),

.replace(/\/\//g, '/'),
//.replace(/\.\./g, '.'),
lib,

@@ -19,3 +20,3 @@ settings,

console.info('2/5 => Loading files');
console.info('2/6 => Loading files');
try {

@@ -30,3 +31,3 @@ lib = fs.readFileSync(__dirname + '/dsw.js', 'utf8');

// validate the json file before generating it
console.info('3/5 => Validating JSON');
console.info('3/6 => Validating JSON');
try{

@@ -47,3 +48,3 @@ let jsonData = JSON.parse(settings);

console.info('4/5 => Writing file');
console.info('4/6 => Writing dswfile.js');

@@ -56,4 +57,19 @@ fullContent = "const PWASettings = " + settings + ';\n' + lib;

console.info(' 5 ... your are good to go, sir!\n\n ()_()\n (ᵔᴥᵔ)\n\nStart your HTTP server at ' + dswPath + '\n');
console.info('5/6 => Writing your manifest');
let manifestContent = fs.readFileSync(__dirname + '/src/manifest-model.json');
try {
if (!fs.existsSync( dswPath + MANIFEST )) {
fs.writeFileSync(dswPath + MANIFEST, manifestContent, 'utf8');
}else{
console.info('Manifest was already there');
}
}catch(e){
console.error('Could not write the manifest file. Possibly due to a permission issue.\n', e.message);
}
console.info('Don\'t forget to link your manifest in your index.html file:\n' +
' <link rel="manifest" href="/webapp-manifest.json">\n <meta name="theme-color" content="#color">');
console.info(' 6 ... your are good to go, sir!\n\n ()_()\n (ᵔᴥᵔ)\n\nStart your HTTP server at ' + dswPath + '\n');
// write a temporary file with the combination of both settings and lib files

@@ -60,0 +76,0 @@ //console.info('1) Writing temporary file');

{
"name": "dsw",
"version": "1.1.0",
"version": "1.2.0",
"description": "Dynamic Service Worker, offline Progressive Web Apps much easier",

@@ -13,3 +13,3 @@ "bin": {

"test": "echo ':: Running tests:' && mocha tests/ --compilers js:babel-core/register",
"lint": "echo ':: Linting the source files:' && eslint src/* && echo 'Done linting'",
"lint": "echo ':: Linting the source files:' && eslint --ignore-pattern manifest-model.json --quiet src/** && echo 'Done linting'",
"docs": "echo ':: Generating documentation:' && docco -m -o docs/ docs/config-example.js",

@@ -16,0 +16,0 @@ "build": "browserify src/main.js -o dsw.js -t [ babelify --presets [ es2015 ] ] && npm run docs && echo 'Done building'",

@@ -1,2 +0,2 @@

const PWASettings = {"dswVersion":"2.20.1","applyImmediately":true,"appShell":[],"dswRules":{"moved-pages":{"match":{"path":"/old-site/(.*)"},"apply":{"redirect":"/redirected.html?$1"}},"imageNotFound":{"match":{"status":[404,500],"extension":["jpg","gif","png","jpeg","webp"]},"apply":{"fetch":"/images/public/404.jpg"}},"redirectOlderPage":{"match":{"path":"/legacy-images/.*"},"apply":{"fetch":"/images/public/gizmo.jpg"}},"pageNotFound":{"match":{"status":[404]},"apply":{"fetch":"/404.html"}},"imageNotCached":{"match":{"path":"/images/not-cached"},"apply":{"cache":false}},"images":{"match":{"extension":["jpg","gif","png","jpeg","webp"]},"apply":{"cache":{"name":"cachedImages","version":"1"}}},"statics":{"match":{"extension":["js","css"]},"apply":{"cache":{"name":"static-files","version":"1"}}},"static-html":{"match":{"extension":["html"]},"apply":{"cache":{"name":"static-html-files","version":"1"}}},"userData":{"match":{"path":"/api/user/.*"},"options":{"credentials":"same-origin"},"apply":{"indexedDB":{"name":"userData","version":"1","indexes":["name"]}}},"updates":{"match":{"path":"/api/updates/"},"keepItWarm":true,"apply":{"indexedDB":{"name":"shownUpdates","version":"1"}}},"articles":{"match":{"path":"/api/updates/"},"apply":{"cache":{"name":"cachedArticles","version":"1"}}},"events":{"match":{"path":"/api/events/"},"apply":{"indexedDB":{"name":"eventsList","version":"1"}}},"lineup":{"match":{"path":"/api/events/(.*)/"},"apply":{"indexedDB":{"name":"eventLineup-$1","version":"1"}}}}};
const PWASettings = {"dswVersion":"2.20.1","applyImmediately":true,"appShell":[],"enforceSSL":false,"dswRules":{"moved-pages":{"match":{"path":"/old-site/(.*)"},"apply":{"redirect":"/redirected.html?$1"}},"imageNotFound":{"match":{"status":[404,500],"extension":["jpg","gif","png","jpeg","webp"]},"apply":{"fetch":"/images/public/404.jpg"}},"redirectOlderPage":{"match":{"path":"/legacy-images/.*"},"apply":{"fetch":"/images/public/gizmo.jpg"}},"pageNotFound":{"match":{"status":[404]},"apply":{"fetch":"/404.html"}},"imageNotCached":{"match":{"path":"/images/not-cached"},"apply":{"cache":false}},"images":{"match":{"extension":["jpg","gif","png","jpeg","webp"]},"apply":{"cache":{"name":"cachedImages","version":"1"}}},"statics":{"match":{"extension":["js","css"]},"apply":{"cache":{"name":"static-files","version":"1"}}},"static-html":{"match":{"extension":["html"]},"apply":{"cache":{"name":"static-html-files","version":"1"}}},"userData":{"match":{"path":"/api/user/.*"},"options":{"credentials":"same-origin"},"apply":{"indexedDB":{"name":"userData","version":"1","indexes":["name"]}}},"updates":{"match":{"path":"/api/updates/"},"keepItWarm":true,"apply":{"indexedDB":{"name":"shownUpdates","version":"1"}}},"articles":{"match":{"path":"/api/updates/"},"apply":{"cache":{"name":"cachedArticles","version":"1"}}},"events":{"match":{"path":"/api/events/"},"apply":{"indexedDB":{"name":"eventsList","version":"1"}}},"lineup":{"match":{"path":"/api/events/(.*)/"},"apply":{"indexedDB":{"name":"eventLineup-$1","version":"1"}}}}};
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

@@ -162,2 +162,6 @@ "use strict";

(function () {
var DEFAULT_CACHE_NAME = 'defaultDSWCached';
var DEFAULT_CACHE_VERSION = PWASettings.dswVersion || '1';
var treatBadPage = function treatBadPage(response, pathName, event) {

@@ -179,5 +183,2 @@ var result = void 0;

var DEFAULT_CACHE_NAME = 'defaultDSWCached';
var DEFAULT_CACHE_VERSION = PWASettings.dswVersion || '1';
var cacheManager = {

@@ -494,4 +495,11 @@ add: function add(req) {

var url = new URL(event.request.url);
var pathName = new URL(url).pathname;
var pathName = url.pathname;
// in case we want to enforce https
if (PWASettings.enforceSSL) {
if (url.protocol != 'https:' && url.hostname != 'localhost') {
event.respondWith(Response.redirect(event.request.url.replace('http:', 'https:'), 302));
}
}
var i = 0,

@@ -498,0 +506,0 @@ l = (DSWManager.rules['*'] || []).length;

@@ -5,2 +5,3 @@ {

"appShell": [],
"enforceSSL": false,
"dswRules": {

@@ -7,0 +8,0 @@ "moved-pages": {

@@ -358,4 +358,12 @@ // TODO: should pre-cache or cache in the first load, some of the page's already sources (like css, js or images), or tell the user it supports offline usage, only in the next reload

const url = new URL(event.request.url);
const pathName = (new URL(url)).pathname;
const pathName = url.pathname;
// in case we want to enforce https
if (PWASettings.enforceSSL) {
if (url.protocol != 'https:' && url.hostname != 'localhost') {
event.respondWith(Response.redirect(
event.request.url.replace('http:', 'https:'), 302));
}
}
let i = 0,

@@ -362,0 +370,0 @@ l = (DSWManager.rules['*'] || []).length;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc