Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ldap-schema-ts-generator

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ldap-schema-ts-generator - npm Package Compare versions

Comparing version 3.9.1 to 4.0.0-beta1

7

CHANGELOG.md

@@ -7,2 +7,9 @@ ### Changelog

#### [v3.9.1](https://github.com/saostad/ldap-schema-ts-generator/compare/v3.9.0...v3.9.1)
> 4 June 2020
- fix: a pissible meory leak [`a4b641b`](https://github.com/saostad/ldap-schema-ts-generator/commit/a4b641bbddc6821d345def8fb76da9a17b0ffffc)
- doc: change log [`ce4e29a`](https://github.com/saostad/ldap-schema-ts-generator/commit/ce4e29ae75234b93998706421d015a2210a8d78b)
#### [v3.9.0](https://github.com/saostad/ldap-schema-ts-generator/compare/v3.8.0...v3.9.0)

@@ -9,0 +16,0 @@

102

dist/app.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.main = void 0;
const ldap_ts_client_1 = require("ldap-ts-client");
const dotenv_1 = require("dotenv");

@@ -9,3 +10,3 @@ dotenv_1.config();

async function main() {
var _a, _b, _c;
var _a, _b, _c, _d;
const logger = await fast_node_logger_1.createLogger({

@@ -19,22 +20,47 @@ level: "trace",

ldapServerUrl: (_c = process.env.AD_URI) !== null && _c !== void 0 ? _c : "",
baseDN: (_d = process.env.BASE_DN) !== null && _d !== void 0 ? _d : "",
logger,
};
const schemaDn = await index_1.getSchemaNamingContext({ options });
const linkIds = await index_1.getLinkIds({ options, schemaDn });
const client = new ldap_ts_client_1.Client(options);
const schemaDn = await index_1.getSchemaNamingContext({
client,
options: { logger },
});
console.log(`File: app.ts,`, `Line: 51 => `, schemaDn);
const rootDn = await index_1.getRootNamingContext({
client,
options: { logger },
});
console.log(`File: app.ts,`, `Line: 61 => `, rootDn);
const configurationsDn = await index_1.getConfigurationNamingContext({
client,
options: { logger },
});
console.log(`File: app.ts,`, `Line: 68 => `, configurationsDn);
const linkIds = await index_1.getLinkIds({ options: { logger }, client });
const relations = index_1.getRelations(linkIds);
await index_1.generateRelationsFile({ relations });
const controls = await index_1.getSchemaControls({ options });
const controls = await index_1.getSchemaControls({ client, options: { logger } });
await index_1.generateControlsFile({ controls });
const extensions = await index_1.getSchemaExtensions({ options });
const extensions = await index_1.getSchemaExtensions({ client, options: { logger } });
await index_1.generateExtensionsFile({ extensions });
const capabilities = await index_1.getSchemaCapabilities({ options });
const capabilities = await index_1.getSchemaCapabilities({
client,
options: { logger },
});
await index_1.generateCapabilitiesFile({ capabilities });
const policies = await index_1.getSchemaPolicies({ options });
const policies = await index_1.getSchemaPolicies({ client, options: { logger } });
await index_1.generatePoliciesFile({ policies });
const classes = await index_1.getStructuralSchemaClasses({ schemaDn, options });
const classes = await index_1.getStructuralSchemaClasses({
client,
options: { logger },
});
await index_1.generateStructuralClassesFile({ classes });
const countryCodes = await index_1.getCountryIsoCodes({ useCache: true });
await index_1.generateCountryIsoCodesFile({ countryCodes });
const objectAttributes = await index_1.getSchemaAttributes({ schemaDn, options });
const objectClasses = await index_1.getSchemaClasses({ schemaDn, options });
const objectAttributes = await index_1.getSchemaAttributes({
client,
options: { logger },
});
const objectClasses = await index_1.getSchemaClasses({ client, options: { logger } });
await index_1.generateAttributesMeta({

@@ -48,30 +74,30 @@ attributes: objectAttributes,

await index_1.generateInterfaceFiles({ objectAttributes, objectClasses });
// // test without generic type
// await generateGraphqlTypeFiles({
// objectClasses,
// objectAttributes,
// options: {
// generateClientSideDocuments: true,
// generateEnumTypeMaps: false,
// justThisClasses: ["user"],
// },
// });
// // test without generic type but limited classes
// await generateGraphqlTypeFiles({
// objectClasses,
// objectAttributes,
// options: {
// justThisClasses: ["user"],
// generateClientSideDocuments: true,
// },
// });
// // test with type
// await generateGraphqlTypeFiles<StructuralClasses>({
// objectClasses,
// objectAttributes,
// options: {
// justThisClasses: ["user"],
// generateClientSideDocuments: true,
// },
// });
// test without generic type
await index_1.generateGraphqlTypeFiles({
objectClasses,
objectAttributes,
options: {
generateClientSideDocuments: true,
generateEnumTypeMaps: false,
justThisClasses: ["user"],
},
});
// test without generic type but limited classes
await index_1.generateGraphqlTypeFiles({
objectClasses,
objectAttributes,
options: {
justThisClasses: ["user"],
generateClientSideDocuments: true,
},
});
// test with type
await index_1.generateGraphqlTypeFiles({
objectClasses,
objectAttributes,
options: {
justThisClasses: ["user"],
generateClientSideDocuments: true,
},
});
// test with enum type

@@ -78,0 +104,0 @@ await index_1.generateGraphqlTypeFiles({

@@ -1,6 +0,8 @@

import { IClientConfig } from "ldap-ts-client";
import type { SearchEntryObject, CN, AttributeID, AttributeSyntax, IsSingleValued, ShowInAdvancedViewOnly, AdminDisplayName, AdminDescription, OMSyntax, LDAPDisplayName, SystemOnly, SystemFlags, ObjectCategory } from "../typings/general/types";
import type { Client } from "ldap-ts-client";
import type { SearchEntryObject, CN, AttributeID, AttributeSyntax, IsSingleValued, ShowInAdvancedViewOnly, AdminDisplayName, AdminDescription, OMSyntax, LDAPDisplayName, SystemOnly, SystemFlags, ObjectCategory, Logger } from "../typings/general/types";
declare type GetSchemaAttributesFnInput = {
schemaDn: string;
options: Omit<IClientConfig, "baseDN">;
client: Client;
options?: {
logger?: Logger;
};
};

@@ -22,3 +24,3 @@ export interface SchemaAttribute extends Pick<SearchEntryObject, "dn" | "controls"> {

/** get defined an attribute objects in the schema. */
export declare function getSchemaAttributes({ schemaDn, options, }: GetSchemaAttributesFnInput): Promise<Partial<SchemaAttribute>[]>;
export declare function getSchemaAttributes({ client, options, }: GetSchemaAttributesFnInput): Promise<Partial<SchemaAttribute>[]>;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSchemaAttributes = void 0;
const ldap_ts_client_1 = require("ldap-ts-client");
const naming_context_1 = require("./naming-context");
/** get defined an attribute objects in the schema. */
async function getSchemaAttributes({ schemaDn, options, }) {
async function getSchemaAttributes({ client, options, }) {
var _a;
(_a = options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSchemaAttributes()");
const client = new ldap_ts_client_1.Client({
user: options.user,
pass: options.pass,
ldapServerUrl: options.ldapServerUrl,
baseDN: schemaDn,
logger: options.logger,
(_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSchemaAttributes()");
const schemaDn = await naming_context_1.getSchemaNamingContext({
client,
options: { logger: options === null || options === void 0 ? void 0 : options.logger },
});
const objectAttributes = await client.queryAttributes({
base: schemaDn,
attributes: [

@@ -38,3 +36,2 @@ "cn",

});
await client.unbind();
return objectAttributes;

@@ -41,0 +38,0 @@ }

@@ -1,5 +0,9 @@

import { IClientConfig } from "ldap-ts-client";
interface GetSchemaCapabilitiesFnInput {
options: Omit<IClientConfig, "baseDN">;
}
import type { Client } from "ldap-ts-client";
import type { Logger } from "fast-node-logger";
declare type GetSchemaCapabilitiesFnInput = {
options?: {
logger?: Logger;
};
client: Client;
};
declare type GetSchemaCapabilitiesFnOutput = Promise<string[]>;

@@ -9,3 +13,3 @@ /** get schema capabilities from RootDSE

*/
export declare function getSchemaCapabilities({ options, }: GetSchemaCapabilitiesFnInput): GetSchemaCapabilitiesFnOutput;
export declare function getSchemaCapabilities({ client, options, }: GetSchemaCapabilitiesFnInput): GetSchemaCapabilitiesFnOutput;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSchemaCapabilities = void 0;
const ldap_ts_client_1 = require("ldap-ts-client");
/** get schema capabilities from RootDSE
* - A multiple-valued attribute that contains the capabilities supported by this directory server.
*/
async function getSchemaCapabilities({ options, }) {
async function getSchemaCapabilities({ client, options, }) {
var _a;
(_a = options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSchemaCapabilities()");
const client = new ldap_ts_client_1.Client({
user: options.user,
pass: options.pass,
ldapServerUrl: options.ldapServerUrl,
baseDN: "",
logger: options.logger,
});
(_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSchemaCapabilities()");
const data = await client.queryAttributes({
base: "",
attributes: ["supportedCapabilities"],

@@ -25,3 +18,2 @@ options: {

});
client.unbind();
return data[0].supportedCapabilities;

@@ -28,0 +20,0 @@ }

@@ -1,3 +0,3 @@

import { IClientConfig } from "ldap-ts-client";
import { SearchEntryObject, ObjectClass, CN, InstanceType, SubClassOf, AuxiliaryClass, SystemAuxiliaryClass, GovernsID, RDnAttId, ShowInAdvancedViewOnly, AdminDisplayName, AdminDescription, ObjectClassCategory, LDAPDisplayName, Name, SystemOnly, SystemPossSuperiors, SystemMayContain, SystemMustContain, SystemFlags, DefaultHidingValue, ObjectCategory, DefaultObjectCategory, MustContain, MayContain, PossSuperiors } from "../typings/general/types";
import type { Client } from "ldap-ts-client";
import type { SearchEntryObject, ObjectClass, CN, InstanceType, SubClassOf, AuxiliaryClass, SystemAuxiliaryClass, GovernsID, RDnAttId, ShowInAdvancedViewOnly, AdminDisplayName, AdminDescription, ObjectClassCategory, LDAPDisplayName, Name, SystemOnly, SystemPossSuperiors, SystemMayContain, SystemMustContain, SystemFlags, DefaultHidingValue, ObjectCategory, DefaultObjectCategory, MustContain, MayContain, PossSuperiors, Logger } from "../typings/general/types";
export interface SchemaClass extends Pick<SearchEntryObject, "dn" | "controls"> {

@@ -31,19 +31,25 @@ objectClass: ObjectClass;

declare type GetSchemaClassesFnInput = {
schemaDn: string;
options: Omit<IClientConfig, "baseDN">;
client: Client;
options?: {
logger?: Logger;
};
};
/** get defined classSchema Objects in schema */
export declare function getSchemaClasses({ schemaDn, options, }: GetSchemaClassesFnInput): Promise<Partial<SchemaClass>[]>;
export declare function getSchemaClasses({ client, options, }: GetSchemaClassesFnInput): Promise<Partial<SchemaClass>[]>;
declare type GetStructuralSchemaClassesFnInput = {
schemaDn: string;
options: Omit<IClientConfig, "baseDN">;
client: Client;
options?: {
logger?: Logger;
};
};
/** get defined classSchema Objects in schema where objectClassCategory=1 */
export declare function getStructuralSchemaClasses({ schemaDn, options, }: GetStructuralSchemaClassesFnInput): Promise<Partial<SchemaClass>[]>;
export declare function getStructuralSchemaClasses({ client, options, }: GetStructuralSchemaClassesFnInput): Promise<Partial<SchemaClass>[]>;
declare type GetSchemaClassByLdapNameFnInput = {
schemaDn: string;
client: Client;
ldapName: string;
options: Omit<IClientConfig, "baseDN">;
options?: {
logger?: Logger;
};
};
export declare function getSchemaClassByLdapName({ options, schemaDn, ldapName, }: GetSchemaClassByLdapNameFnInput): Promise<Partial<SchemaClass>[]>;
export declare function getSchemaClassByLdapName({ options, client, ldapName, }: GetSchemaClassByLdapNameFnInput): Promise<Partial<SchemaClass>[]>;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSchemaClassByLdapName = exports.getStructuralSchemaClasses = exports.getSchemaClasses = void 0;
const ldap_ts_client_1 = require("ldap-ts-client");
const ldap_query_generator_1 = require("ldap-query-generator");
const naming_context_1 = require("./naming-context");
/** get defined classSchema Objects in schema */
async function getSchemaClasses({ schemaDn, options, }) {
async function getSchemaClasses({ client, options, }) {
var _a;
(_a = options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSchemaClasses()");
const client = new ldap_ts_client_1.Client({
user: options.user,
pass: options.pass,
ldapServerUrl: options.ldapServerUrl,
baseDN: schemaDn,
logger: options.logger,
(_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSchemaClasses()");
const schemaDn = await naming_context_1.getSchemaNamingContext({
client,
options: { logger: options === null || options === void 0 ? void 0 : options.logger },
});
const objectClasses = await client.queryAttributes({
base: schemaDn,
attributes: [

@@ -52,3 +50,2 @@ "objectClass",

});
await client.unbind();
return objectClasses;

@@ -58,13 +55,11 @@ }

/** get defined classSchema Objects in schema where objectClassCategory=1 */
async function getStructuralSchemaClasses({ schemaDn, options, }) {
async function getStructuralSchemaClasses({ client, options, }) {
var _a;
(_a = options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSchemaClasses()");
const client = new ldap_ts_client_1.Client({
user: options.user,
pass: options.pass,
ldapServerUrl: options.ldapServerUrl,
baseDN: schemaDn,
logger: options.logger,
(_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSchemaClasses()");
const schemaDn = await naming_context_1.getSchemaNamingContext({
client,
options: { logger: options === null || options === void 0 ? void 0 : options.logger },
});
const objectClasses = await client.queryAttributes({
base: schemaDn,
attributes: [

@@ -104,18 +99,14 @@ "objectClass",

});
client.unbind();
return objectClasses;
}
exports.getStructuralSchemaClasses = getStructuralSchemaClasses;
async function getSchemaClassByLdapName({ options, schemaDn, ldapName, }) {
async function getSchemaClassByLdapName({ options, client, ldapName, }) {
var _a;
(_a = options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSchemaClassByLdapName()");
const client = new ldap_ts_client_1.Client({
user: options.user,
pass: options.pass,
ldapServerUrl: options.ldapServerUrl,
baseDN: schemaDn,
logger: options.logger,
(_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSchemaClassByLdapName()");
const schemaDn = await naming_context_1.getSchemaNamingContext({
client,
options: { logger: options === null || options === void 0 ? void 0 : options.logger },
});
const qGen = new ldap_query_generator_1.QueryGenerator({
logger: options.logger,
logger: options === null || options === void 0 ? void 0 : options.logger,
});

@@ -157,2 +148,3 @@ const { query } = qGen

const objectClass = await client.queryAttributes({
base: schemaDn,
attributes: query.attributes,

@@ -166,3 +158,2 @@ options: {

});
client.unbind();
return objectClass;

@@ -169,0 +160,0 @@ }

@@ -1,5 +0,9 @@

import { IClientConfig } from "ldap-ts-client";
interface GetSchemaControlsFnInput {
options: Omit<IClientConfig, "baseDN">;
}
import type { Client } from "ldap-ts-client";
import type { Logger } from "fast-node-logger";
declare type GetSchemaControlsFnInput = {
client: Client;
options?: {
logger?: Logger;
};
};
/** get schema controls from RootDSE

@@ -9,3 +13,3 @@ * - A multiple-valued attribute that contains the OIDs for extension controls supported by this directory server. See the table below for a list of the possible control OIDs.

declare type GetSchemaControlsFnOutput = Promise<string[]>;
export declare function getSchemaControls({ options, }: GetSchemaControlsFnInput): GetSchemaControlsFnOutput;
export declare function getSchemaControls({ options, client, }: GetSchemaControlsFnInput): GetSchemaControlsFnOutput;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSchemaControls = void 0;
const ldap_ts_client_1 = require("ldap-ts-client");
async function getSchemaControls({ options, }) {
async function getSchemaControls({ options, client, }) {
var _a;
(_a = options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSchemaControls()");
const client = new ldap_ts_client_1.Client(Object.assign(Object.assign({}, options), { baseDN: "", logger: options.logger }));
(_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSchemaControls()");
const data = await client.queryAttributes({
base: "",
attributes: ["supportedControl"],

@@ -16,3 +15,2 @@ options: {

});
client.unbind();
return data[0].supportedControl;

@@ -19,0 +17,0 @@ }

@@ -1,9 +0,13 @@

import { IClientConfig } from "ldap-ts-client";
interface GetSchemaExtensionsFnInput {
options: Omit<IClientConfig, "baseDN">;
}
import type { Client } from "ldap-ts-client";
import type { Logger } from "fast-node-logger";
declare type GetSchemaExtensionsFnInput = {
options?: {
logger?: Logger;
};
client: Client;
};
/** get schema extensions from RootDSE.
* - A supported extension is a mechanism for identifying the Extended Request supported by the Directory Server. The OIDs of these extended operations are listed in the supportedExtension attribute of the server's root DSE.
*/
export declare function getSchemaExtensions({ options, }: GetSchemaExtensionsFnInput): Promise<string[]>;
export declare function getSchemaExtensions({ options, client, }: GetSchemaExtensionsFnInput): Promise<string[]>;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSchemaExtensions = void 0;
const ldap_ts_client_1 = require("ldap-ts-client");
/** get schema extensions from RootDSE.
* - A supported extension is a mechanism for identifying the Extended Request supported by the Directory Server. The OIDs of these extended operations are listed in the supportedExtension attribute of the server's root DSE.
*/
async function getSchemaExtensions({ options, }) {
async function getSchemaExtensions({ options, client, }) {
var _a;
(_a = options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSchemaExtensions()");
const client = new ldap_ts_client_1.Client(Object.assign(Object.assign({}, options), { baseDN: "", logger: options.logger }));
(_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSchemaExtensions()");
const data = await client.queryAttributes({
base: "",
attributes: ["supportedExtension"],

@@ -19,3 +18,2 @@ options: {

});
client.unbind();
return data[0].supportedExtension;

@@ -22,0 +20,0 @@ }

@@ -1,4 +0,8 @@

import { IClientConfig } from "ldap-ts-client";
import type { Client } from "ldap-ts-client";
import type { Logger } from "fast-node-logger";
interface GetSupportedLdapVersionsFnInput {
options: Omit<IClientConfig, "baseDN">;
options?: {
logger?: Logger;
};
client: Client;
}

@@ -8,3 +12,3 @@ /** get supported LDAP versions from RootDSE

*/
export declare function getSupportedLdapVersions({ options, }: GetSupportedLdapVersionsFnInput): Promise<string[]>;
export declare function getSupportedLdapVersions({ options, client, }: GetSupportedLdapVersionsFnInput): Promise<string[]>;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSupportedLdapVersions = void 0;
const ldap_ts_client_1 = require("ldap-ts-client");
/** get supported LDAP versions from RootDSE
* - A multiple-valued attribute that contains the LDAP versions (specified by major version number) supported by this directory server.
*/
async function getSupportedLdapVersions({ options, }) {
async function getSupportedLdapVersions({ options, client, }) {
var _a;
(_a = options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSupportedLdapVersions()");
const client = new ldap_ts_client_1.Client(Object.assign(Object.assign({}, options), { baseDN: "", logger: options.logger }));
(_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSupportedLdapVersions()");
const data = await client.queryAttributes({
base: "",
attributes: ["supportedLDAPVersion"],

@@ -19,3 +18,2 @@ options: {

});
client.unbind();
return data[0].supportedLDAPVersion;

@@ -22,0 +20,0 @@ }

@@ -1,7 +0,10 @@

import { IClientConfig } from "ldap-ts-client";
import type { Client } from "ldap-ts-client";
import type { SearchEntryObject, CN, AttributeID, AttributeSyntax, IsSingleValued, AdminDisplayName, AdminDescription, LDAPDisplayName, SystemOnly, LinkID } from "../typings/general/types";
interface GetSchemaAttributesFnInput {
schemaDn: string;
options: Omit<IClientConfig, "baseDN">;
}
import type { Logger } from "fast-node-logger";
declare type GetSchemaAttributesFnInput = {
client: Client;
options?: {
logger: Logger;
};
};
export interface SchemaLinkAttribute extends Pick<SearchEntryObject, "dn" | "controls"> {

@@ -21,3 +24,3 @@ cn: CN;

*/
export declare function getLinkIds({ schemaDn, options, }: GetSchemaAttributesFnInput): Promise<SchemaLinkAttribute[]>;
export declare function getLinkIds({ client, options, }: GetSchemaAttributesFnInput): Promise<SchemaLinkAttribute[]>;
export declare type Relation = {

@@ -24,0 +27,0 @@ [ldapName: string]: {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRelations = exports.getLinkIds = void 0;
const ldap_ts_client_1 = require("ldap-ts-client");
const utils_1 = require("../helpers/utils");
const fast_node_logger_1 = require("fast-node-logger");
const naming_context_1 = require("./naming-context");
/** get Attributes defined in schema which has linkID
* - LinkID is a Number specified in AttributeSchema for Microsoft Active Directory which indicated a Linked Attribute
*/
async function getLinkIds({ schemaDn, options, }) {
async function getLinkIds({ client, options, }) {
var _a;
(_a = options.logger) === null || _a === void 0 ? void 0 : _a.trace("getLinkIds()");
const client = new ldap_ts_client_1.Client(Object.assign(Object.assign({}, options), { baseDN: schemaDn, logger: options.logger }));
(_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.trace("getLinkIds()");
const schemaDn = await naming_context_1.getSchemaNamingContext({
client,
options: { logger: options === null || options === void 0 ? void 0 : options.logger },
});
const objectAttributes = await client.queryAttributes({
base: schemaDn,
attributes: [

@@ -33,3 +37,2 @@ "cn",

});
client.unbind();
const linkIds = objectAttributes;

@@ -36,0 +39,0 @@ /** sort the result base on linkID field */

@@ -1,25 +0,29 @@

import { IClientConfig } from "ldap-ts-client";
interface GetNamingContextsFnInput {
options: Omit<IClientConfig, "baseDN">;
}
import type { Client } from "ldap-ts-client";
import type { Logger } from "fast-node-logger";
declare type GetNamingContextsFnInput = {
client: Client;
options?: {
logger?: Logger;
};
};
/** get base DNs from RootDSE
* - A multiple-valued attribute that contains the distinguished names for all naming contexts stored on this directory server. By default, a Windows 2000 domain controller contains at least three naming contexts: Schema, Configuration, and one for the domain of which the server is a member.
*/
export declare function getNamingContexts({ options, }: GetNamingContextsFnInput): Promise<string[]>;
export declare function getNamingContexts({ client, options, }: GetNamingContextsFnInput): Promise<string[]>;
/** get DefaultNamingContext from RootDSE
* - Contains the distinguished name for the domain of which this directory server is a member.
*/
export declare function getDefaultNamingContext({ options, }: GetNamingContextsFnInput): Promise<string>;
export declare function getDefaultNamingContext({ options, client, }: GetNamingContextsFnInput): Promise<string>;
/** get SchemaNamingContext from RootDSE
* - Contains the distinguished name for the schema container.
*/
export declare function getSchemaNamingContext({ options, }: GetNamingContextsFnInput): Promise<string>;
export declare function getSchemaNamingContext({ options, client, }: GetNamingContextsFnInput): Promise<string>;
/** get rootDomainNamingContext from RootDSE
* - Contains the distinguished name for the first domain in the forest that contains the domain of which this directory server is a member.
*/
export declare function getRootNamingContext({ options, }: GetNamingContextsFnInput): Promise<string>;
export declare function getRootNamingContext({ options, client, }: GetNamingContextsFnInput): Promise<string>;
/** get configurationNamingContext from RootDSE
* - DN of the Configuration NamingContext
*/
export declare function getConfigurationNamingContext({ options, }: GetNamingContextsFnInput): Promise<string>;
export declare function getConfigurationNamingContext({ options, client, }: GetNamingContextsFnInput): Promise<string>;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getConfigurationNamingContext = exports.getRootNamingContext = exports.getSchemaNamingContext = exports.getDefaultNamingContext = exports.getNamingContexts = void 0;
const ldap_ts_client_1 = require("ldap-ts-client");
/** get base DNs from RootDSE
* - A multiple-valued attribute that contains the distinguished names for all naming contexts stored on this directory server. By default, a Windows 2000 domain controller contains at least three naming contexts: Schema, Configuration, and one for the domain of which the server is a member.
*/
async function getNamingContexts({ options, }) {
async function getNamingContexts({ client, options, }) {
var _a;
(_a = options.logger) === null || _a === void 0 ? void 0 : _a.trace("getNamingContexts()");
const client = new ldap_ts_client_1.Client(Object.assign(Object.assign({}, options), { baseDN: "", logger: options.logger }));
(_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.trace("getNamingContexts()");
const data = await client.queryAttributes({
attributes: ["namingContexts"],
base: "",
options: {

@@ -19,3 +18,2 @@ filter: "(&(objectClass=*))",

});
client.unbind();
return data[0].namingContexts;

@@ -27,8 +25,8 @@ }

*/
async function getDefaultNamingContext({ options, }) {
async function getDefaultNamingContext({ options, client, }) {
var _a;
(_a = options.logger) === null || _a === void 0 ? void 0 : _a.trace("getDefaultNamingContext()");
const client = new ldap_ts_client_1.Client(Object.assign(Object.assign({}, options), { baseDN: "", logger: options.logger }));
(_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.trace("getDefaultNamingContext()");
const data = await client.queryAttributes({
attributes: ["defaultNamingContext"],
base: "",
options: {

@@ -39,3 +37,2 @@ filter: "(&(objectClass=*))",

});
client.unbind();
return data[0].defaultNamingContext;

@@ -47,8 +44,8 @@ }

*/
async function getSchemaNamingContext({ options, }) {
async function getSchemaNamingContext({ options, client, }) {
var _a;
(_a = options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSchemaNamingContext()");
const client = new ldap_ts_client_1.Client(Object.assign(Object.assign({}, options), { baseDN: "", logger: options.logger }));
(_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSchemaNamingContext()");
const data = await client.queryAttributes({
attributes: ["schemaNamingContext"],
base: "",
options: {

@@ -59,3 +56,2 @@ filter: "(&(objectClass=*))",

});
client.unbind();
return data[0].schemaNamingContext;

@@ -67,8 +63,8 @@ }

*/
async function getRootNamingContext({ options, }) {
async function getRootNamingContext({ options, client, }) {
var _a;
(_a = options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSchemaNamingContext()");
const client = new ldap_ts_client_1.Client(Object.assign(Object.assign({}, options), { baseDN: "", logger: options.logger }));
(_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSchemaNamingContext()");
const data = await client.queryAttributes({
attributes: ["rootDomainNamingContext"],
base: "",
options: {

@@ -79,3 +75,2 @@ filter: "(&(objectClass=*))",

});
client.unbind();
return data[0].rootDomainNamingContext;

@@ -87,8 +82,8 @@ }

*/
async function getConfigurationNamingContext({ options, }) {
async function getConfigurationNamingContext({ options, client, }) {
var _a;
(_a = options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSchemaNamingContext()");
const client = new ldap_ts_client_1.Client(Object.assign(Object.assign({}, options), { baseDN: "", logger: options.logger }));
(_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSchemaNamingContext()");
const data = await client.queryAttributes({
attributes: ["configurationNamingContext"],
base: "",
options: {

@@ -99,3 +94,2 @@ filter: "(&(objectClass=*))",

});
client.unbind();
return data[0].configurationNamingContext;

@@ -102,0 +96,0 @@ }

@@ -1,5 +0,9 @@

import { IClientConfig } from "ldap-ts-client";
interface GetSchemaPoliciesFnInput {
options: Omit<IClientConfig, "baseDN">;
}
import type { Client } from "ldap-ts-client";
import type { Logger } from "fast-node-logger";
declare type GetSchemaPoliciesFnInput = {
options?: {
logger?: Logger;
};
client: Client;
};
declare type GetSchemaPoliciesFnOutput = Promise<string[]>;

@@ -9,3 +13,3 @@ /** get schema supported policies from RootDSE

*/
export declare function getSchemaPolicies({ options, }: GetSchemaPoliciesFnInput): GetSchemaPoliciesFnOutput;
export declare function getSchemaPolicies({ options, client, }: GetSchemaPoliciesFnInput): GetSchemaPoliciesFnOutput;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSchemaPolicies = void 0;
const ldap_ts_client_1 = require("ldap-ts-client");
/** get schema supported policies from RootDSE
* - A multiple-valued attribute that contains the names of the supported LDAP management policies.
*/
async function getSchemaPolicies({ options, }) {
async function getSchemaPolicies({ options, client, }) {
var _a;
(_a = options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSchemaPolicies()");
const client = new ldap_ts_client_1.Client(Object.assign(Object.assign({}, options), { baseDN: "", logger: options.logger }));
(_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSchemaPolicies()");
const data = await client.queryAttributes({
base: "",
attributes: ["supportedLDAPPolicies"],

@@ -19,3 +18,2 @@ options: {

});
client.unbind();
return data[0].supportedLDAPPolicies;

@@ -22,0 +20,0 @@ }

@@ -1,12 +0,19 @@

import { IClientConfig } from "ldap-ts-client";
interface GetRootDseFnInput {
options: Omit<IClientConfig, "baseDN">;
}
import type { Client } from "ldap-ts-client";
import type { Logger } from "fast-node-logger";
declare type GetRootDseFnInput = {
options?: {
logger?: Logger;
};
client: Client;
};
/** get RootDSE entries
* - In LDAP 3.0, rootDSE is defined as the root of the directory data tree on a directory server. The rootDSE is not part of any namespace. The purpose of the rootDSE is to provide data about the directory server.
*/
export declare function getRootDSE({ options }: GetRootDseFnInput): Promise<import("ldapjs").SearchEntryObject[]>;
interface GetSubSchemaSubEntryFnInput {
options: Omit<IClientConfig, "baseDN">;
}
export declare function getRootDSE({ options, client }: GetRootDseFnInput): Promise<import("ldapjs").SearchEntryObject[]>;
declare type GetSubSchemaSubEntryFnInput = {
options?: {
logger?: Logger;
};
client: Client;
};
/** get schema SubSchemaSubEntry from RootDSE

@@ -16,3 +23,3 @@ * - Contains the distinguished name for the subSchema object. The subSchema object contains properties that expose the supported attributes (in the attributeTypes property) and classes (in the objectClasses property).

*/
export declare function getSubSchemaSubEntry({ options, }: GetSubSchemaSubEntryFnInput): Promise<string>;
export declare function getSubSchemaSubEntry({ options, client, }: GetSubSchemaSubEntryFnInput): Promise<string>;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSubSchemaSubEntry = exports.getRootDSE = void 0;
const ldap_ts_client_1 = require("ldap-ts-client");
/** get RootDSE entries
* - In LDAP 3.0, rootDSE is defined as the root of the directory data tree on a directory server. The rootDSE is not part of any namespace. The purpose of the rootDSE is to provide data about the directory server.
*/
async function getRootDSE({ options }) {
async function getRootDSE({ options, client }) {
var _a;
(_a = options.logger) === null || _a === void 0 ? void 0 : _a.trace("getRootDSE()");
const client = new ldap_ts_client_1.Client(Object.assign(Object.assign({}, options), { baseDN: "", logger: options.logger }));
(_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.trace("getRootDSE()");
const data = await client.queryAttributes({
base: "",
attributes: ["*"],

@@ -19,3 +18,2 @@ options: {

});
client.unbind();
return data;

@@ -28,7 +26,7 @@ }

*/
async function getSubSchemaSubEntry({ options, }) {
async function getSubSchemaSubEntry({ options, client, }) {
var _a;
(_a = options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSubSchemaSubEntry()");
const client = new ldap_ts_client_1.Client(Object.assign(Object.assign({}, options), { baseDN: "", logger: options.logger }));
(_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSubSchemaSubEntry()");
const data = await client.queryAttributes({
base: "",
attributes: ["subschemaSubentry"],

@@ -40,3 +38,2 @@ options: {

});
client.unbind();
return data[0].subschemaSubentry;

@@ -43,0 +40,0 @@ }

@@ -1,4 +0,8 @@

import { IClientConfig } from "ldap-ts-client";
import type { Client } from "ldap-ts-client";
import type { Logger } from "fast-node-logger";
interface GetSupportedSaslMechanismsFnInput {
options: Omit<IClientConfig, "baseDN">;
options?: {
logger?: Logger;
};
client: Client;
}

@@ -12,3 +16,3 @@ /** get schema supported SASL Mechanisms from RootDSE.

*/
export declare function getSupportedSaslMechanisms({ options, }: GetSupportedSaslMechanismsFnInput): Promise<string[]>;
export declare function getSupportedSaslMechanisms({ options, client, }: GetSupportedSaslMechanismsFnInput): Promise<string[]>;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSupportedSaslMechanisms = void 0;
const ldap_ts_client_1 = require("ldap-ts-client");
/** get schema supported SASL Mechanisms from RootDSE.

@@ -12,7 +11,7 @@ * - Contains the security mechanisms supported for SASL negotiation (see LDAP RFCs). By default, GSSAPI is supported.

*/
async function getSupportedSaslMechanisms({ options, }) {
async function getSupportedSaslMechanisms({ options, client, }) {
var _a;
(_a = options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSupportedSaslMechanisms()");
const client = new ldap_ts_client_1.Client(Object.assign(Object.assign({}, options), { baseDN: "", logger: options.logger }));
(_a = options === null || options === void 0 ? void 0 : options.logger) === null || _a === void 0 ? void 0 : _a.trace("getSupportedSaslMechanisms()");
const data = await client.queryAttributes({
base: "",
attributes: ["supportedSASLMechanisms"],

@@ -24,3 +23,2 @@ options: {

});
client.unbind();
return data[0].supportedSASLMechanisms;

@@ -27,0 +25,0 @@ }

{
"name": "ldap-schema-ts-generator",
"version": "3.9.1",
"version": "4.0.0-beta1",
"description": "Typescript typedef and meta-data generator for LDAP Schema. It can be useful to interact from schema-aware/type-safe LDAP Client with LDAP servers like active directory.",

@@ -52,3 +52,3 @@ "repository": {

"@types/jest": "^25.2.3",
"@types/node": "^14.0.9",
"@types/node": "^14.0.10",
"@typescript-eslint/eslint-plugin": "^3.1.0",

@@ -55,0 +55,0 @@ "@typescript-eslint/parser": "^3.1.0",

@@ -5,16 +5,2 @@ # Typescript typedef and meta-data generator for LDAP Schema

### Functionalities
- generate typescript interfaces for each object class
- generate relations between attributes (json)
- generate graphql schema:
- type for each object class
- basic CRUD operations for each object class
- generate typescript enum for supported:
- controls
- capabilities
- extensions
- policies
- structural classes
### How to use

@@ -27,2 +13,3 @@

```ts
import { Client, IClientConfig } from "ldap-ts-client";
import {

@@ -38,10 +25,10 @@ getSchemaAttributes,

ldapServerUrl: "ldap://domain.com",
baseDn: "DC=domain,DC=com",
};
const client = new Client(options);
const schemaDn = await getSchemaNamingContext({ options });
const objectAttributes = await getSchemaAttributes({ client });
const objectAttributes = await getSchemaAttributes({ schemaDn, options });
const objectClasses = await getSchemaClasses({ client });
const objectClasses = await getSchemaClasses({ schemaDn, options });
await generateInterfaceFiles({ objectAttributes, objectClasses });

@@ -52,16 +39,2 @@ }

### Options:
```ts
options?: {
/** default generated folder of root directory of you project */
outputFolder?: string;
/** use prettier to format generated files. default true */
usePrettier?: boolean;
/** create index file for output folder. default true */
indexFile: boolean;
};
```
### API

@@ -71,5 +44,15 @@

### Result
### Functionalities
creates typescript interface for each LDAP class that exist in schema
- generate typescript interfaces for each object class
- generate relations between attributes (json)
- generate graphql schema:
- type for each object class
- basic CRUD operations for each object class
- generate typescript enum for supported:
- controls
- capabilities
- extensions
- policies
- structural classes

@@ -86,3 +69,2 @@ ### Sample Generated File:

*/
export interface Container extends Top, MsExchBaseClass {

@@ -89,0 +71,0 @@ /** - attributeSyntax: 2.5.5.12

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc