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

sandblaster

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sandblaster - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

10

dist/sandblaster.js
/*!
* sandblaster
* A client-side JavaScript library to detect if your code is running inside of a sandboxed iframe... and, if desired, might just be able to change that fact!
* Copyright (c) 2014 James M. Greene
* Copyright (c) 2014-2015 James M. Greene
* Licensed MIT
* http://jamesmgreene.github.io/sandblaster/
* v1.0.2
* v1.1.0
*/

@@ -82,4 +82,6 @@

forms: null,
modals: null,
pointerLock: null,
popups: null,
popupsToEscapeSandbox: null,
sameOrigin: true,

@@ -98,4 +100,6 @@ scripts: true,

forms: allowanceList.indexOf("allow-forms") !== -1,
modals: allowanceList.indexOf("allow-modals") !== -1,
pointerLock: allowanceList.indexOf("allow-pointer-lock") !== -1,
popups: allowanceList.indexOf("allow-popups") !== -1,
popupsToEscapeSandbox: allowanceList.indexOf("allow-popups-to-escape-sandbox") !== -1,
sameOrigin: allowanceList.indexOf("allow-same-origin") !== -1,

@@ -286,4 +290,6 @@ scripts: allowanceList.indexOf("allow-scripts") !== -1,

forms: null,
modals: null,
pointerLock: null,
popups: null,
popupsToEscapeSandbox: null,
sameOrigin: null,

@@ -290,0 +296,0 @@ scripts: true,

6

