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

browser-module-sandbox

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browser-module-sandbox - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

69

index.js

@@ -6,2 +6,3 @@ var inherits = require('inherits')

var detective = require('detective')
var createCache = require('browser-module-cache')

@@ -24,2 +25,3 @@ module.exports = function(opts) {

"</style>"
this.cache = createCache()
}

@@ -33,19 +35,10 @@

var body = {
"options": {
"debug": true
},
"dependencies": {}
}
modules.map(function(module) {
var version = preferredVersions[module] || 'latest'
body.dependencies[module] = version
})
self.emit('bundleStart')
if (modules.length === 0) return makeIframe(entry)
request({method: "POST", body: body, url: this.cdn + '/multi', json: true}, function(err, resp, json) {
if (modules.length === 0) return makeIframe()
var allBundles = ''
var packages = []
self.cache.get(function(err, cached) {
if (err) {

@@ -55,5 +48,33 @@ self.emit('bundleEnd')

}
var allBundles = ''
var packages = []
var download = []
modules.forEach(function(module) {
if (cached[module]) {
allBundles += cached[module]['bundle']
packages.push(cached[module]['package'])
} else {
download.push(module)
}
})
if (download.length === 0) return makeIframe(allBundles)
var body = {
"options": {
"debug": true
},
"dependencies": {}
}
download.map(function(module) {
var version = preferredVersions[module] || 'latest'
body.dependencies[module] = version
})
request({method: "POST", body: body, url: self.cdn + '/multi', json: true}, downloadedModules)
})
function downloadedModules(err, resp, json) {
if (err) {
self.emit('bundleEnd')
return err
}
Object.keys(json).map(function(module) {

@@ -63,9 +84,11 @@ allBundles += json[module]['bundle']

})
self.emit('modules', packages)
makeIframe(allBundles + entry)
})
self.cache.put(json, function() {
self.emit('modules', packages)
makeIframe(allBundles)
})
}
function makeIframe(script) {
script = script + entry
// setTimeout is because iframes report inaccurate window.innerWidth/innerHeight, even after DOMContentLoaded!

@@ -72,0 +95,0 @@ var body = self.iframeBody +

{
"name": "browser-module-sandbox",
"version": "1.2.1",
"version": "1.3.0",
"description": "uses browserify-cdn to run node code in an iframe",

@@ -13,3 +13,4 @@ "repository": {

"inherits": "1.0.0",
"detective": "~2.1.2"
"detective": "~2.1.2",
"browser-module-cache": "0.1.1"
},

@@ -16,0 +17,0 @@ "engines": {

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