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

asn1.js

Package Overview
Dependencies
Maintainers
2
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 4.3.1 to 4.4.0

25

lib/asn1/base/node.js
var Reporter = require('../base').Reporter;
var EncoderBuffer = require('../base').EncoderBuffer;
var DecoderBuffer = require('../base').DecoderBuffer;
var assert = require('minimalistic-assert');

@@ -15,3 +16,3 @@

'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice',
'any'
'any', 'contains'
].concat(tags);

@@ -52,2 +53,3 @@

state.implicit = null;
state.contains = null;

@@ -257,2 +259,11 @@ // Should create new instance on each method

Node.prototype.contains = function contains(item) {
var state = this._baseState;
assert(state.use === null);
state.contains = item;
return this;
};
//

@@ -360,2 +371,8 @@ // Decoding

}
// Decode contained/encoded by schema, only in bit or octet strings
if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) {
var data = new DecoderBuffer(result);
result = this._getUse(state.contains, input._reporterState.obj)._decode(data);
}
}

@@ -504,2 +521,5 @@

result = this._encodeChoice(data, reporter);
} else if (state.contains) {
content = this._getUse(state.contains, parent)._encode(data, reporter);
primitive = true;
} else if (state.children) {

@@ -524,3 +544,2 @@ content = state.children.map(function(child) {

});
content = this._createEncoderBuffer(content);

@@ -617,2 +636,2 @@ } else {

return /^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(str);
};
};

2

package.json
{
"name": "asn1.js",
"version": "4.3.1",
"version": "4.4.0",
"description": "ASN.1 encoder and decoder",

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

@@ -93,2 +93,16 @@ var assert = require('assert');

}, '060a2a830e030a0101010202', 'yes');
it('should decode encapsulated models', function() {
var B = asn1.define('B', function() {
this.seq().obj(
this.key('nested').int()
);
});
var A = asn1.define('A', function() {
this.octstr().contains(B);
});
var out = A.decode(new Buffer('04053003020105', 'hex'), 'der');
assert.equal(out.nested.toString(10), '5');
});
});

@@ -103,2 +103,16 @@ var assert = require('assert');

}, 'Привет', '1e0c041f04400438043204350442');
it('should encode encapsulated models', function() {
var B = asn1.define('B', function() {
this.seq().obj(
this.key('nested').int()
);
});
var A = asn1.define('A', function() {
this.octstr().contains(B);
});
var out = A.encode({ nested: 5 }, 'der')
assert.equal(out.toString('hex'), '04053003020105');
});
});
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