Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Please update @ldapjs/asn1 dependency to 2.0.0 #3

Open
guimard opened this issue Jul 31, 2023 · 2 comments
Open

Please update @ldapjs/asn1 dependency to 2.0.0 #3

guimard opened this issue Jul 31, 2023 · 2 comments
Labels
good first issue Good for newcomers

Comments

@guimard
Copy link

guimard commented Jul 31, 2023

Hi,

@ldapjs/controls still uses previous version of @ldapjs/asn1. I tried the following patch, but it's not enough.

Best regards,

diff --git a/index.js b/ldapjs-controls/index.js
index 9f260b7..0b85eeb 100644
--- a/index.js
+++ b/index.js
@@ -1,6 +1,6 @@
 'use strict'
 
-const { Ber } = require('@ldapjs/asn1')
+const { BerTypes } = require('@ldapjs/asn1')
 
 const Control = require('./lib/control')
 const EntryChangeNotificationControl = require('./lib/controls/entry-change-notification-control')
@@ -32,10 +32,10 @@ module.exports = {
       /* istanbul ignore else */
       if (ber.offset < end) {
         /* istanbul ignore else */
-        if (ber.peek() === Ber.Boolean) { opts.criticality = ber.readBoolean() }
+        if (ber.peek() === BerTypes.Boolean) { opts.criticality = ber.readBoolean() }
       }
 
-      if (ber.offset < end) { opts.value = ber.readString(Ber.OctetString, true) }
+      if (ber.offset < end) { opts.value = ber.readString(BerTypes.OctetString, true) }
     }
 
     let control
diff --git a/lib/controls/paged-results-control.js b/ldapjs-controls/lib/controls/paged-results-control.js
index fe7dc5f..82fcf23 100644
--- a/lib/controls/paged-results-control.js
+++ b/lib/controls/paged-results-control.js
@@ -1,6 +1,6 @@
 'use strict'
 
-const { Ber, BerReader, BerWriter } = require('@ldapjs/asn1')
+const { BerTypes, BerReader, BerWriter } = require('@ldapjs/asn1')
 const isObject = require('../is-object')
 const hasOwn = require('../has-own')
 const Control = require('../control')
