Socket
Socket
Sign inDemoInstall

@ldapjs/asn1

Package Overview
Dependencies
Maintainers
4
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ldapjs/asn1 - npm Package Compare versions

Comparing version 2.0.0-rc.2 to 2.0.0-rc.3

lib/buffer-to-hex-dump.js

4

index.js

@@ -6,2 +6,3 @@ 'use strict'

const BerTypes = require('./lib/ber/types')
const bufferToHexDump = require('./lib/buffer-to-hex-dump')

@@ -11,3 +12,4 @@ module.exports = {

BerTypes,
BerWriter
BerWriter,
bufferToHexDump
}
'use strict'
const types = require('./types')
const bufferToHexDump = require('../buffer-to-hex-dump')

@@ -463,2 +464,14 @@ /**

}
/**
* @param {HexDumpParams} params The `buffer` parameter will be ignored.
*
* @see bufferToHexDump
*/
toHexDump (params) {
bufferToHexDump({
...params,
buffer: this.buffer
})
}
}

@@ -465,0 +478,0 @@

'use strict'
const tap = require('tap')
const { Writable } = require('stream')
const BerReader = require('./reader')

@@ -581,2 +582,31 @@

tap.test('toHexDump', t => {
t.test('dumps buffer', t => {
const reader = new BerReader(
Buffer.from([0x00, 0x01, 0x02, 0x03])
)
const expected = '00010203'
let found = ''
const destination = new Writable({
write (chunk, encoding, callback) {
found += chunk.toString()
callback()
}
})
destination.on('finish', () => {
t.equal(found, expected)
t.end()
})
reader.toHexDump({
destination,
closeDestination: true
})
})
t.end()
})
// Original test

@@ -583,0 +613,0 @@ tap.test('anonymous LDAPv3 bind', async t => {

'use strict'
const types = require('./types')
const bufferToHexDump = require('../buffer-to-hex-dump')

@@ -138,2 +139,14 @@ class BerWriter {

/**
* @param {HexDumpParams} params The `buffer` parameter will be ignored.
*
* @see bufferToHexDump
*/
toHexDump (params) {
bufferToHexDump({
...params,
buffer: this.buffer
})
}
/**
* Write a boolean TLV to the buffer.

@@ -140,0 +153,0 @@ *

'use strict'
const tap = require('tap')
const { Writable } = require('stream')
const BerWriter = require('./writer')

@@ -62,23 +63,2 @@

tap.test('startSequence', t => {
t.test('throws if tag not a number', async t => {
const writer = new BerWriter()
t.throws(
() => writer.startSequence('30'),
Error('tag must be a Number')
)
})
t.test('starts a sequence', async t => {
const writer = new BerWriter({ size: 1 })
writer.startSequence()
t.equal(writer.size, 8)
const expected = Buffer.from([0x30, 0x00, 0x00, 0x00])
t.equal(Buffer.compare(writer.buffer, expected), 0)
})
t.end()
})
tap.test('endSequence', t => {

@@ -167,2 +147,51 @@ t.test('ends a sequence', async t => {

tap.test('startSequence', t => {
t.test('throws if tag not a number', async t => {
const writer = new BerWriter()
t.throws(
() => writer.startSequence('30'),
Error('tag must be a Number')
)
})
t.test('starts a sequence', async t => {
const writer = new BerWriter({ size: 1 })
writer.startSequence()
t.equal(writer.size, 8)
const expected = Buffer.from([0x30, 0x00, 0x00, 0x00])
t.equal(Buffer.compare(writer.buffer, expected), 0)
})
t.end()
})
tap.test('toHexDump', t => {
t.test('dumps buffer', t => {
const writer = new BerWriter()
writer.appendBuffer(Buffer.from([0x00, 0x01, 0x02, 0x03]))
const expected = '00010203'
let found = ''
const destination = new Writable({
write (chunk, encoding, callback) {
found += chunk.toString()
callback()
}
})
destination.on('finish', () => {
t.equal(found, expected)
t.end()
})
writer.toHexDump({
destination,
closeDestination: true
})
})
t.end()
})
tap.test('writeBoolean', t => {

@@ -169,0 +198,0 @@ t.test('throws if input not a boolean', async t => {

@@ -11,3 +11,3 @@ {

"description": "Contains parsers and serializers for ASN.1 (currently BER only)",
"version": "2.0.0-rc.2",
"version": "2.0.0-rc.3",
"repository": {

@@ -14,0 +14,0 @@ "type": "git",

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