Socket
Socket
Sign inDemoInstall

@lapo/asn1js

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lapo/asn1js - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

60

asn1.js

@@ -75,3 +75,3 @@ // ASN.1 JavaScript decoder

if (pos >= this.enc.length)
throw 'Requesting byte offset ' + pos + ' on a stream of length ' + this.enc.length;
throw new Error('Requesting byte offset ' + pos + ' on a stream of length ' + this.enc.length);
return (typeof this.enc == 'string') ? this.enc.charCodeAt(pos) : this.enc[pos];

@@ -82,7 +82,11 @@ }

}
hexDump(start, end, raw) {
/** Hexadecimal dump.
* @param type 'raw', 'byte' or 'dump' */
hexDump(start, end, type = 'dump') {
let s = '';
for (let i = start; i < end; ++i) {
if (type == 'byte' && i > start)
s += ' ';
s += this.hexByte(this.get(i));
if (raw !== true)
if (type == 'dump')
switch (i & 0xF) {

@@ -195,3 +199,3 @@ case 0x7: s += ' '; break;

if (!m)
return 'Unrecognized time: ' + s;
throw new Error('Unrecognized time: ' + s);
if (shortYear) {

@@ -251,3 +255,3 @@ // to avoid querying the timer, use the fixed range [1970, 2069]

if (unusedBits > 7)
throw 'Invalid BitString with unusedBits=' + unusedBits;
throw new Error('Invalid BitString with unusedBits=' + unusedBits);
let lenBit = ((end - start - 1) << 3) - unusedBits,

@@ -375,3 +379,3 @@ s = '';

constructor(stream, header, length, tag, tagLen, sub) {
if (!(tag instanceof ASN1Tag)) throw 'Invalid tag value.';
if (!(tag instanceof ASN1Tag)) throw new Error('Invalid tag value.');
this.stream = stream;

@@ -493,3 +497,12 @@ this.header = header;

if (indent === undefined) indent = '';
let s = indent + this.typeName() + ' @' + this.stream.pos;
let s = indent;
if (this.def) {
if (this.def.id)
s += this.def.id + ' ';
if (this.def.name && this.def.name != this.typeName().replace(/_/g, ' '))
s+= this.def.name + ' ';
if (this.def.mismatch)
s += '[?] ';
}
s += this.typeName() + ' @' + this.stream.pos;
if (this.length >= 0)

@@ -526,5 +539,8 @@ s += '+';

}
toHexString() {
return this.stream.hexDump(this.posStart(), this.posEnd(), true);
/** Hexadecimal dump of the node.
* @param type 'raw', 'byte' or 'dump' */
toHexString(type = 'raw') {
return this.stream.hexDump(this.posStart(), this.posEnd(), type);
}
/** Base64 dump of the node. */
toB64String() {

@@ -541,3 +557,3 @@ return this.stream.b64Dump(this.posStart(), this.posEnd());

if (len > 6) // no reason to use Int10, as it would be a huge buffer anyways
throw 'Length over 48 bits not supported at position ' + (stream.pos - 1);
throw new Error('Length over 48 bits not supported at position ' + (stream.pos - 1));
buf = 0;

@@ -550,3 +566,3 @@ for (let i = 0; i < len; ++i)

if (!(type == ASN1 || type.prototype instanceof ASN1))
throw 'Must pass a class that extends ASN1';
throw new Error('Must pass a class that extends ASN1');
if (!(stream instanceof Stream))

@@ -567,7 +583,7 @@ stream = new Stream(stream, offset || 0);

if (end > stream.enc.length)
throw 'Container at offset ' + start + ' has a length of ' + len + ', which is past the end of the stream';
throw new Error('Container at offset ' + start + ' has a length of ' + len + ', which is past the end of the stream');
while (stream.pos < end)
sub[sub.length] = type.decode(stream);
if (stream.pos != end)
throw 'Content size is not correct for container at offset ' + start;
throw new Error('Content size is not correct for container at offset ' + start);
} else {

@@ -584,3 +600,3 @@ // undefined length

} catch (e) {
throw 'Exception while decoding undefined length content at offset ' + start + ': ' + e;
throw new Error('Exception while decoding undefined length content at offset ' + start + ': ' + e);
}

@@ -597,7 +613,13 @@ }

if (stream.get() != 0)
throw 'BIT STRINGs with unused bits cannot encapsulate.';
throw new Error('BIT STRINGs with unused bits cannot encapsulate.');
getSub();
for (let i = 0; i < sub.length; ++i)
if (sub[i].tag.isEOC())
throw 'EOC is not supposed to be actual content.';
for (let s of sub) {
if (s.tag.isEOC())
throw new Error('EOC is not supposed to be actual content.');
try {
s.content();
} catch (e) {
throw new Error('Unable to parse content: ' + e);
}
}
} catch (e) {

@@ -611,3 +633,3 @@ // but silently ignore when they don't

if (len === null)
throw "We can't skip over an invalid tag with undefined length at offset " + start;
throw new Error("We can't skip over an invalid tag with undefined length at offset " + start);
stream.pos = start + Math.abs(len);

@@ -614,0 +636,0 @@ }

{
"name": "@lapo/asn1js",
"version": "2.0.1",
"version": "2.0.2",
"description": "Generic ASN.1 parser/decoder that can decode any valid ASN.1 DER or BER structures.",

@@ -18,6 +18,7 @@ "type": "module",

"scripts": {
"lint": "npx eslint asn1.js base64.js hex.js int10.js oids.js tags.js index.js parseRFC.js dumpASN1.js",
"lint": "npx eslint asn1.js base64.js hex.js int10.js oids.js tags.js context.js index.js parseRFC.js dumpASN1.js test.js testDefs.js",
"lint-action": "npx @action-validator/cli .github/workflows/node.js.yml",
"serve": "echo 'Connect to http://localhost:3000/' ; npx statik --port 3000 .",
"test": "node test"
"test": "node test",
"testdefs": "node testDefs"
},

@@ -85,2 +86,7 @@ "engines": {

}
}, {
"files": [ "testDefs.js" ],
"parserOptions": {
"ecmaVersion": 2022
}
}

@@ -87,0 +93,0 @@ ]

@@ -65,3 +65,3 @@ asn1js

- Relative OID support added by [Mistial Developer](https://github.com/mistial-dev)
- dark mode support added by [Oliver Burgmaier](https://github.com/olibu/)
- dark mode and other UI improvements by [Oliver Burgmaier](https://github.com/olibu/)
- patches by [Nicolai Søborg](https://github.com/NicolaiSoeborg)

@@ -68,0 +68,0 @@

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