Socket
Socket
Sign inDemoInstall

asn1.js

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asn1.js - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

lib/asn1/base/error.js

4

lib/asn1/api.js

@@ -38,7 +38,7 @@ var asn1 = require('../asn1');

Entity.prototype.encode = function encode(data, enc) {
Entity.prototype.encode = function encode(data, enc, /* internal */ path) {
// Lazily create encoder
if (!this.encoders.hasOwnProperty(enc))
this.encoders[enc] = this._createNamed(asn1.encoders[enc]);
return this.encoders[enc].encode(data);
return this.encoders[enc].encode(data, path);
};
var base = exports;
base.EncoderError = require('./error').EncoderError;
base.DecoderBuffer = require('./buffer').DecoderBuffer;
base.EncoderBuffer = require('./buffer').EncoderBuffer;
base.Node = require('./node');
var assert = require('assert');
var EncoderBuffer = require('../base').EncoderBuffer;
var EncoderError = require('../base').EncoderError;

@@ -368,3 +369,3 @@ // Supported tags

if (state.parent === null)
return state.children[0]._encode(data, '');
return state.children[0]._encode(data, path || '');

@@ -390,8 +391,14 @@ var result = null;

content = state.children.map(function(child) {
assert(child._baseState.key, 'Child should have a key');
var newpath = path + '.' + child._baseState.key;
assert(child._baseState.key !== null, 'Child should have a key');
// Maintain path for error reporting purposes
var newpath = path ? path + '.' + child._baseState.key :
child._baseState.key;
try {
return child._encode(data[child._baseState.key], newpath);
} catch (e) {
throw new Error('Failed to encode: ' + newpath + '\n' + e.stack);
if (e instanceof EncoderError)
throw e;
else
throw new EncoderError(newpath, e);
}

@@ -410,6 +417,6 @@ }, this).filter(function(child) {

content = new EncoderBuffer(data.map(function(item) {
return this._use(state.args[0], item);
return this._use(state.args[0], item, path);
}, this));
} else if (state.use !== null) {
result = this._use(state.use, data);
result = this._use(state.use, data, path);
} else {

@@ -416,0 +423,0 @@ content = this._encodePrimitive(state.tag, data);

@@ -22,4 +22,4 @@ var assert = require('assert');

DEREncoder.prototype.encode = function encode(data) {
return this.tree._encode(data).join();
DEREncoder.prototype.encode = function encode(data, path) {
return this.tree._encode(data, path).join();
};

@@ -81,3 +81,5 @@

assert(Array.isArray(id));
assert(Array.isArray(id),
'objid() should be either array or string, got: ' +
JSON.stringify(id));
if (!relative) {

@@ -153,3 +155,4 @@ assert(id[1] < 40, 'Second objid identifier OOB');

assert(values, 'String int or enum given, but no values map');
assert(values.hasOwnProperty(num), 'Values map doesn\'t contain number');
assert(values.hasOwnProperty(num),
'Values map doesn\'t contain: ' + JSON.stringify(num));
num = values[num];

@@ -178,4 +181,4 @@ }

DERNode.prototype._use = function use(encoder, data) {
return encoder.encode(data, 'der');
DERNode.prototype._use = function use(encoder, data, path) {
return encoder.encode(data, 'der', path);
};

@@ -182,0 +185,0 @@

{
"name": "asn1.js",
"version": "0.1.2",
"version": "0.1.3",
"description": "ASN.1 encoder and decoder",

@@ -5,0 +5,0 @@ "main": "lib/asn1.js",

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