Comparing version 1.3.0 to 1.4.0
@@ -0,1 +1,5 @@ | ||
### 1.4.0 | ||
* Support binary attribute values (Fix #11) | ||
### 1.3.0 | ||
@@ -2,0 +6,0 @@ |
@@ -0,12 +1,14 @@ | ||
/// <reference types="node" /> | ||
import { BerReader, BerWriter } from 'asn1'; | ||
export interface AttributeOptions { | ||
type?: string; | ||
values?: string[]; | ||
values?: string[] | Buffer[]; | ||
} | ||
export declare class Attribute { | ||
type: string; | ||
values: string[]; | ||
values: string[] | Buffer[]; | ||
constructor(options?: AttributeOptions); | ||
write(writer: BerWriter): void; | ||
parse(reader: BerReader): void; | ||
private _isBinaryType; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const asn1_1 = require("asn1"); | ||
const ProtocolOperation_1 = require("./ProtocolOperation"); | ||
@@ -11,7 +12,18 @@ class Attribute { | ||
writer.startSequence(); | ||
writer.writeString(this.type); | ||
let type = this.type; | ||
const isBinaryType = this._isBinaryType(); | ||
// If the value is a buffer and the type does not end in ;binary, append it | ||
if (!isBinaryType && this.values.length && Buffer.isBuffer(this.values[0])) { | ||
type += ';binary'; | ||
} | ||
writer.writeString(type); | ||
writer.startSequence(ProtocolOperation_1.ProtocolOperation.LBER_SET); | ||
if (this.values.length) { | ||
for (const value of this.values) { | ||
writer.writeString(value); | ||
if (Buffer.isBuffer(value)) { | ||
writer.writeBuffer(value, asn1_1.Ber.OctetString); | ||
} | ||
else { | ||
writer.writeString(value); | ||
} | ||
} | ||
@@ -28,2 +40,3 @@ } | ||
this.type = reader.readString(); | ||
const isBinaryType = this._isBinaryType(); | ||
if (reader.peek() === ProtocolOperation_1.ProtocolOperation.LBER_SET) { | ||
@@ -33,3 +46,8 @@ if (reader.readSequence(ProtocolOperation_1.ProtocolOperation.LBER_SET)) { | ||
while (reader.offset < end) { | ||
this.values.push(reader.readString()); | ||
if (isBinaryType) { | ||
this.values.push(reader.readString(asn1_1.Ber.OctetString, true) || Buffer.alloc(0)); | ||
} | ||
else { | ||
this.values.push(reader.readString()); | ||
} | ||
} | ||
@@ -39,4 +57,7 @@ } | ||
} | ||
_isBinaryType() { | ||
return /;binary$/.test(this.type); | ||
} | ||
} | ||
exports.Attribute = Attribute; | ||
//# sourceMappingURL=Attribute.js.map |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
import { BerReader } from 'asn1'; | ||
@@ -11,3 +12,3 @@ import { MessageResponse, MessageResponseOptions } from './MessageResponse'; | ||
dn: string; | ||
[index: string]: string | string[]; | ||
[index: string]: string | string[] | Buffer | Buffer[]; | ||
} | ||
@@ -14,0 +15,0 @@ export declare class SearchEntry extends MessageResponse { |
{ | ||
"name": "ldapts", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "LDAP client", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
261896
4243