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

@segment/loosely-validate-event

Package Overview
Dependencies
Maintainers
60
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@segment/loosely-validate-event - npm Package Compare versions

Comparing version 1.1.2 to 2.0.0

LICENSE

7

index.js

@@ -5,2 +5,5 @@ var type = require('component-type')

// Segment messages can be a maximum of 32kb.
var MAX_SIZE = 32 << 10
module.exports = looselyValidateEvent

@@ -109,2 +112,6 @@

assert(type(event) === 'object', 'You must pass a message object.')
var json = JSON.stringify(event)
// Strings are variable byte encoded, so json.length is not sufficient.
assert(Buffer.byteLength(json, 'utf8') < MAX_SIZE, 'Your message must be < 32kb.')
for (var key in genericValidationRules) {

@@ -111,0 +118,0 @@ var val = event[key]

2

package.json
{
"name": "@segment/loosely-validate-event",
"version": "1.1.2",
"version": "2.0.0",
"main": "index.js",

@@ -5,0 +5,0 @@ "scripts": {

@@ -259,1 +259,24 @@ var test = require('ava')

})
test('requires events to be < 32kb', t => {
t.throws(() => {
var event = {
type: 'track',
event: 'Did Something',
userId: 'banana',
properties: {}
}
for (var i = 0; i < 10000; i++) {
event.properties[i] = 'a'
}
validate(event)
}, 'Your message must be < 32kb.')
t.notThrows(() => {
validate({
type: 'track',
event: 'Did Something',
userId: 'banana'
})
})
})
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