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.
112 lines (109 loc) • 3 kB
JavaScript
'use strict';
/**
* Constants used throughout the library
*/
/**
* Character sets for token generation
*/
const CHAR_SETS = {
/**
* Uppercase letters
*/
UPPERCASE: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
/**
* Lowercase letters
*/
LOWERCASE: "abcdefghijklmnopqrstuvwxyz",
/**
* Numeric characters
*/
NUMBERS: "0123456789",
/**
* Special symbols
*/
SYMBOLS: "!@#$%^&*()_+-=[]{}|;:,.<>?",
/**
* Similar characters that can be confused
*/
SIMILAR_CHARS: "il1Lo0O",
/**
* Base58 alphabet (Bitcoin style, no similar characters)
*/
BASE58: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",
/**
* Base32 alphabet (RFC 4648)
*/
BASE32: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",
};
/**
* Default security parameters
*/
const SECURITY_DEFAULTS = {
/**
* Default token length
*/
TOKEN_LENGTH: 32,
/**
* Default number of iterations for PBKDF2
*/
PBKDF2_ITERATIONS: 100000,
/**
* Default key length in bytes
*/
KEY_LENGTH: 32,
/**
* Default session token expiration (24 hours in seconds)
*/
SESSION_EXPIRATION: 86400,
/**
* Minimum recommended password length
*/
MIN_PASSWORD_LENGTH: 12,
/**
* Default API key random part length
*/
API_KEY_RANDOM_LENGTH: 24,
};
/**
* Error messages
*/
const ERROR_MESSAGES = {
INVALID_LENGTH: "Invalid length specified",
INVALID_ALGORITHM: "Invalid algorithm specified",
INVALID_ITERATIONS: "Invalid number of iterations specified",
INVALID_SALT: "Invalid salt specified",
INVALID_FORMAT: "Invalid output format specified",
INVALID_ENTROPY: "Invalid entropy level specified",
CRYPTO_UNAVAILABLE: "Cryptographically secure random number generation is not available",
INVALID_TOKEN_TYPE: "Invalid token type specified",
INVALID_API_KEY: "Invalid API key format",
INVALID_SESSION_TOKEN: "Invalid session token format",
WEAK_PASSWORD: "Password does not meet minimum security requirements",
};
// Enhanced security constants
const SECURITY_CONSTANTS = {
MIN_ENTROPY_BITS: 128,
RECOMMENDED_ENTROPY_BITS: 256,
MAX_ENTROPY_BITS: 512,
ENTROPY_POOL_SIZE: 4096,
RESEED_THRESHOLD: 1000000, // Reseed after 1M bytes
MIN_SECURE_LENGTH: 16,
TIMING_ATTACK_DELAY: 100, // milliseconds
QUANTUM_RESISTANCE_BITS: 384,
};
// Hash security constants
const HASH_SECURITY_CONSTANTS = {
MIN_ITERATIONS: 10000,
RECOMMENDED_ITERATIONS: 50000,
HIGH_SECURITY_ITERATIONS: 100000,
MIN_SALT_LENGTH: 16,
RECOMMENDED_SALT_LENGTH: 32,
MAX_SALT_LENGTH: 64,
TIMING_ATTACK_DELAY: 100, // milliseconds
};
exports.CHAR_SETS = CHAR_SETS;
exports.ERROR_MESSAGES = ERROR_MESSAGES;
exports.HASH_SECURITY_CONSTANTS = HASH_SECURITY_CONSTANTS;
exports.SECURITY_CONSTANTS = SECURITY_CONSTANTS;
exports.SECURITY_DEFAULTS = SECURITY_DEFAULTS;
//# sourceMappingURL=constants.js.map