@segment/loosely-validate-event
Advanced tools
Comparing version 1.1.2 to 2.0.0
@@ -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] |
{ | ||
"name": "@segment/loosely-validate-event", | ||
"version": "1.1.2", | ||
"version": "2.0.0", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
23
test.js
@@ -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' | ||
}) | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
133431
0
353
1