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 2.0.0 to 2.1.0

dist/helpers/write-to-file.d.ts

5

dist/app.js

@@ -20,4 +20,5 @@ "use strict";

const schemaDn = await index_1.getSchemaNamingContext({ options });
const linkIds = await index_1.getLinkIds({ options, schemaDn });
console.log(`File: app.ts,`, `Line: 37 => `, linkIds[0], linkIds[1]);
// const linkIds = await getLinkIds({ options, schemaDn });
// const relations = getRelations(linkIds);
// await generateRelationsFile({ relations });
// const controls = await getSchemaControls({ options });

@@ -24,0 +25,0 @@ // await generateControlsFile({ controls });

2

dist/helpers/utils.d.ts

@@ -11,1 +11,3 @@ /** make sure output is string */

export declare function dirPathExist(targetPath: string): Promise<boolean>;
/** check if number odd */
export declare function isOdd(input: number): boolean;

@@ -58,2 +58,11 @@ "use strict";

exports.dirPathExist = dirPathExist;
/** check if number odd */
function isOdd(input) {
fast_node_logger_1.writeLog(`isOdd()`, { level: "trace" });
if (input % 2 === 0) {
return false;
}
return true;
}
exports.isOdd = isOdd;
//# sourceMappingURL=utils.js.map
export declare const defaultOutDir: string;
export declare const defaultInterfacesDir: string;
export declare const defaultEnumsDir: string;
export declare const defaultJsonDir: string;

@@ -10,2 +10,3 @@ "use strict";

exports.defaultEnumsDir = path_1.default.join(exports.defaultOutDir, "enums");
exports.defaultJsonDir = path_1.default.join(exports.defaultOutDir, "json");
//# sourceMappingURL=variables.js.map

@@ -7,2 +7,3 @@ export * from "./services";

import { generatePoliciesFile } from "./templates/generate-policies-file";
export { generateInterfaceFiles, generateControlsFile, generateCapabilitiesFile, generateExtensionsFile, generatePoliciesFile, };
import { generateRelationsFile } from "./templates/generate-relations-file";
export { generateInterfaceFiles, generateControlsFile, generateCapabilitiesFile, generateExtensionsFile, generatePoliciesFile, generateRelationsFile, };

@@ -17,2 +17,4 @@ "use strict";

exports.generatePoliciesFile = generate_policies_file_1.generatePoliciesFile;
const generate_relations_file_1 = require("./templates/generate-relations-file");
exports.generateRelationsFile = generate_relations_file_1.generateRelationsFile;
//# sourceMappingURL=index.js.map

@@ -23,7 +23,7 @@ import { Logger } from "../typings/general/types";

/** Defines Relation between attributes
* - Even Attribute Value are forward links
* - Odd Attribute Value are BackLinks equals to the LinkID of the corresponding forward link LinkID plus one.
* - Attribute Value of 0 or not present implies it is NOT a Linked Attribute
* - Even linkID Value are forward links
* - Odd linkID Value are BackLinks equals to the linkID of the corresponding forward link linkID plus one.
* - linkID Value of 0 or not present implies it is NOT a Linked Attribute
*/
linkID: number;
linkID: string;
}

