ldap-async
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -39,2 +39,3 @@ /// <reference types="node" /> | ||
} | ||
type ValidAttributeInput = boolean | number | string | Buffer; | ||
export default class Ldap { | ||
@@ -86,3 +87,3 @@ protected connectpromise?: Promise<void>; | ||
*/ | ||
setAttribute(dn: string, attribute: string, val: any): Promise<boolean>; | ||
setAttribute(dn: string, attribute: string, val: ValidAttributeInput | ValidAttributeInput[] | undefined): Promise<boolean>; | ||
/** | ||
@@ -95,3 +96,3 @@ * Use this method to completely replace multiple attributes. If any of the given attributes | ||
*/ | ||
setAttributes(dn: string, modification: Record<string, any>): Promise<boolean>; | ||
setAttributes(dn: string, modification: Record<string, ValidAttributeInput | ValidAttributeInput[] | undefined>): Promise<boolean>; | ||
/** | ||
@@ -98,0 +99,0 @@ * Use this method to add more values to an array attribute without removing any existing values. Any |
@@ -27,2 +27,9 @@ "use strict"; | ||
const utfDecoder = new node_util_1.TextDecoder('utf8', { fatal: true }); | ||
function valToString(val) { | ||
if (typeof val === 'boolean') | ||
return val ? 'TRUE' : 'FALSE'; | ||
if (typeof val === 'number') | ||
return String(val); | ||
return val; | ||
} | ||
class Ldap { | ||
@@ -322,3 +329,4 @@ constructor(config = {}) { | ||
async setAttribute(dn, attribute, val) { | ||
return await this.modify(dn, 'replace', { type: attribute, values: Array.isArray(val) ? val : (val == null ? [] : [val]) }); | ||
const values = (Array.isArray(val) ? val : (val == null ? [] : [val])).map(valToString); | ||
return await this.modify(dn, 'replace', { type: attribute, values }); | ||
} | ||
@@ -333,3 +341,3 @@ /** | ||
async setAttributes(dn, modification) { | ||
const changes = Object.entries(modification).map(([attr, val]) => ({ operation: 'replace', modification: { type: attr, values: Array.isArray(val) ? val : (val == null ? [] : [val]) } })); | ||
const changes = Object.entries(modification).map(([attr, val]) => ({ operation: 'replace', modification: { type: attr, values: (Array.isArray(val) ? val : (val == null ? [] : [val])).map(valToString) } })); | ||
return await this.modify(dn, changes); | ||
@@ -336,0 +344,0 @@ } |
{ | ||
"name": "ldap-async", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "A wrapper around ldapjs to provide promises, pooling, config by environment, and other conveniences.", | ||
@@ -5,0 +5,0 @@ "exports": { |
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
42618
691