Socket
Socket
Sign inDemoInstall

ldapts

Package Overview
Dependencies
Maintainers
1
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ldapts - npm Package Compare versions

Comparing version 4.3.0-beta1 to 5.0.0-beta1

23

CHANGELOG.md
# Change Log
## 4.3.0 - 2023-02-19
## 5.0.0 - 2023-07-08
- Drop Node.js 14 support
- Update npms
- Fix parsing specified controls from response. Fix #106
- Add OpenLDAP test server! Fix #135 Thanks @tsaarni!
- Allow for optional password by setting a default empty string. Fix #134 Thanks @wattry, @TimoHocker, and @thernstig!
## 4.2.6 - 2023-04-28
- Update npms
## 4.2.5 - 2023-04-17
- Update npms
## 4.2.4 - 2023-02-21
- Check for socket if short-circuiting `_connect()`
## 4.2.3 - 2023-02-20
- Update npms
- Fix socket connection not established error. Fix #127 Thanks @Templum!
## 4.2.2 - 2023-01-03

@@ -9,0 +28,0 @@

3

Client.d.ts

@@ -98,4 +98,4 @@ /// <reference types="node" />

private connectTimer?;
private readonly messageParser;
private readonly messageDetailsByMessageId;
private readonly messageParser;
constructor(options: ClientOptions);

@@ -114,2 +114,3 @@ get isConnected(): boolean;

* @param {string|SaslMechanism} mechanism
* @param {string|DN} [dn]
* @param {string} [password]

@@ -116,0 +117,0 @@ * @param {Control|Control[]} [controls]

@@ -49,4 +49,4 @@ "use strict";

