From 941c6fa41aed4f39517d085f3183d87a96ffdaa6 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 6 May 2019 04:13:36 -0400 Subject: [PATCH] [ldapjs] created initial stubs for Server, createServer, and related objects/functions (#35125) * created initial stub for Server and related objects/functions * correct ts-compile for pre-typescript 3.1 versions --- types/ldapjs/index.d.ts | 107 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 105 insertions(+), 2 deletions(-) diff --git a/types/ldapjs/index.d.ts b/types/ldapjs/index.d.ts index fb09150000..af7b4efe42 100644 --- a/types/ldapjs/index.d.ts +++ b/types/ldapjs/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for ldapjs 1.0 +// Type definitions for ldapjs // Project: http://ldapjs.org -// Definitions by: Charles Villemure , Peter Kooijmans , Pablo Moleri +// Definitions by: Charles Villemure , Peter Kooijmans , Pablo Moleri , Michael Scott-Nelson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -250,6 +250,107 @@ export interface Client extends EventEmitter { export function createClient(options?: ClientOptions): Client; +export function createServer(options?: ServerOptions): Server; + +/** + * @param log You can optionally pass in a bunyan instance the client will use to acquire a logger. + * @param certificate A PEM-encoded X.509 certificate; will cause this server to run in TLS mode. + * @param key A PEM-encoded private key that corresponds to certificate for SSL. + */ +export interface ServerOptions { + log?: any; + certificate?: any; + key?: any; +} +export interface Server extends EventEmitter { + + /** + * Set this property to reject connections when the server's connection count gets high. + */ + maxConnections: number; + + /** + * The number of concurrent connections on the server. (getter only) + */ + connections(): number; + + /** + * Returns the fully qualified URL this server is listening on. For example: ldaps://10.1.2.3:1636. If you haven't yet called listen, it will always return ldap://localhost:389. + */ + url: string; + + /** + * Port and Host + * Begin accepting connections on the specified port and host. If the host is omitted, the server will accept connections directed to any IPv4 address (INADDR_ANY). + * This function is asynchronous. The last parameter callback will be called when the server has been bound. + */ + listen(port: number): void; + listen(port: number, callback: any): void; + listen(port: number, host: string): void; + listen(port: number, host: string, callback: any): void; + + /** + * Unix Domain Socket + * Start a UNIX socket server listening for connections on the given path. + * This function is asynchronous. The last parameter callback will be called when the server has been bound. + */ + listen(path: string): void; + listen(path: string, callback: any): void; + + /** + * File descriptor + * Start a server listening for connections on the given file descriptor. + * This file descriptor must have already had the bind(2) and listen(2) system calls invoked on it. Additionally, it must be set non-blocking; try fcntl(fd, F_SETFL, O_NONBLOCK). + */ + listenFD(fileDescriptor: any): void; + + bind(mount: string, ...cbHandlers: any[]): void; + add(mount: string, ...cbHandlers: any[]): void; + + search(ditHook: string, ...cbHandlers: any[]): void; + + modify(ditHook: string, ...cbHandlers: any[]): void; + + del(ditHook: string, ...cbHandlers: any[]): void; + + compare(ditHook: string, ...cbHandlers: any[]): void; + + modifyDN(ditHook: string, ...cbHandlers: any[]): void; + + exop(arbitraryHook: string, ...cbHandlers: any[]): void; + + unbind(...cbHandlers: any[]): void; +} +export class SearchRequest { + baseObject: string; + scope: "base"|"one"|"sub"; + derefAliases: number; + sizeLimit: number; + timeLimit: number; + typesOnly: boolean; + filter: any; + attributes?: any; +} +export class InsufficientAccessRightsError { + constructor(error?: string); +} +export class InvalidCredentialsError { + constructor(error?: string); +} +export class EntryAlreadyExistsError { + constructor(error?: string); +} +export class NoSuchObjectError { + constructor(error?: string); +} +export class NoSuchAttributeError { + constructor(error?: string); +} +export class ProtocolError { + constructor(error?: string); +} + + declare class Filter { matches(obj: any): boolean; type: string; @@ -383,3 +484,5 @@ export class SearchEntry extends LDAPMessage { */ readonly raw: SearchEntryRaw; } + +export function parseDN(dn: string): any;