@@ -71,7 +71,7 @@ class PagedResultsControl extends Control {
     if (ber.readSequence()) {
       this._value = {}
       this._value.size = ber.readInt()
-      this._value.cookie = ber.readString(Ber.OctetString, true)
+      this._value.cookie = ber.readString(BerTypes.OctetString, true)
       // readString returns '' instead of a zero-length buffer
       if (!this._value.cookie) {
         this._value.cookie = Buffer.alloc(0)
@@ -84,14 +84,14 @@ class PagedResultsControl extends Control {
     writer.startSequence()
     writer.writeInt(this._value.size)
     if (this._value.cookie && this._value.cookie.length > 0) {
-      writer.writeBuffer(this._value.cookie, Ber.OctetString)
+      writer.writeBuffer(this._value.cookie, BerTypes.OctetString)
     } else {
       // writeBuffer rejects zero-length buffers
       writer.writeString('')
     }
     writer.endSequence()
 
-    ber.writeBuffer(writer.buffer, Ber.OctetString)
+    ber.writeBuffer(writer.buffer, BerTypes.OctetString)
     return ber
   }
 
diff --git a/lib/controls/server-side-sorting-request-control.js b/ldapjs-controls/lib/controls/server-side-sorting-request-control.js
index 878fa4f..a9e5fc3 100644
--- a/lib/controls/server-side-sorting-request-control.js
+++ b/lib/controls/server-side-sorting-request-control.js
@@ -1,6 +1,6 @@
 'use strict'
 
-const { Ber, BerReader, BerWriter } = require('@ldapjs/asn1')
+const { BerTypes, BerReader, BerWriter } = require('@ldapjs/asn1')
 const isObject = require('../is-object')
 const hasOwn = require('../has-own')
 const Control = require('../control')
@@ -84,14 +84,14 @@ class ServerSideSortingRequestControl extends Control {
 
       while (ber.readSequence(0x30)) {
         item = {}
-        item.attributeType = ber.readString(Ber.OctetString)
+        item.attributeType = ber.readString(BerTypes.OctetString)
         /* istanbul ignore else */
         if (ber.peek() === 0x80) {
           item.orderingRule = ber.readString(0x80)
         }
         /* istanbul ignore else */
         if (ber.peek() === 0x81) {
-          item.reverseOrder = (ber._readTag(0x81) !== 0)
+          item.reverseOrder = (ber.readTag(0x81) !== 0)
         }
         this.value.push(item)
       }
@@ -113,7 +113,7 @@ class ServerSideSortingRequestControl extends Control {
       writer.startSequence(0x30)
       /* istanbul ignore else */
       if (hasOwn(item, 'attributeType')) {
-        writer.writeString(item.attributeType, Ber.OctetString)
+        writer.writeString(item.attributeType, BerTypes.OctetString)
       }
       /* istanbul ignore else */
       if (hasOwn(item, 'orderingRule')) {
diff --git a/lib/controls/virtual-list-view-response-control.js b/ldapjs-controls/lib/controls/virtual-list-view-response-control.js
index f9b1efe..f2383d0 100644
--- a/lib/controls/virtual-list-view-response-control.js
+++ b/lib/controls/virtual-list-view-response-control.js
@@ -1,6 +1,6 @@
 'use strict'
 
-const { Ber, BerReader, BerWriter } = require('@ldapjs/asn1')
+const { BerTypes, BerReader, BerWriter } = require('@ldapjs/asn1')
 const isObject = require('../is-object')
 const hasOwn = require('../has-own')
 const Control = require('../control')
@@ -106,7 +106,7 @@ class VirtualListViewResponseControl extends Control {
       }
 
       this._value.result = ber.readEnumeration()
-      this._value.cookie = ber.readString(Ber.OctetString, true)
+      this._value.cookie = ber.readString(BerTypes.OctetString, true)
 
       // readString returns '' instead of a zero-length buffer
       if (!this._value.cookie) {
@@ -138,7 +138,7 @@ class VirtualListViewResponseControl extends Control {
 
     writer.writeEnumeration(this.value.result)
     if (this.value.cookie && this.value.cookie.length > 0) {
-      writer.writeBuffer(this.value.cookie, Ber.OctetString)
+      writer.writeBuffer(this.value.cookie, BerTypes.OctetString)
     } else {
       writer.writeString('') // writeBuffer rejects zero-length buffers
     }
@jsumners jsumners added the good first issue Good for newcomers label Jul 31, 2023
@jsumners
Copy link
Member

This does look like a miss when preparing the ldapjs@3 release. Bumping the version will be a semver major change. Luckily, we are approaching a window for such a release with the end-of-life for Node.js 16 coming up in early September. Would you like to take this work on? I have created a next-v3 branch for any PR addressing this to target.

Other than that, are you experiencing some issue at the moment with the current dependency version?

@guimard
Copy link
Author

guimard commented Aug 1, 2023

This does look like a miss when preparing the ldapjs@3 release. Bumping the version will be a semver major change. Luckily, we are approaching a window for such a release with the end-of-life for Node.js 16 coming up in early September. Would you like to take this work on? I have created a next-v3 branch for any PR addressing this to target.

Other than that, are you experiencing some issue at the moment with the current dependency version?

Hi,

Thanks for providing such amazing software. I'm using ldapjs for 2 distinct goals:

  • as a dependency of my JS projects (version 2 for now)
  • I'm the Debian Maintainer of it. In this case, it is not possible to have 2 versions of @ldapjs/asn1, so it's not possible to upgrade to version 3 for now

Regards,
Yadd

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers
Projects
Status: Todo
Development

No branches or pull requests

2 participants