this.connected = false;
this.messageParser = new MessageParser_1.MessageParser();
this.messageDetailsByMessageId = {};
this.messageParser = new MessageParser_1.MessageParser(this.messageDetailsByMessageId);
this.socketDataHandler = (data) => {

@@ -95,9 +95,8 @@ if (this.messageParser) {

get isConnected() {
return this.connected;
return !!this.socket && this.connected;
}
async startTLS(options = {}, controls) {
if (!this.connected) {
if (!this.isConnected) {
await this._connect();
}
// Start TLS extended operation: Request that the server start using encrypted communications over the connection
await this.exop('1.3.6.1.4.1.1466.20037', undefined, controls);

@@ -157,2 +156,3 @@ const originalSocket = this.socket;

* @param {string|SaslMechanism} mechanism
* @param {string|DN} [dn]
* @param {string} [password]

@@ -180,3 +180,3 @@ * @param {Control|Control[]} [controls]

async add(dn, attributes, controls) {
if (!this.connected) {
if (!this.isConnected) {
await this._connect();

@@ -229,3 +229,3 @@ }

async compare(dn, attribute, value, controls) {
if (!this.connected) {
if (!this.isConnected) {
await this._connect();

@@ -259,3 +259,3 @@ }

async del(dn, controls) {
if (!this.connected) {
if (!this.isConnected) {
await this._connect();

@@ -283,3 +283,3 @@ }

async exop(oid, value, controls) {
if (!this.connected) {
if (!this.isConnected) {
await this._connect();

@@ -312,3 +312,3 @@ }

async modify(dn, changes, controls) {
if (!this.connected) {
if (!this.isConnected) {
await this._connect();

@@ -340,3 +340,3 @@ }

async modifyDN(dn, newDN, controls) {
if (!this.connected) {
if (!this.isConnected) {
await this._connect();

@@ -391,3 +391,3 @@ }

async search(baseDN, options = {}, controls) {
if (!this.connected) {
if (!this.isConnected) {
await this._connect();

@@ -477,3 +477,3 @@ }

async _sendBind(req) {
if (!this.connected) {
if (!this.isConnected) {
await this._connect();

@@ -530,4 +530,4 @@ }

_connect() {
if (this.connected) {
return Promise.resolve();
if (this.isConnected) {
return;
}

@@ -680,3 +680,4 @@ return new Promise((resolve, reject) => {

const sendPromise = new Promise((resolve, reject) => {
// @ts-expect-error - Resolving with MessageResponse | undefined is expected.
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
messageResolve = resolve;

@@ -683,0 +684,0 @@ messageReject = reject;

@@ -58,3 +58,3 @@ # Contributor Covenant Code of Conduct

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at opensource@github.com. All
reported by contacting the project team at <opensource@github.com>. All
complaints will be reviewed and investigated and will result in a response that

@@ -61,0 +61,0 @@ is deemed necessary and appropriate to the circumstances. The project team is

import { BerReader } from 'asn1';
import type { Control } from './controls';
export declare class ControlParser {
/**
* Parse control from reader
* @param {BerReader} reader
* @param {Control[]} [controls] - Controls specified for specific message
*/
static parse(reader: BerReader, controls?: Control[]): Control | null;
static parse(reader: BerReader): Control | null;
}

@@ -8,8 +8,3 @@ "use strict";

class ControlParser {
/**
* Parse control from reader
* @param {BerReader} reader
* @param {Control[]} [controls] - Controls specified for specific message
*/
static parse(reader, controls) {
static parse(reader) {
if (reader.readSequence() === null) {

@@ -56,11 +51,7 @@ return null;

default:
control = controls?.find((messageControls) => messageControls.type === type);
break;
return null;
}
if (control) {
const controlReader = new asn1_1.BerReader(value);
control.parse(controlReader);
return control;
}
return null;
const controlReader = new asn1_1.BerReader(value);
control.parse(controlReader);
return control;
}

@@ -67,0 +58,0 @@ }

@@ -5,3 +5,2 @@ /// <reference types="node" />

import type { StrictEventEmitter } from 'strict-event-emitter-types';
import type { Message } from './messages/Message';
import type { MessageResponse } from './messages/MessageResponse';

@@ -13,10 +12,5 @@ interface MessageParserEvents {

type MessageParserEmitter = StrictEventEmitter<EventEmitter, MessageParserEvents>;
export interface MessageDetails {
readonly message: Readonly<Message>;
}
declare const MessageParser_base: new () => MessageParserEmitter;
export declare class MessageParser extends MessageParser_base {
private buffer?;
private readonly messageDetailsByMessageId;
constructor(messageDetailsByMessageId: Readonly<Record<string, MessageDetails>>);
read(data: Buffer): void;

@@ -23,0 +17,0 @@ private _getMessageFromProtocolOperation;

@@ -34,6 +34,2 @@ "use strict";

class MessageParser extends events_1.EventEmitter {
constructor(messageDetailsByMessageId) {
super();
this.messageDetailsByMessageId = messageDetailsByMessageId;
}
read(data) {

@@ -157,5 +153,3 @@ let nextMessage;

}
// Try to get controls specified with the message request
const messageDetails = this.messageDetailsByMessageId[messageId];
message.parse(reader, messageDetails?.message.controls);
message.parse(reader);
return message;

@@ -162,0 +156,0 @@ }

@@ -8,3 +8,3 @@ "use strict";

MessageResponseStatus[MessageResponseStatus["SizeLimitExceeded"] = 4] = "SizeLimitExceeded";
})(MessageResponseStatus = exports.MessageResponseStatus || (exports.MessageResponseStatus = {}));
})(MessageResponseStatus || (exports.MessageResponseStatus = MessageResponseStatus = {}));
//# sourceMappingURL=MessageResponseStatus.js.map

@@ -15,3 +15,3 @@ import type { BerReader, BerWriter } from 'asn1';

dn: string;
password?: string;
password: string;
mechanism: string | undefined;

@@ -18,0 +18,0 @@ constructor(options: BindRequestMessageOptions);

@@ -13,3 +13,3 @@ "use strict";

this.dn = options.dn || '';
this.password = options.password;
this.password = options.password || '';
this.mechanism = options.mechanism;

@@ -24,8 +24,6 @@ }

writer.writeString(this.mechanism);
if (typeof this.password === 'string') {
writer.writeString(this.password);
}
writer.writeString(this.password);
writer.endSequence();
}
else if (typeof this.password === 'string') {
else {
// Simple authentication

@@ -32,0 +30,0 @@ writer.writeString(this.password, asn1_1.Ber.Context); // 128

@@ -14,8 +14,4 @@ "use strict";

super.parseMessage(reader);
// Parse SASL response
while (reader.remain > 0) {
const type = reader.peek();
if (type === ProtocolOperation_1.ProtocolOperation.LDAP_CONTROLS) {
break;
}
this.data.push(reader.readString(typeof type === 'number' ? type : undefined));

@@ -22,0 +18,0 @@ }

@@ -24,3 +24,3 @@ "use strict";

CompareResult[CompareResult["noSuchObject"] = 50] = "noSuchObject";
})(CompareResult = exports.CompareResult || (exports.CompareResult = {}));
})(CompareResult || (exports.CompareResult = CompareResult = {}));
class CompareResponse extends MessageResponse_1.MessageResponse {

@@ -27,0 +27,0 @@ constructor(options) {

@@ -10,3 +10,3 @@ "use strict";

ExtendedResponseProtocolOperations[ExtendedResponseProtocolOperations["value"] = 139] = "value";
})(ExtendedResponseProtocolOperations = exports.ExtendedResponseProtocolOperations || (exports.ExtendedResponseProtocolOperations = {}));
})(ExtendedResponseProtocolOperations || (exports.ExtendedResponseProtocolOperations = ExtendedResponseProtocolOperations = {}));
class ExtendedResponse extends MessageResponse_1.MessageResponse {

@@ -13,0 +13,0 @@ constructor(options) {

@@ -17,3 +17,3 @@ /// <reference types="node" />

write(): Buffer;
parse(reader: BerReader, controls?: Control[]): void;
parse(reader: BerReader): void;
toString(): string;

@@ -20,0 +20,0 @@ protected parseMessage(_: BerReader): void;

@@ -31,3 +31,3 @@ "use strict";

}
parse(reader, controls) {
parse(reader) {
this.controls = [];

@@ -39,3 +39,3 @@ this.parseMessage(reader);

while (reader.offset < end) {
const control = ControlParser_1.ControlParser.parse(reader, controls);
const control = ControlParser_1.ControlParser.parse(reader);
if (control) {

@@ -42,0 +42,0 @@ this.controls.push(control);

@@ -1,2 +0,2 @@

import type { BerReader, BerWriter } from 'asn1';
import type { BerReader } from 'asn1';
import type { MessageOptions } from './Message';

@@ -15,3 +15,2 @@ import { Message } from './Message';

parseMessage(reader: BerReader): void;
writeMessage(writer: BerWriter): void;
}

@@ -17,9 +17,4 @@ "use strict";

}
writeMessage(writer) {
writer.writeEnumeration(this.status);
writer.writeString(this.matchedDN || '');
writer.writeString(this.errorMessage || '');
}
}
exports.MessageResponse = MessageResponse;
//# sourceMappingURL=MessageResponse.js.map
{
"name": "ldapts",
"version": "4.3.0-beta1",
"version": "5.0.0-beta1",
"description": "LDAP client",

@@ -14,4 +14,4 @@ "main": "index.js",

"lint-staged": "lint-staged",
"dist": "if [ -d \"src\" ]; then rm -rf dist && npm run lint && npm run build && npm run test && cp package.json dist && cp package-lock.json dist && cp *.md dist && cp LICENSE dist && cp .npmignore dist && cd dist && npm publish; fi",
"beta": "if [ -d \"src\" ]; then rm -rf dist && npm run lint && npm run build && npm run test && cp package.json dist && cp package-lock.json dist && cp *.md dist && cp LICENSE dist && cp .npmignore dist && cd dist && npm publish --tag beta; fi",
"dist": "if [ -d \"src\" ]; then rm -rf dist && npm run lint && npm run build && npm run test && cp package.json dist && cp package-lock.json dist && cp *.md dist && cp .npmignore dist && cd dist && npm publish; fi",
"beta": "if [ -d \"src\" ]; then rm -rf dist && npm run lint && npm run build && npm run test && cp package.json dist && cp package-lock.json dist && cp *.md dist && cp .npmignore dist && cd dist && npm publish --tag beta; fi",
"prepublishOnly": "if [ -d \"src\" ]; then echo \"Please use: npm run dist\" && exit 125; fi && pinst --disable",

@@ -38,3 +38,3 @@ "_postinstall": "husky install",

"engines": {
"node": ">=14"
"node": ">=16"
},

@@ -54,3 +54,3 @@ "keywords": [

"@types/asn1": ">=0.2.0",
"@types/node": ">=14",
"@types/node": ">=16",
"@types/uuid": ">=9",

@@ -63,17 +63,17 @@ "asn1": "~0.2.6",

"devDependencies": {
"@types/chai": "~4.3.4",
"@types/chai": "~4.3.5",
"@types/chai-as-promised": "~7.1.5",
"@types/debug": "~4.1.7",
"@types/debug": "~4.1.8",
"@types/mocha": "~10.0.1",
"@types/sinon": "~10.0.13",
"@typescript-eslint/eslint-plugin": "~5.52.0",
"@typescript-eslint/parser": "~5.52.0",
"@types/sinon": "~10.0.15",
"@typescript-eslint/eslint-plugin": "~5.61.0",
"@typescript-eslint/parser": "~5.61.0",
"chai": "~4.3.7",
"chai-as-promised": "~7.1.1",
"eslint": "~8.34.0",
"eslint": "~8.44.0",
"eslint-config-airbnb-base": "~15.0.0",
"eslint-config-airbnb-typescript": "~17.0.0",
"eslint-config-prettier": "~8.6.0",
"eslint-config-prettier": "~8.8.0",
"eslint-plugin-import": "~2.27.5",
"eslint-plugin-jsdoc": "~40.0.0",
"eslint-plugin-jsdoc": "~46.4.3",
"eslint-plugin-mocha": "10.1.0",

@@ -84,13 +84,13 @@ "eslint-plugin-prettier": "~4.2.1",

"husky": "~8.0.3",
"lint-staged": "~13.1.2",
"markdownlint-cli": "~0.33.0",
"lint-staged": "~13.2.3",
"markdownlint-cli": "~0.35.0",
"mocha": "~10.2.0",
"npm-run-all": "~4.1.5",
"pinst": "~3.0.0",
"prettier": "~2.8.4",
"sinon": "~15.0.1",
"prettier": "~2.8.8",
"sinon": "~15.2.0",
"ts-mockito": "~2.6.1",
"ts-node": "~10.9.1",
"typescript": "~4.9.5"
"typescript": "~5.1.6"
}
}

@@ -33,3 +33,3 @@ "use strict";

ProtocolOperation[ProtocolOperation["LDAP_RES_EXTENSION"] = 120] = "LDAP_RES_EXTENSION";
})(ProtocolOperation = exports.ProtocolOperation || (exports.ProtocolOperation = {}));
})(ProtocolOperation || (exports.ProtocolOperation = ProtocolOperation = {}));
//# sourceMappingURL=ProtocolOperation.js.map

@@ -401,3 +401,3 @@ # LDAPts

than one wildcard for a given string. For example you could do `(email=*@*bar.com)`
to match any email of @bar.com or its subdomains like "example@foo.bar.com".
to match any email of @bar.com or its subdomains like "<example@foo.bar.com>".

@@ -404,0 +404,0 @@ Now, let's say we also want to set our filter to include a

@@ -16,3 +16,3 @@ "use strict";

SearchFilter[SearchFilter["extensibleMatch"] = 169] = "extensibleMatch";
})(SearchFilter = exports.SearchFilter || (exports.SearchFilter = {}));
})(SearchFilter || (exports.SearchFilter = SearchFilter = {}));
//# sourceMappingURL=SearchFilter.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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