Comparing version 7.1.0 to 7.1.1
{ | ||
"name": "ldapts", | ||
"version": "7.1.0", | ||
"version": "7.1.1", | ||
"description": "LDAP client", | ||
@@ -73,32 +73,33 @@ "main": "./dist/index.cjs", | ||
"asn1": "~0.2.6", | ||
"debug": "~4.3.5", | ||
"debug": "~4.3.6", | ||
"strict-event-emitter-types": "~2.0.0", | ||
"uuid": "~10.0.0" | ||
"uuid": "~10.0.0", | ||
"whatwg-url": "~14.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "~4.3.16", | ||
"@types/chai": "~4.3.18", | ||
"@types/chai-as-promised": "~7.1.8", | ||
"@types/debug": "~4.1.12", | ||
"@types/mocha": "~10.0.7", | ||
"@types/node": ">=20", | ||
"@types/node": ">=22", | ||
"@types/sinon": "~17.0.3", | ||
"@types/uuid": ">=10", | ||
"@types/whatwg-url": "~11.0.5", | ||
"chai": "~5.1.1", | ||
"chai-as-promised": "~8.0.0", | ||
"eslint": "~9.6.0", | ||
"eslint-config-decent": "^1.3.0", | ||
"husky": "~9.0.11", | ||
"lint-staged": "~15.2.7", | ||
"eslint": "~9.9.1", | ||
"eslint-config-decent": "^2.2.0", | ||
"husky": "~9.1.5", | ||
"lint-staged": "~15.2.9", | ||
"markdownlint-cli": "~0.41.0", | ||
"mocha": "~10.6.0", | ||
"mocha": "~10.7.3", | ||
"npm-run-all": "~4.1.5", | ||
"pinst": "~3.0.0", | ||
"prettier": "~3.3.2", | ||
"prettier": "~3.3.3", | ||
"sinon": "~18.0.0", | ||
"ts-mockito": "~2.6.1", | ||
"tsx": "~4.16.2", | ||
"typescript": "~5.5.3", | ||
"typescript-eslint": "~8.0.0-alpha.41", | ||
"tsx": "~4.18.0", | ||
"typescript": "~5.5.4", | ||
"unbuild": "2.0.0" | ||
} | ||
} |
@@ -542,2 +542,10 @@ # LDAPts | ||
### Generate certificates | ||
Use [certyaml](https://github.com/tsaarni/certyaml) to generate certificates for tests: | ||
```sh | ||
(cd tests/certs && ./certyaml -d .) | ||
``` | ||
### Start test OpenLDAP server | ||
@@ -544,0 +552,0 @@ |
import * as net from 'net'; | ||
import * as tls from 'tls'; | ||
import { parse as parseUrl } from 'url'; | ||
import debug from 'debug'; | ||
import { v4 } from 'uuid'; | ||
import { parseURL } from 'whatwg-url'; | ||
@@ -20,19 +20,19 @@ import { Attribute } from './Attribute.js'; | ||
import { | ||
AbandonRequest, | ||
AddRequest, | ||
BindRequest, | ||
UnbindRequest, | ||
AbandonRequest, | ||
CompareRequest, | ||
CompareResult, | ||
DeleteRequest, | ||
ExtendedRequest, | ||
ModifyDNRequest, | ||
ModifyRequest, | ||
SASL_MECHANISMS, | ||
SearchEntry, | ||
SearchReference, | ||
SearchRequest, | ||
CompareResult, | ||
SearchResponse, | ||
SearchReference, | ||
SearchEntry, | ||
AddRequest, | ||
ModifyRequest, | ||
SASL_MECHANISMS, | ||
UnbindRequest, | ||
} from './messages/index.js'; | ||
import type { BindResponse, CompareResponse, Entry, DeleteResponse, ExtendedResponse, ModifyDNResponse, AddResponse, ModifyResponse, SaslMechanism } from './messages/index.js'; | ||
import type { AddResponse, BindResponse, CompareResponse, DeleteResponse, Entry, ExtendedResponse, ModifyDNResponse, ModifyResponse, SaslMechanism } from './messages/index.js'; | ||
import type { Message } from './messages/Message.js'; | ||
@@ -173,10 +173,23 @@ import type { MessageResponse } from './messages/MessageResponse.js'; | ||
const parsedUrl = parseUrl(options.url); | ||
if (!parsedUrl.protocol || !(parsedUrl.protocol === 'ldap:' || parsedUrl.protocol === 'ldaps:')) { | ||
const parsedUrl = parseURL(options.url); | ||
if (!parsedUrl?.scheme || !(parsedUrl.scheme === 'ldap' || parsedUrl.scheme === 'ldaps')) { | ||
throw new Error(`${options.url} is an invalid LDAP URL (protocol)`); | ||
} | ||
const isSecureProtocol = parsedUrl.protocol === 'ldaps:'; | ||
const isSecureProtocol = parsedUrl.scheme === 'ldaps'; | ||
this.secure = isSecureProtocol || !!this.clientOptions.tlsOptions; | ||
this.host = parsedUrl.hostname ?? 'localhost'; | ||
let host: string | null | undefined = null; | ||
if (typeof parsedUrl.host === 'string') { | ||
// Host might include a port, so split to get the hostname part | ||
host = parsedUrl.host.split(':')[0]; | ||
} else if (Array.isArray(parsedUrl.host)) { | ||
// Handle IPv6Address case by joining parts | ||
host = parsedUrl.host.join(':'); | ||
} else if (parsedUrl.host !== null) { | ||
// If it's a number or any other type, convert to string | ||
host = String(parsedUrl.host); | ||
} | ||
this.host = host ?? 'localhost'; // Default to 'localhost' if host is null | ||
if (parsedUrl.port) { | ||
@@ -183,0 +196,0 @@ this.port = Number(parsedUrl.port); |
@@ -6,12 +6,12 @@ import type { BerReader } from 'asn1'; | ||
import { | ||
PresenceFilter, | ||
AndFilter, | ||
ApproximateFilter, | ||
EqualityFilter, | ||
ExtensibleFilter, | ||
GreaterThanEqualsFilter, | ||
ExtensibleFilter, | ||
LessThanEqualsFilter, | ||
NotFilter, | ||
OrFilter, | ||
PresenceFilter, | ||
SubstringFilter, | ||
EqualityFilter, | ||
ApproximateFilter, | ||
OrFilter, | ||
LessThanEqualsFilter, | ||
} from './filters/index.js'; | ||
@@ -210,3 +210,3 @@ import { SearchFilter } from './SearchFilter.js'; | ||
filter = FilterParser._parseExpressionFilterFromString(filterString.substr(cursor, end - cursor)); | ||
filter = FilterParser._parseExpressionFilterFromString(filterString.substring(cursor, end)); | ||
cursor = end; | ||
@@ -234,3 +234,3 @@ } | ||
[attribute] = matches; | ||
remainingExpression = filterString.substr(attribute.length); | ||
remainingExpression = filterString.slice(attribute.length); | ||
} else { | ||
@@ -248,3 +248,3 @@ throw new Error(`Invalid attribute name: ${filterString}`); | ||
if (remainingExpression.startsWith('=')) { | ||
remainingExpression = remainingExpression.substr(1); | ||
remainingExpression = remainingExpression.slice(1); | ||
if (remainingExpression.includes('*')) { | ||
@@ -269,3 +269,3 @@ const escapedExpression = FilterParser._unescapeSubstring(remainingExpression); | ||
attribute, | ||
value: FilterParser._unescapeHexValues(remainingExpression.substr(2)), | ||
value: FilterParser._unescapeHexValues(remainingExpression.slice(2)), | ||
}); | ||
@@ -277,3 +277,3 @@ } | ||
attribute, | ||
value: FilterParser._unescapeHexValues(remainingExpression.substr(2)), | ||
value: FilterParser._unescapeHexValues(remainingExpression.slice(2)), | ||
}); | ||
@@ -285,3 +285,3 @@ } | ||
attribute, | ||
value: FilterParser._unescapeHexValues(remainingExpression.substr(2)), | ||
value: FilterParser._unescapeHexValues(remainingExpression.slice(2)), | ||
}); | ||
@@ -323,3 +323,3 @@ } | ||
// Trim the leading = (from the :=) and reinsert any extra ':' characters | ||
const remainingExpression = fields.join(':').substr(1); | ||
const remainingExpression = fields.join(':').slice(1); | ||
const options: ExtensibleFilterOptions = { | ||
@@ -355,3 +355,3 @@ matchType: attribute, | ||
case '\\': { | ||
const value = input.substr(index + 1, 2); | ||
const value = input.slice(index + 1, index + 3); | ||
if (/^[\dA-Fa-f]{2}$/.exec(value) === null) { | ||
@@ -358,0 +358,0 @@ throw new Error(`Invalid escaped hex character: ${value} in value: ${input}`); |
@@ -23,3 +23,3 @@ import type { BerReader, BerWriter } from 'asn1'; | ||
public override parseFilter(reader: BerReader): void { | ||
this.attribute = reader.buffer.slice(0, reader.length).toString('utf8').toLowerCase(); | ||
this.attribute = reader.buffer.subarray(0, reader.length).toString('utf8').toLowerCase(); | ||
reader._offset += reader.length; | ||
@@ -26,0 +26,0 @@ } |
@@ -9,3 +9,3 @@ import * as assert from 'assert'; | ||
import { MessageParserError } from './errors/MessageParserError.js'; | ||
import { AddResponse, BindResponse, CompareResponse, DeleteResponse, ExtendedResponse, ModifyDNResponse, ModifyResponse, SearchResponse, SearchEntry, SearchReference } from './messages/index.js'; | ||
import { AddResponse, BindResponse, CompareResponse, DeleteResponse, ExtendedResponse, ModifyDNResponse, ModifyResponse, SearchEntry, SearchReference, SearchResponse } from './messages/index.js'; | ||
import type { Message } from './messages/Message.js'; | ||
@@ -53,3 +53,3 @@ import type { MessageResponse } from './messages/MessageResponse.js'; | ||
// Received too much data | ||
nextMessage = this.buffer.slice(reader.offset + reader.length); | ||
nextMessage = this.buffer.subarray(reader.offset + reader.length); | ||
reader._size = reader.offset + reader.length; | ||
@@ -56,0 +56,0 @@ assert.strictEqual(reader.remain, reader.length); |
@@ -33,5 +33,5 @@ import type { BerReader, BerWriter } from 'asn1'; | ||
const { length } = reader; | ||
this.dn = reader.buffer.slice(0, length).toString('utf8'); | ||
this.dn = reader.buffer.subarray(0, length).toString('utf8'); | ||
reader._offset += reader.length; | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
565619
12256
561
6
+ Addedwhatwg-url@~14.0.0
+ Addedpunycode@2.3.1(transitive)
+ Addedtr46@5.0.0(transitive)
+ Addedwebidl-conversions@7.0.0(transitive)
+ Addedwhatwg-url@14.0.0(transitive)
Updateddebug@~4.3.6