dist/sandblaster.min.js
/*!
* sandblaster
* A client-side JavaScript library to detect if your code is running inside of a sandboxed iframe... and, if desired, might just be able to change that fact!
* Copyright (c) 2014 James M. Greene
* Copyright (c) 2014-2015 James M. Greene
* Licensed MIT
* http://jamesmgreene.github.io/sandblaster/
* v1.0.2
* v1.1.0
*/
!function(a,b){"use strict";function c(a){return{name:a.name,message:a.message,stack:a.stack}}function d(a,b){return(a||[]).concat(b||[]).filter(function(a,b,c){return c.indexOf(a)===b})}function e(){var b=!a.opener,c=!!(a.top&&a!=a.top||a.parent&&a!=a.parent);return b&&c}function f(a){var b;try{b="object"==typeof a&&null!==a&&1===a.nodeType&&/^I?FRAME$/.test(a.nodeName||"")&&!!a.hasAttribute&&!!a.getAttribute&&!!a.setAttribute}catch(c){b=!1}return b}function g(b){var d;try{d=a.frameElement,f(d)||(d=null)}catch(e){d=null,"function"==typeof b&&b(c(e))}return d}function h(a){var b;try{b=document.domain||null}catch(d){b=null,"function"==typeof a&&a(c(d))}return b}function i(){return{forms:null,pointerLock:null,popups:null,sameOrigin:!0,scripts:!0,topNavigation:null}}function j(a){var b,c=null;return null===a?c=i():"string"==typeof a&&(b=a.replace(/^\s+|\s+$/g,"").toLowerCase().split(/\s+/),c={forms:-1!==b.indexOf("allow-forms"),pointerLock:-1!==b.indexOf("allow-pointer-lock"),popups:-1!==b.indexOf("allow-popups"),sameOrigin:-1!==b.indexOf("allow-same-origin"),scripts:-1!==b.indexOf("allow-scripts"),topNavigation:-1!==b.indexOf("allow-top-navigation")}),c}function k(a,b){var c,e,f,g,h=!1;if(a&&"object"==typeof a&&b&&"object"==typeof b)for(c=d(Object.keys(a),Object.keys(b)),h=!0,e=0,f=c.length;f>e;e++)if(g=c[e],!a.hasOwnProperty(g)||!b.hasOwnProperty(g)||a[g]!==b[g]){h=!1;break}return h}function l(a,c){var d,e,g,h,i={sandboxed:b,sandboxAllowances:b,unsandboxable:b,resandboxable:b,errors:[]};if(f(a)){try{i.sandboxed=a.hasAttribute("sandbox")}catch(l){i.sandboxed=null,"function"==typeof c&&c(l)}if(i.sandboxed)try{d=a.getAttribute("sandbox")||""}catch(l){d=null,"function"==typeof c&&c(l)}else null===i.sandboxed&&(d=null);if((null===d||"string"==typeof d)&&(i.sandboxAllowances=j(d)),i.sandboxed)try{a.removeAttribute("sandbox"),i.unsandboxable=!a.hasAttribute("sandbox")}catch(l){i.unsandboxable=!1,"function"==typeof c&&c(l)}if(i.unsandboxable&&"string"==typeof d)try{a.setAttribute("sandbox",d),e=a.hasAttribute("sandbox")}catch(l){e=!1,"function"==typeof c&&c(l)}if(e&&i.sandboxAllowances)try{g=a.getAttribute("sandbox")||""}catch(l){g=null,"function"==typeof c&&c(l)}else null===e&&(g=null);(null===g||"string"==typeof g)&&(g=j(g)),e&&(h=null,i.sandboxAllowances&&g&&(h=k(i.sandboxAllowances,g))),i.resandboxable=h}return i}function m(){var a=this;return a instanceof m?(a._initialState=a.detect(),void(a._unsandboxState=null)):new m}var n=Array.prototype.slice;m.prototype.detect=function(){var a,d,f,i={framed:!1,crossOrigin:null,sandboxed:null,sandboxAllowances:b,unsandboxable:b,resandboxable:b,sandboxable:b,errors:[]},j=function(a){i.errors.push(c(a))},k=function(a){d=c(a),i.errors.push(d)};try{i.framed=e(),i.framed?(a=g(k),null!=a?(i.crossOrigin=!1,f=l(a,j),i.sandboxed=f.sandboxed,i.sandboxAllowances=f.sandboxAllowances,i.unsandboxable=f.unsandboxable,i.resandboxable=f.resandboxable):(i.crossOrigin=!0,i.sandboxed=null,i.sandboxAllowances={forms:null,pointerLock:null,popups:null,sameOrigin:null,scripts:!0,topNavigation:null},i.unsandboxable=!1,i.resandboxable=!1,null===h(j)?(i.sandboxed=!0,i.sandboxAllowances.sameOrigin=!1):d&&("SecurityError"!==d.name?i.crossOrigin=null:/(^|[\s\(\[@])sandbox(es|ed|ing|[\s\.,!\)\]@]|$)/.test(d.message.toLowerCase())&&(i.sandboxed=!0,i.sandboxAllowances.sameOrigin=!0))),i.sandboxable=i.resandboxable||i.framed===!0&&i.crossOrigin===!1&&(i.sandboxed===!1||i.sandboxAllowances.sameOrigin)||!1):(i.crossOrigin=b,i.sandboxed=b,i.errors=b)}catch(m){j(m)}return i},m.prototype.unsandbox=function(){var a,b,c=!1,d=this,e=d._initialState;if(e.framed===!1)c=!0;else if(e.crossOrigin===!1&&(a=d.detect(),c=a.sandboxed===!1,a.sandboxed&&a.unsandboxable&&(d._unsandboxState=a,b=g(function(){c=!1}))))try{b.removeAttribute("sandbox"),c=!b.hasAttribute("sandbox")}catch(f){c=!1}return c},m.prototype.resandbox=function(){var a=!1,b=this;return null!=b._unsandboxState&&(a=b.sandbox(b._unsandboxState.sandboxAllowances)),a===!0&&(b._unsandboxState=null),a},m.prototype.sandbox=function(a){var b,c,e,f,i,j,k,l=!1,m=this,n=m._initialState,o=[];if(a&&"object"==typeof a&&n.framed&&n.crossOrigin!==!1&&(e=m.detect(),(e.sandboxed===!1&&e.sandboxable||e.sandboxed&&e.unsandboxable)&&(f=e.sandboxAllowances,c=d(Object.keys(a),Object.keys(f||{})),c.forEach(function(b){(a[b]===!0||null==a[b]&&f&&f[b]===!0)&&o.push("allow-"+b.replace(/[A-Z]/g,"-$1").toLowerCase())}),o.length>0&&(j=g())))){i=-1===o.indexOf("allow-same-origin")||-1===o.indexOf("allow-scripts"),b=o.sort().join(" ");try{j.setAttribute("sandbox",b),l=i}catch(p){l=!1}if(j=g())try{k=(j.getAttribute("sandbox")||"").replace(/^\s+|\s+$/g,"").split(/\s+/).sort().join(" "),l=k===b||i&&(""===k||null===h())}catch(p){l=i}}return l},m.prototype.reload=function(){var a,b,c,d,e=!1,f=this,h=f._initialState;if(h.framed&&h.crossOrigin===!1&&(a=g()))try{a.parentNode&&a.parentNode.ownerDocument&&(b=n.call(a.attributes).map(function(a){return{name:a.name,value:a.value}}),c=a.parentNode.ownerDocument.createElement("iframe"),b.forEach(function(a){c.setAttribute(a.name,a.value)}),d=a.parentNode.replaceChild(c,a),e=a===d)}catch(i){e=!1}return e},a.sandblaster=new m}(window);
!function(a,b){"use strict";function c(a){return{name:a.name,message:a.message,stack:a.stack}}function d(a,b){return(a||[]).concat(b||[]).filter(function(a,b,c){return c.indexOf(a)===b})}function e(){var b=!a.opener,c=!!(a.top&&a!=a.top||a.parent&&a!=a.parent);return b&&c}function f(a){var b;try{b="object"==typeof a&&null!==a&&1===a.nodeType&&/^I?FRAME$/.test(a.nodeName||"")&&!!a.hasAttribute&&!!a.getAttribute&&!!a.setAttribute}catch(c){b=!1}return b}function g(b){var d;try{d=a.frameElement,f(d)||(d=null)}catch(e){d=null,"function"==typeof b&&b(c(e))}return d}function h(a){var b;try{b=document.domain||null}catch(d){b=null,"function"==typeof a&&a(c(d))}return b}function i(){return{forms:null,modals:null,pointerLock:null,popups:null,popupsToEscapeSandbox:null,sameOrigin:!0,scripts:!0,topNavigation:null}}function j(a){var b,c=null;return null===a?c=i():"string"==typeof a&&(b=a.replace(/^\s+|\s+$/g,"").toLowerCase().split(/\s+/),c={forms:-1!==b.indexOf("allow-forms"),modals:-1!==b.indexOf("allow-modals"),pointerLock:-1!==b.indexOf("allow-pointer-lock"),popups:-1!==b.indexOf("allow-popups"),popupsToEscapeSandbox:-1!==b.indexOf("allow-popups-to-escape-sandbox"),sameOrigin:-1!==b.indexOf("allow-same-origin"),scripts:-1!==b.indexOf("allow-scripts"),topNavigation:-1!==b.indexOf("allow-top-navigation")}),c}function k(a,b){var c,e,f,g,h=!1;if(a&&"object"==typeof a&&b&&"object"==typeof b)for(c=d(Object.keys(a),Object.keys(b)),h=!0,e=0,f=c.length;f>e;e++)if(g=c[e],!a.hasOwnProperty(g)||!b.hasOwnProperty(g)||a[g]!==b[g]){h=!1;break}return h}function l(a,c){var d,e,g,h,i={sandboxed:b,sandboxAllowances:b,unsandboxable:b,resandboxable:b,errors:[]};if(f(a)){try{i.sandboxed=a.hasAttribute("sandbox")}catch(l){i.sandboxed=null,"function"==typeof c&&c(l)}if(i.sandboxed)try{d=a.getAttribute("sandbox")||""}catch(l){d=null,"function"==typeof c&&c(l)}else null===i.sandboxed&&(d=null);if((null===d||"string"==typeof d)&&(i.sandboxAllowances=j(d)),i.sandboxed)try{a.removeAttribute("sandbox"),i.unsandboxable=!a.hasAttribute("sandbox")}catch(l){i.unsandboxable=!1,"function"==typeof c&&c(l)}if(i.unsandboxable&&"string"==typeof d)try{a.setAttribute("sandbox",d),e=a.hasAttribute("sandbox")}catch(l){e=!1,"function"==typeof c&&c(l)}if(e&&i.sandboxAllowances)try{g=a.getAttribute("sandbox")||""}catch(l){g=null,"function"==typeof c&&c(l)}else null===e&&(g=null);(null===g||"string"==typeof g)&&(g=j(g)),e&&(h=null,i.sandboxAllowances&&g&&(h=k(i.sandboxAllowances,g))),i.resandboxable=h}return i}function m(){var a=this;return a instanceof m?(a._initialState=a.detect(),void(a._unsandboxState=null)):new m}var n=Array.prototype.slice;m.prototype.detect=function(){var a,d,f,i={framed:!1,crossOrigin:null,sandboxed:null,sandboxAllowances:b,unsandboxable:b,resandboxable:b,sandboxable:b,errors:[]},j=function(a){i.errors.push(c(a))},k=function(a){d=c(a),i.errors.push(d)};try{i.framed=e(),i.framed?(a=g(k),null!=a?(i.crossOrigin=!1,f=l(a,j),i.sandboxed=f.sandboxed,i.sandboxAllowances=f.sandboxAllowances,i.unsandboxable=f.unsandboxable,i.resandboxable=f.resandboxable):(i.crossOrigin=!0,i.sandboxed=null,i.sandboxAllowances={forms:null,modals:null,pointerLock:null,popups:null,popupsToEscapeSandbox:null,sameOrigin:null,scripts:!0,topNavigation:null},i.unsandboxable=!1,i.resandboxable=!1,null===h(j)?(i.sandboxed=!0,i.sandboxAllowances.sameOrigin=!1):d&&("SecurityError"!==d.name?i.crossOrigin=null:/(^|[\s\(\[@])sandbox(es|ed|ing|[\s\.,!\)\]@]|$)/.test(d.message.toLowerCase())&&(i.sandboxed=!0,i.sandboxAllowances.sameOrigin=!0))),i.sandboxable=i.resandboxable||i.framed===!0&&i.crossOrigin===!1&&(i.sandboxed===!1||i.sandboxAllowances.sameOrigin)||!1):(i.crossOrigin=b,i.sandboxed=b,i.errors=b)}catch(m){j(m)}return i},m.prototype.unsandbox=function(){var a,b,c=!1,d=this,e=d._initialState;if(e.framed===!1)c=!0;else if(e.crossOrigin===!1&&(a=d.detect(),c=a.sandboxed===!1,a.sandboxed&&a.unsandboxable&&(d._unsandboxState=a,b=g(function(){c=!1}))))try{b.removeAttribute("sandbox"),c=!b.hasAttribute("sandbox")}catch(f){c=!1}return c},m.prototype.resandbox=function(){var a=!1,b=this;return null!=b._unsandboxState&&(a=b.sandbox(b._unsandboxState.sandboxAllowances)),a===!0&&(b._unsandboxState=null),a},m.prototype.sandbox=function(a){var b,c,e,f,i,j,k,l=!1,m=this,n=m._initialState,o=[];if(a&&"object"==typeof a&&n.framed&&n.crossOrigin!==!1&&(e=m.detect(),(e.sandboxed===!1&&e.sandboxable||e.sandboxed&&e.unsandboxable)&&(f=e.sandboxAllowances,c=d(Object.keys(a),Object.keys(f||{})),c.forEach(function(b){(a[b]===!0||null==a[b]&&f&&f[b]===!0)&&o.push("allow-"+b.replace(/[A-Z]/g,"-$1").toLowerCase())}),o.length>0&&(j=g())))){i=-1===o.indexOf("allow-same-origin")||-1===o.indexOf("allow-scripts"),b=o.sort().join(" ");try{j.setAttribute("sandbox",b),l=i}catch(p){l=!1}if(j=g())try{k=(j.getAttribute("sandbox")||"").replace(/^\s+|\s+$/g,"").split(/\s+/).sort().join(" "),l=k===b||i&&(""===k||null===h())}catch(p){l=i}}return l},m.prototype.reload=function(){var a,b,c,d,e=!1,f=this,h=f._initialState;if(h.framed&&h.crossOrigin===!1&&(a=g()))try{a.parentNode&&a.parentNode.ownerDocument&&(b=n.call(a.attributes).map(function(a){return{name:a.name,value:a.value}}),c=a.parentNode.ownerDocument.createElement("iframe"),b.forEach(function(a){c.setAttribute(a.name,a.value)}),d=a.parentNode.replaceChild(c,a),e=a===d)}catch(i){e=!1}return e},a.sandblaster=new m}(window);
//# sourceMappingURL=sandblaster.min.map
{
"name": "sandblaster",
"version": "1.0.2",
"version": "1.1.0",
"description": "A client-side JavaScript library to detect if your code is running inside of a sandboxed iframe... and, if desired, might just be able to change that fact!",

@@ -5,0 +5,0 @@ "keywords": [

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