Socket
Socket
Sign inDemoInstall

assertions-recorder

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

assertions-recorder - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

81

dist/umd/assertionsRecorder.js

@@ -49,13 +49,2 @@ (function (global, factory) {

/**
* Postmate logging function that enables/disables via config
* @param {Object} ...args Rest Arguments
*/
var log = function log() {
var _console;
return Postmate.debug ? (_console = console).log.apply(_console, arguments) : null;
}; // eslint-disable-line no-console
/**
* Takes a URL and returns the origin

@@ -124,7 +113,2 @@ * @param {String} url The full URL being requested

if (process.env.NODE_ENV !== 'production') {
log('Parent: Registering API');
log('Parent: Awaiting messages...');
}
this.listener = function (e) {

@@ -136,6 +120,2 @@ var _ref = ((e || {}).data || {}).value || {},

if (e.data.postmate === 'emit') {
if (process.env.NODE_ENV !== 'production') {
log("Parent: Received event emission: " + name);
}
if (name in _this.events) {

@@ -149,5 +129,3 @@ _this.events[name].call(_this, data);

if (process.env.NODE_ENV !== 'production') {
log('Parent: Awaiting event emissions from Child');
}
}

@@ -200,6 +178,2 @@

_proto.destroy = function destroy() {
if (process.env.NODE_ENV !== 'production') {
log('Parent: Destroying Postmate instance');
}
window.removeEventListener('message', this.listener, false);

@@ -227,14 +201,5 @@ this.frame.parentNode.removeChild(this.frame);

if (process.env.NODE_ENV !== 'production') {
log('Child: Registering API');
log('Child: Awaiting messages...');
}
this.child.addEventListener('message', function (e) {
if (!sanitize(e, _this3.parentOrigin)) return;
if (process.env.NODE_ENV !== 'production') {
log('Child: Received request', e.data);
}
var _e$data = e.data,

@@ -269,6 +234,2 @@ property = _e$data.property,

_proto2.emit = function emit(name, data) {
if (process.env.NODE_ENV !== 'production') {
log("Child: Emitting Event \"" + name + "\"", data);
}
this.parent.postMessage({

@@ -338,6 +299,2 @@ postmate: 'emit',

if (process.env.NODE_ENV !== 'production') {
log('Parent: Received handshake reply from Child');
}
_this4.parent.removeEventListener('message', reply, false);

@@ -347,6 +304,2 @@

if (process.env.NODE_ENV !== 'production') {
log('Parent: Saving Child origin', _this4.childOrigin);
}
return resolve(new ParentAPI(_this4));

@@ -357,6 +310,2 @@ } // Might need to remove since parent might be receiving different messages

if (process.env.NODE_ENV !== 'production') {
log('Parent: Invalid handshake reply');
}
return reject('Failed handshake');

@@ -370,8 +319,2 @@ };

if (process.env.NODE_ENV !== 'production') {
log("Parent: Sending handshake attempt " + attempt, {
childOrigin: childOrigin
});
}
_this4.child.postMessage({

@@ -399,8 +342,2 @@ postmate: 'handshake',

if (process.env.NODE_ENV !== 'production') {
log('Parent: Loading frame', {
url: url
});
}
_this4.frame.src = url;

@@ -458,12 +395,4 @@ });

if (e.data.postmate === 'handshake') {
if (process.env.NODE_ENV !== 'production') {
log('Child: Received handshake from Parent');
}
_this5.child.removeEventListener('message', shake, false);
if (process.env.NODE_ENV !== 'production') {
log('Child: Sending handshake reply to Parent');
}
e.source.postMessage({

@@ -486,11 +415,5 @@ postmate: 'handshake-reply',

if (process.env.NODE_ENV !== 'production') {
log('Child: Inherited and extended model from Parent');
}
}
if (process.env.NODE_ENV !== 'production') {
log('Child: Saving Parent origin', _this5.parentOrigin);
}
return resolve(new ChildAPI(_this5));

@@ -497,0 +420,0 @@ }

2

dist/umd/assertionsRecorder.min.js

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("optimal-select")):"function"==typeof define&&define.amd?define(["optimal-select"],t):t(e.optimalSelect)}(this,function(n){"use strict";var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c="application/x-postmate-v1+json",d=Object.prototype.hasOwnProperty,r=0,p=function(){var e;return m.debug?(e=console).log.apply(e,arguments):null},l=function(e,t){return e.origin===t&&("object"===i(e.data)&&("postmate"in e.data&&(e.data.type===c&&!!{"handshake-reply":1,call:1,emit:1,reply:1,request:1}[e.data.postmate])))},h=function(){function e(e){var o=this;this.parent=e.parent,this.frame=e.frame,this.child=e.child,this.childOrigin=e.childOrigin,this.events={},"production"!==process.env.NODE_ENV&&(p("Parent: Registering API"),p("Parent: Awaiting messages...")),this.listener=function(e){var t=((e||{}).data||{}).value||{},n=t.data,i=t.name;"emit"===e.data.postmate&&("production"!==process.env.NODE_ENV&&p("Parent: Received event emission: "+i),i in o.events&&o.events[i].call(o,n))},this.parent.addEventListener("message",this.listener,!1),"production"!==process.env.NODE_ENV&&p("Parent: Awaiting event emissions from Child")}var t=e.prototype;return t.get=function(e){var o=this;return new m.Promise(function(n){var i=++r;o.parent.addEventListener("message",function e(t){t.data.uid===i&&"reply"===t.data.postmate&&(o.parent.removeEventListener("message",e,!1),n(t.data.value))},!1),o.child.postMessage({postmate:"request",type:c,property:e,uid:i},o.childOrigin)})},t.call=function(e,t){this.child.postMessage({postmate:"call",type:c,property:e,data:t},this.childOrigin)},t.on=function(e,t){this.events[e]=t},t.destroy=function(){"production"!==process.env.NODE_ENV&&p("Parent: Destroying Postmate instance"),window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame)},e}(),u=function(){function e(e){var d=this;this.model=e.model,this.parent=e.parent,this.parentOrigin=e.parentOrigin,this.child=e.child,"production"!==process.env.NODE_ENV&&(p("Child: Registering API"),p("Child: Awaiting messages...")),this.child.addEventListener("message",function(t){if(l(t,d.parentOrigin)){"production"!==process.env.NODE_ENV&&p("Child: Received request",t.data);var e,n,i,o=t.data,r=o.property,a=o.uid,s=o.data;if("call"!==t.data.postmate)(e=d.model,n=r,i="function"==typeof e[n]?e[n]():e[n],m.Promise.resolve(i)).then(function(e){return t.source.postMessage({property:r,postmate:"reply",type:c,uid:a,value:e},t.origin)});else r in d.model&&"function"==typeof d.model[r]&&d.model[r].call(d,s)}})}return e.prototype.emit=function(e,t){"production"!==process.env.NODE_ENV&&p('Child: Emitting Event "'+e+'"',t),this.parent.postMessage({postmate:"emit",type:c,value:{name:e,data:t}},this.parentOrigin)},e}(),m=function(){function e(e){var t=void 0===e?userOptions:e,n=t.container,i=void 0===n?void 0!==i?i:document.body:n,o=t.model,r=t.url;return this.parent=window,this.frame=document.createElement("iframe"),i.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=o||{},this.sendHandshake(r)}return e.prototype.sendHandshake=function(o){var r,a=this,s=function(e){var t=document.createElement("a");t.href=e;var n=4<t.protocol.length?t.protocol:window.location.protocol,i=t.host.length?"80"===t.port||"443"===t.port?t.hostname:t.host:window.location.host;return t.origin||n+"//"+i}(o),d=0;return new e.Promise(function(n,i){a.parent.addEventListener("message",function e(t){return!!l(t,s)&&("handshake-reply"===t.data.postmate?(clearInterval(r),"production"!==process.env.NODE_ENV&&p("Parent: Received handshake reply from Child"),a.parent.removeEventListener("message",e,!1),a.childOrigin=t.origin,"production"!==process.env.NODE_ENV&&p("Parent: Saving Child origin",a.childOrigin),n(new h(a))):("production"!==process.env.NODE_ENV&&p("Parent: Invalid handshake reply"),i("Failed handshake")))},!1);var e=function(){d++,"production"!==process.env.NODE_ENV&&p("Parent: Sending handshake attempt "+d,{childOrigin:s}),a.child.postMessage({postmate:"handshake",type:c,model:a.model},s),5===d&&clearInterval(r)},t=function(){e(),r=setInterval(e,500)};a.frame.attachEvent?a.frame.attachEvent("onload",t):a.frame.onload=t,"production"!==process.env.NODE_ENV&&p("Parent: Loading frame",{url:o}),a.frame.src=o})},e}();m.debug=!1,m.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}(),m.Model=function(){function e(e){return this.child=window,this.model=e,this.parent=this.child.parent,this.sendHandshakeReply()}return e.prototype.sendHandshakeReply=function(){var s=this;return new m.Promise(function(r,a){s.child.addEventListener("message",function e(t){if(t.data.postmate){if("handshake"===t.data.postmate){"production"!==process.env.NODE_ENV&&p("Child: Received handshake from Parent"),s.child.removeEventListener("message",e,!1),"production"!==process.env.NODE_ENV&&p("Child: Sending handshake reply to Parent"),t.source.postMessage({postmate:"handshake-reply",type:c},t.origin),s.parentOrigin=t.origin;var n=t.data.model;if(n){for(var i=Object.keys(n),o=0;o<i.length;o++)d.call(n,i[o])&&(s.model[i[o]]=n[i[o]]);"production"!==process.env.NODE_ENV&&p("Child: Inherited and extended model from Parent")}return"production"!==process.env.NODE_ENV&&p("Child: Saving Parent origin",s.parentOrigin),r(new u(s))}return a("Handshake Reply Failed")}},!1)})},e}(),new m.Model({}).then(function(t){var e,i,o;["onclick","onfocus","onkeyup","onscroll"].forEach(function(e){/on/.test(e)&&window.addEventListener(e.slice(2),function(e){t.emit("child-dom-events",{type:e.type,path:n.select(e.target)})})}),e=analytics,i=t,o=e.track,e.track=function(){i.emit("child-dom-events",{type:"TRACK",path:"track call"});for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.call.apply(o,[this].concat(t))}})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("optimal-select")):"function"==typeof define&&define.amd?define(["optimal-select"],t):t(e.optimalSelect)}(this,function(n){"use strict";var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c="application/x-postmate-v1+json",d=Object.prototype.hasOwnProperty,a=0,l=function(e,t){return e.origin===t&&("object"===i(e.data)&&("postmate"in e.data&&(e.data.type===c&&!!{"handshake-reply":1,call:1,emit:1,reply:1,request:1}[e.data.postmate])))},p=function(){function e(e){var o=this;this.parent=e.parent,this.frame=e.frame,this.child=e.child,this.childOrigin=e.childOrigin,this.events={},this.listener=function(e){var t=((e||{}).data||{}).value||{},n=t.data,i=t.name;"emit"===e.data.postmate&&i in o.events&&o.events[i].call(o,n)},this.parent.addEventListener("message",this.listener,!1)}var t=e.prototype;return t.get=function(e){var o=this;return new m.Promise(function(n){var i=++a;o.parent.addEventListener("message",function e(t){t.data.uid===i&&"reply"===t.data.postmate&&(o.parent.removeEventListener("message",e,!1),n(t.data.value))},!1),o.child.postMessage({postmate:"request",type:c,property:e,uid:i},o.childOrigin)})},t.call=function(e,t){this.child.postMessage({postmate:"call",type:c,property:e,data:t},this.childOrigin)},t.on=function(e,t){this.events[e]=t},t.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame)},e}(),h=function(){function e(e){var d=this;this.model=e.model,this.parent=e.parent,this.parentOrigin=e.parentOrigin,this.child=e.child,this.child.addEventListener("message",function(t){if(l(t,d.parentOrigin)){var e,n,i,o=t.data,a=o.property,r=o.uid,s=o.data;if("call"!==t.data.postmate)(e=d.model,n=a,i="function"==typeof e[n]?e[n]():e[n],m.Promise.resolve(i)).then(function(e){return t.source.postMessage({property:a,postmate:"reply",type:c,uid:r,value:e},t.origin)});else a in d.model&&"function"==typeof d.model[a]&&d.model[a].call(d,s)}})}return e.prototype.emit=function(e,t){this.parent.postMessage({postmate:"emit",type:c,value:{name:e,data:t}},this.parentOrigin)},e}(),m=function(){function e(e){var t=void 0===e?userOptions:e,n=t.container,i=void 0===n?void 0!==i?i:document.body:n,o=t.model,a=t.url;return this.parent=window,this.frame=document.createElement("iframe"),i.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=o||{},this.sendHandshake(a)}return e.prototype.sendHandshake=function(o){var a,r=this,s=function(e){var t=document.createElement("a");t.href=e;var n=4<t.protocol.length?t.protocol:window.location.protocol,i=t.host.length?"80"===t.port||"443"===t.port?t.hostname:t.host:window.location.host;return t.origin||n+"//"+i}(o),d=0;return new e.Promise(function(n,i){r.parent.addEventListener("message",function e(t){return!!l(t,s)&&("handshake-reply"===t.data.postmate?(clearInterval(a),r.parent.removeEventListener("message",e,!1),r.childOrigin=t.origin,n(new p(r))):i("Failed handshake"))},!1);var e=function(){d++,r.child.postMessage({postmate:"handshake",type:c,model:r.model},s),5===d&&clearInterval(a)},t=function(){e(),a=setInterval(e,500)};r.frame.attachEvent?r.frame.attachEvent("onload",t):r.frame.onload=t,r.frame.src=o})},e}();m.debug=!1,m.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}(),m.Model=function(){function e(e){return this.child=window,this.model=e,this.parent=this.child.parent,this.sendHandshakeReply()}return e.prototype.sendHandshakeReply=function(){var s=this;return new m.Promise(function(a,r){s.child.addEventListener("message",function e(t){if(t.data.postmate){if("handshake"===t.data.postmate){s.child.removeEventListener("message",e,!1),t.source.postMessage({postmate:"handshake-reply",type:c},t.origin),s.parentOrigin=t.origin;var n=t.data.model;if(n)for(var i=Object.keys(n),o=0;o<i.length;o++)d.call(n,i[o])&&(s.model[i[o]]=n[i[o]]);return a(new h(s))}return r("Handshake Reply Failed")}},!1)})},e}(),new m.Model({}).then(function(t){var e,i,o;["onclick","onfocus","onkeyup","onscroll"].forEach(function(e){/on/.test(e)&&window.addEventListener(e.slice(2),function(e){t.emit("child-dom-events",{type:e.type,path:n.select(e.target)})})}),e=analytics,i=t,o=e.track,e.track=function(){i.emit("child-dom-events",{type:"TRACK",path:"track call"});for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.call.apply(o,[this].concat(t))}})});
{
"name": "assertions-recorder",
"version": "0.0.1",
"description": "this is a description",
"version": "0.0.2",
"description": "a module for publishing all dom and track events to the assertions recorder application",
"main": "dist/cjs/index.js",

@@ -56,3 +56,4 @@ "browser": "dist/umd/assertionsRecorder.js",

"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-uglify": "^2.0.1"
"rollup-plugin-uglify": "^2.0.1",
"rollup-plugin-replace": "^2.0.0"
},

@@ -64,3 +65,6 @@ "dependencies": {

"postmate": "^1.4.2"
},
"env": {
"browser": true
}
}

@@ -10,50 +10,6 @@ # assertions-recorder

> this is a description
> a module for publishing all dom and track events to the assertions recorder application
### Usage
```js
import assertionsRecorder from 'assertions-recorder';
```
### Installation
Install via [yarn](https://github.com/yarnpkg/yarn)
yarn add assertions-recorder (--dev)
or npm
npm install assertions-recorder (--save-dev)
### configuration
You can pass in extra options as a configuration object (➕ required, ➖ optional, ✏️ default).
```js
import assertionsRecorder from 'assertions-recorder';
```
➖ **property** ( type ) ` ✏️ default `
<br/> 📝 description
<br/> ❗️ warning
<br/> ℹ️ info
<br/> 💡 example
### methods
#### #name
```js
assertionsRecorder
```
### Examples
See [`example`](example/script.js) folder or the [runkit](https://runkit.com//assertions-recorder) example.
### Builds

@@ -67,13 +23,1 @@

The `assertions-recorder` package includes precompiled production and development [UMD](https://github.com/umdjs/umd) builds in the [`dist/umd` folder](https://unpkg.com/assertions-recorder/dist/umd/). They can be used directly without a bundler and are thus compatible with many popular JavaScript module loaders and environments. You can drop a UMD build as a [`<script>` tag](https://unpkg.com/assertions-recorder) on your page. The UMD builds make `assertions-recorder` available as a `window.assertionsRecorder` global variable.
### License
The code is available under the [MIT](LICENSE) license.
### Contributing
We are open to contributions, see [CONTRIBUTING.md](CONTRIBUTING.md) for more info.
### Misc
This module was created using [generator-module-boilerplate](https://github.com/duivvv/generator-module-boilerplate).
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