UNPKG

fortify2-js

Version:

MOST POWERFUL JavaScript Security Library! Military-grade cryptography + 19 enhanced object methods + quantum-resistant algorithms + perfect TypeScript support. More powerful than Lodash with built-in security.

65 lines (61 loc) 1.77 kB
'use strict'; var nehoid = require('nehoid'); /** * ID Generator Utility * Generates unique IDs for SecureObject instances */ /** * Generates unique IDs for SecureObject instances */ class IdGenerator { /** * Generates a unique ID for a SecureObject instance */ static generate() { return nehoid.NehoID.generate({ prefix: "sobj", size: 16 }); } /** * Generates a unique ID with custom prefix */ static generateWithPrefix(prefix) { return nehoid.NehoID.generate({ prefix, size: 16 }); } /** * Generates a unique ID with custom size */ static generateWithSize(size) { return nehoid.NehoID.generate({ prefix: "sobj", size }); } /** * Generates a unique ID with custom prefix and size */ static generateCustom(prefix, size) { return nehoid.NehoID.generate({ prefix, size }); } /** * Validates if a string looks like a valid SecureObject ID */ static isValidId(id) { // Basic validation - starts with sobj_ and has reasonable length return typeof id === "string" && id.startsWith("sobj_") && id.length > 10 && id.length < 50; } /** * Extracts the prefix from an ID */ static extractPrefix(id) { const underscoreIndex = id.indexOf("_"); return underscoreIndex > 0 ? id.substring(0, underscoreIndex) : null; } /** * Extracts the unique part from an ID (without prefix) */ static extractUniquePart(id) { const underscoreIndex = id.indexOf("_"); return underscoreIndex > 0 ? id.substring(underscoreIndex + 1) : null; } } exports.IdGenerator = IdGenerator; //# sourceMappingURL=id-generator.js.map