@@ -34,2 +34,23 @@ /** get Attributes defined in schema which has linkID

export declare function getLinkIds({ schemaDn, options, }: GetSchemaAttributesFnInput): Promise<SchemaLinkAttribute[]>;
export interface Relation {
[ldapName: string]: {
isBackLink: boolean;
/** Back Link Attribute LDAP Name (readonly) */
backLink: string;
/** Back Link Attribute Distinguished Name */
backLinkDn: string;
/** Back Link ID */
backLinkId: number;
/** Forward Link Attribute LDAP Name (writable) */
forwardLink: string;
/** Forward Link Attribute Distinguished Name */
forwardLinkDn: string;
/** Forward Link ID */
forwardLinkId: number;
};
}
/** process linkIds
* @return array of relations
*/
export declare function getRelations(linkIds: SchemaLinkAttribute[]): Relation[];
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const node_ad_ldap_1 = require("node-ad-ldap");
const utils_1 = require("../helpers/utils");
const fast_node_logger_1 = require("fast-node-logger");
/** get Attributes defined in schema which has linkID

@@ -43,2 +45,47 @@ * - LinkID is a Number specified in AttributeSchema for Microsoft Active Directory which indicated a Linked Attribute

exports.getLinkIds = getLinkIds;
/** process linkIds
* @return array of relations
*/
function getRelations(linkIds) {
const relations = [];
linkIds.forEach((el) => {
const isBackLink = utils_1.isOdd(Number(el.linkID));
/** find other side of relationship base on LinkID
* - Even linkID Value are forward links
* - Odd linkID Value are BackLinks equals to the linkID of the corresponding forward link linkID plus one.
* - linkID Value of 0 or not present implies it is NOT a Linked Attribute
*/
const otherSideOfRelation = linkIds.find((linkItem) => {
let otherSideOfRelationId;
if (isBackLink) {
otherSideOfRelationId = Number(el.linkID) - 1;
}
else {
otherSideOfRelationId = Number(el.linkID) + 1;
}
return linkItem.linkID === String(otherSideOfRelationId);
});
if (!otherSideOfRelation) {
fast_node_logger_1.writeLog(`relation for ${el.lDAPDisplayName} linkID ${el.linkID} not found!`, {
level: "warn",
stdout: true,
});
/** ignore this relation */
return;
}
relations.push({
[el.lDAPDisplayName]: {
isBackLink,
backLink: el.lDAPDisplayName,
backLinkDn: el.dn,
backLinkId: Number(el.linkID),
forwardLink: otherSideOfRelation.lDAPDisplayName,
forwardLinkDn: otherSideOfRelation.dn,
forwardLinkId: Number(otherSideOfRelation.linkID),
},
});
});
return relations;
}
exports.getRelations = getRelations;
//# sourceMappingURL=link-id.js.map
{
"name": "ldap-schema-ts-generator",
"version": "2.0.0",
"version": "2.1.0",
"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.",

@@ -5,0 +5,0 @@ "repository": {

@@ -154,2 +154,3 @@ # Typescript typedef and meta-data generator for LDAP Schema

- [ ] Active Directory create a functionality to fetch all meta data about server [ref](https://docs.microsoft.com/en-us/windows/win32/adschema/rootdse)
- [ ] add option to customize generated file names with prefix/postfix (now it 's using Pascal case of ldap display name as interface and file name)

@@ -156,0 +157,0 @@ ### Know Issues

@@ -18,2 +18,4 @@ import { config } from "dotenv";

getLinkIds,
getRelations,
generateRelationsFile,
} from "./index";

@@ -36,6 +38,6 @@

const linkIds = await getLinkIds({ options, schemaDn });
// const linkIds = await getLinkIds({ options, schemaDn });
// const relations = getRelations(linkIds);
// await generateRelationsFile({ relations });
console.log(`File: app.ts,`, `Line: 37 => `, linkIds[0], linkIds[1]);
// const controls = await getSchemaControls({ options });

@@ -54,5 +56,3 @@ // await generateControlsFile({ controls });

// const objectAttributes = await getSchemaAttributes({ schemaDn, options });
// const objectClasses = await getSchemaClasses({ schemaDn, options });
// await generateInterfaceFiles({ objectAttributes, objectClasses });

@@ -59,0 +59,0 @@ }

@@ -53,1 +53,10 @@ import { writeLog } from "fast-node-logger";

}
/** check if number odd */
export function isOdd(input: number): boolean {
writeLog(`isOdd()`, { level: "trace" });
if (input % 2 === 0) {
return false;
}
return true;
}

@@ -6,1 +6,2 @@ import path from "path";

export const defaultEnumsDir = path.join(defaultOutDir, "enums");
export const defaultJsonDir = path.join(defaultOutDir, "json");

@@ -8,2 +8,3 @@ export * from "./services";

import { generatePoliciesFile } from "./templates/generate-policies-file";
import { generateRelationsFile } from "./templates/generate-relations-file";

@@ -16,2 +17,3 @@ export {

generatePoliciesFile,
generateRelationsFile,
};
import { AdClient } from "node-ad-ldap";
import { Logger } from "../typings/general/types";
import { SearchEntryObject } from "ldapjs";
import { isOdd } from "../helpers/utils";
import { writeLog } from "fast-node-logger";

@@ -26,7 +28,7 @@ interface GetSchemaAttributesFnInput {

/** Defines Relation between attributes
* - Even Attribute Value are forward links
* - Odd Attribute Value are BackLinks equals to the LinkID of the corresponding forward link LinkID plus one.
* - Attribute Value of 0 or not present implies it is NOT a Linked Attribute
* - Even linkID Value are forward links
* - Odd linkID Value are BackLinks equals to the linkID of the corresponding forward link linkID plus one.
* - linkID Value of 0 or not present implies it is NOT a Linked Attribute
*/
linkID: number;
linkID: string;
}

@@ -78,1 +80,71 @@

}
export interface Relation {
[ldapName: string]: {
isBackLink: boolean;
/** Back Link Attribute LDAP Name (readonly) */
backLink: string;
/** Back Link Attribute Distinguished Name */
backLinkDn: string;
/** Back Link ID */
backLinkId: number;
/** Forward Link Attribute LDAP Name (writable) */
forwardLink: string;
/** Forward Link Attribute Distinguished Name */
forwardLinkDn: string;
/** Forward Link ID */
forwardLinkId: number;
/** boolean flag that shows attribute back link */
};
}
/** process linkIds
* @return array of relations
*/
export function getRelations(linkIds: SchemaLinkAttribute[]): Relation[] {
const relations: Relation[] = [];
linkIds.forEach((el) => {
const isBackLink = isOdd(Number(el.linkID));
/** find other side of relationship base on LinkID
* - Even linkID Value are forward links
* - Odd linkID Value are BackLinks equals to the linkID of the corresponding forward link linkID plus one.
* - linkID Value of 0 or not present implies it is NOT a Linked Attribute
*/
const otherSideOfRelation = linkIds.find((linkItem) => {
let otherSideOfRelationId;
if (isBackLink) {
otherSideOfRelationId = Number(el.linkID) - 1;
} else {
otherSideOfRelationId = Number(el.linkID) + 1;
}
return linkItem.linkID === String(otherSideOfRelationId);
});
if (!otherSideOfRelation) {
writeLog(
`relation for ${el.lDAPDisplayName} linkID ${el.linkID} not found!`,
{
level: "warn",
stdout: true,
},
);
/** ignore this relation */
return;
}
relations.push({
[el.lDAPDisplayName]: {
isBackLink,
backLink: el.lDAPDisplayName,
backLinkDn: el.dn,
backLinkId: Number(el.linkID),
forwardLink: otherSideOfRelation.lDAPDisplayName,
forwardLinkDn: otherSideOfRelation.dn,
forwardLinkId: Number(otherSideOfRelation.linkID),
},
});
});
return relations;
}

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