Advertisement
Zorbing

ldapjs.d.ts

Mar 10th, 2019
530
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Type definitions for LDAPjs 0.7.1
  2. // Project: https://www.npmjs.com/package/ldapjs
  3. // Definitions by: Zorbing <https://github.com/Zorbing>
  4.  
  5. /* =================== USAGE ===================
  6.  
  7.     import * as ldapjs from "ldapjs";
  8.  
  9.  =============================================== */
  10.  
  11. /// <reference path="../../typings/node/node.d.ts" />
  12.  
  13. declare module "ldapjs"
  14. {
  15.     interface IControl {}
  16.     interface IChange {}
  17.     interface IChangeObject {
  18.         modification;
  19.         operation?;
  20.         type?;
  21.     }
  22.     interface ICallback {
  23.         (...args: any[]): any;
  24.     }
  25.    
  26.     interface ICreateClientOptions {
  27.         // timeout for connecting to server in milliseconds
  28.         connectTimeout?: number | string;
  29.         log?;
  30.         maxConnections?: number;
  31.         socketPath?: string;
  32.         timeout?: number | string;
  33.         // options see: https://nodejs.org/api/tls.html#tls_tls_connect_port_host_options_callback
  34.         tlsOptions?/*: tls.ConnectionOptions*/;
  35.         url?: string;
  36.     }
  37.     export function createClient(options: ICreateClientOptions): LDAPClient;
  38.     export function createServer(options?)/*: LDAPServer*/;
  39.    
  40.     export var Server;
  41.     export var Attribute;
  42.     export var Change;
  43.     export var PersistentSearchCache;
  44.     export var RDN;
  45.     export var dn: DN;
  46.     export var persistentSearch;
  47.     export var filters;
  48.     export var parseURL;
  49.     export var url;
  50.     export var GUID_FORMAT_N;
  51.     export var GUID_FORMAT_D;
  52.     export var GUID_FORMAT_B;
  53.     export var GUID_FORMAT_P;
  54.     export var GUID_FORMAT_X;
  55.    
  56.     interface IUrl extends URL {
  57.         attributes?: string[];
  58.         DN?;
  59.         extensions?: string;
  60.         filter?: string;
  61.         port: number;
  62.         scope?: string;
  63.         secure: boolean;
  64.     }
  65.    
  66.    
  67.     interface ISearchOptions
  68.     {
  69.         // One of base, one, or sub. Defaults to base.
  70.         scope?: string;
  71.         // A string version of an LDAP filter (see below), or a programatically constructed Filter object. Defaults to (objectclass=*).
  72.         filter?: string | Filter;
  73.         // attributes to select and return (if these are set, the server will return only these attributes). Defaults to the empty set, which means all attributes.
  74.         attributes?;
  75.         // boolean on whether you want the server to only return the names of the attributes, and not their values. Borderline useless. Defaults to false.
  76.         attrsOnly?: boolean;
  77.         // the maximum number of entries to return. Defaults to 0 (unlimited).
  78.         sizeLimit?: number;
  79.         // the maximum amount of time the server should take in responding, in seconds. Defaults to 10. Lots of servers will ignore this.
  80.         timeLimit?: number;
  81.     }
  82.     /**
  83.      * Client
  84.      */
  85.     export class LDAPClient {
  86.         connectTimeout: number;
  87.         host: string;
  88.         log;
  89.         port: number |  boolean;
  90.         secure: boolean;
  91.         tlsOptions;
  92.         socketPath: string;
  93.         timeout: number;
  94.         url: IUrl;
  95.         socket/*: Socket | ClearTextStream*/;
  96.        
  97.         abandon(messageID: number, callback: ICallback);
  98.         abandon(messageID: number, controls: IControl | IControl[], callback: ICallback);
  99.        
  100.         add(name: string, entry: Object | Object[], callback: ICallback);
  101.         add(name: string, entry: Object | Object[], controls, callback);
  102.        
  103.         bind(name: string | DN, credentials: string, callback: ICallback);
  104.         bind(name: string | DN, credentials: string, controls: IControl | IControl[], callback: ICallback);
  105.        
  106.         compare(name: string, attr: string, value: string, callback: ICallback);
  107.         compare(name: string, attr: string, value: string, controls: IControl | IControl[], callback: ICallback);
  108.        
  109.         del(name: string, callback: ICallback);
  110.         del(name: string, controls: IControl | IControl[], callback: ICallback);
  111.        
  112.         exop(name: string, callback: ICallback);
  113.         exop(name: string, value: string | Buffer, controls: IControl | IControl[], callback: ICallback);
  114.        
  115.         modify(name: string, change: IChange | IChange[] | Object | Object[], callback: ICallback);
  116.         modify(name: string, change: IChange | IChange[] | Object | Object[], controls: IControl | IControl[], callback: ICallback);
  117.        
  118.         modifyDN(name: string, newName: string, callback: ICallback);
  119.         modifyDN(name: string, newName: string, controls: IControl | IControl[], callback: ICallback);
  120.        
  121.         search(base: string | DN, callback: ICallback);
  122.         search(base: string | DN, controls: IControl | IControl[], callback: ICallback);
  123.         search(base: string | DN, options: string | ISearchOptions, callback: ICallback);
  124.         search(base: string | DN, options: string | ISearchOptions, controls: IControl | IControl[], callback: ICallback);
  125.        
  126.         unbind(callback?: ICallback);
  127.     }
  128.    
  129.    
  130.     /**
  131.      * TODO: EventEmitter
  132.      */
  133.    
  134.    
  135.     /**
  136.      * Parses the given distinguished names and returns an instance of the DN class
  137.      */
  138.     export function parseDN(dn: string): DN;
  139.    
  140.     export class DN
  141.     {
  142.         childOf(dn: string | DN): boolean;
  143.         parentOf(dn: string | DN): boolean;
  144.         equals(dn: string | DN): boolean;
  145.         parent(): DN;
  146.         toString(): string;
  147.     }
  148.    
  149.    
  150.     /**
  151.      * Abstract filter class
  152.      */
  153.     class Filter
  154.     {
  155.         // possible values are:
  156.         // equal, present, substring, ge, le, and, or, not; (not implemented types: approx, ext)
  157.         type: string;
  158.         matches(entry: any): boolean;
  159.     }
  160.    
  161.     /**
  162.      * Parses the given filter string and returns an instance of one Filter class
  163.      */
  164.     export function parseFilter(filter: string): Filter;
  165.    
  166.     export class EqualityFilter extends Filter
  167.     {
  168.         constructor(config: {
  169.             attribute: string;
  170.             value: string;
  171.         });
  172.     }
  173.     export class PresenceFilter extends Filter
  174.     {
  175.         constructor(config: {
  176.             attribute: string;
  177.         });
  178.     }
  179.     export class SubstringFilter extends Filter
  180.     {
  181.         constructor(config: {
  182.             attribute?: string;
  183.             initial: string;
  184.             any: string[];
  185.             final: string;
  186.         });
  187.     }
  188.     export class GreaterThanEqualsFilter extends Filter
  189.     {
  190.         constructor(config: {
  191.             attribute: string;
  192.             value: string;
  193.         });
  194.     }
  195.     export class LessThanEqualsFilter extends Filter
  196.     {
  197.         constructor(config: {
  198.             attribute: string;
  199.             value: string;
  200.         });
  201.     }
  202.     export class AndFilter extends Filter
  203.     {
  204.         constructor(config: {
  205.             filters: Filter[];
  206.         });
  207.     }
  208.     export class OrFilter extends Filter
  209.     {
  210.         constructor(config: {
  211.             filters: Filter[];
  212.         });
  213.     }
  214.     export class NotFilter extends Filter
  215.     {
  216.         constructor(config: {
  217.             filter: Filter;
  218.         });
  219.     }
  220.    
  221.    
  222.     /**
  223.      * Abstact error class
  224.      */
  225.     class LDAPError
  226.     {
  227.         stack;
  228.         code: number;
  229.         name: string;
  230.         message: string;
  231.     }
  232.     export class OperationsError extends LDAPError
  233.     {
  234.         constructor(message: string);
  235.     }
  236.     export class ProtocolError extends LDAPError
  237.     {
  238.         constructor(message: string);
  239.     }
  240.     export class TimeLimitExceededError extends LDAPError
  241.     {
  242.         constructor(message: string);
  243.     }
  244.     export class SizeLimitExceededError extends LDAPError
  245.     {
  246.         constructor(message: string);
  247.     }
  248.     export class CompareFalseError extends LDAPError
  249.     {
  250.         constructor(message: string);
  251.     }
  252.     export class CompareTrueError extends LDAPError
  253.     {
  254.         constructor(message: string);
  255.     }
  256.     export class AuthMethodNotSupportedError extends LDAPError
  257.     {
  258.         constructor(message: string);
  259.     }
  260.     export class StrongAuthRequiredError extends LDAPError
  261.     {
  262.         constructor(message: string);
  263.     }
  264.     export class ReferralError extends LDAPError
  265.     {
  266.         constructor(message: string);
  267.     }
  268.     export class AdminLimitExceededError extends LDAPError
  269.     {
  270.         constructor(message: string);
  271.     }
  272.     export class UnavailableCriticalExtensionError extends LDAPError
  273.     {
  274.         constructor(message: string);
  275.     }
  276.     export class ConfidentialityRequiredError extends LDAPError
  277.     {
  278.         constructor(message: string);
  279.     }
  280.     export class SaslBindInProgressError extends LDAPError
  281.     {
  282.         constructor(message: string);
  283.     }
  284.     export class NoSuchAttributeError extends LDAPError
  285.     {
  286.         constructor(message: string);
  287.     }
  288.     export class UndefinedAttributeTypeError extends LDAPError
  289.     {
  290.         constructor(message: string);
  291.     }
  292.     export class InappropriateMatchingError extends LDAPError
  293.     {
  294.         constructor(message: string);
  295.     }
  296.     export class ConstraintViolationError extends LDAPError
  297.     {
  298.         constructor(message: string);
  299.     }
  300.     export class AttributeOrValueExistsError extends LDAPError
  301.     {
  302.         constructor(message: string);
  303.     }
  304.     export class InvalidAttriubteSyntaxError extends LDAPError
  305.     {
  306.         constructor(message: string);
  307.     }
  308.     export class NoSuchObjectError extends LDAPError
  309.     {
  310.         constructor(message: string);
  311.     }
  312.     export class AliasProblemError extends LDAPError
  313.     {
  314.         constructor(message: string);
  315.     }
  316.     export class InvalidDnSyntaxError extends LDAPError
  317.     {
  318.         constructor(message: string);
  319.     }
  320.     export class AliasDerefProblemError extends LDAPError
  321.     {
  322.         constructor(message: string);
  323.     }
  324.     export class InappropriateAuthenticationError extends LDAPError
  325.     {
  326.         constructor(message: string);
  327.     }
  328.     export class InvalidCredentialsError extends LDAPError
  329.     {
  330.         constructor(message: string);
  331.     }
  332.     export class InsufficientAccessRightsError extends LDAPError
  333.     {
  334.         constructor(message: string);
  335.     }
  336.     export class BusyError extends LDAPError
  337.     {
  338.         constructor(message: string);
  339.     }
  340.     export class UnavailableError extends LDAPError
  341.     {
  342.         constructor(message: string);
  343.     }
  344.     export class UnwillingToPerformError extends LDAPError
  345.     {
  346.         constructor(message: string);
  347.     }
  348.     export class LoopDetectError extends LDAPError
  349.     {
  350.         constructor(message: string);
  351.     }
  352.     export class NamingViolationError extends LDAPError
  353.     {
  354.         constructor(message: string);
  355.     }
  356.     export class ObjectclassViolationError extends LDAPError
  357.     {
  358.         constructor(message: string);
  359.     }
  360.     export class NotAllowedOnNonLeafError extends LDAPError
  361.     {
  362.         constructor(message: string);
  363.     }
  364.     export class NotAllowedOnRdnError extends LDAPError
  365.     {
  366.         constructor(message: string);
  367.     }
  368.     export class EntryAlreadyExistsError extends LDAPError
  369.     {
  370.         constructor(message: string);
  371.     }
  372.     export class ObjectclassModsProhibitedError extends LDAPError
  373.     {
  374.         constructor(message: string);
  375.     }
  376.     export class AffectsMultipleDsasError extends LDAPError
  377.     {
  378.         constructor(message: string);
  379.     }
  380.     export class OtherError extends LDAPError
  381.     {
  382.         constructor(message: string);
  383.     }
  384. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement