UNPKG

@elsikora/commitizen-plugin-commitlint-ai

Version:
52 lines (48 loc) 1.45 kB
'use strict'; var numeric_constant = require('../constant/numeric.constant.js'); /** * Value object representing an API key */ class ApiKey { VALUE; constructor(value) { if (!value || value.trim().length === 0) { throw new Error("API key cannot be empty"); } this.VALUE = value.trim(); } /** * Check if two API keys are equal * @param {ApiKey} other - The other API key to compare with * @returns {boolean} True if the API keys are equal */ equals(other) { return this.VALUE === other.VALUE; } /** * Get the API key value * @returns {string} The API key value */ getValue() { return this.VALUE; } /** * Check if the API key is valid * @returns {boolean} True if the API key appears to be valid */ isValid() { // Basic validation - just check it's not a placeholder return this.VALUE.length > numeric_constant.MIN_API_KEY_LENGTH && !this.VALUE.includes("your-api-key"); } /** * Get a redacted version of the API key for display * @returns {string} Redacted API key */ toRedacted() { if (this.VALUE.length <= numeric_constant.REDACTED_LENGTH) return "****"; return this.VALUE.slice(0, numeric_constant.REDACTED_LENGTH) + "..." + this.VALUE.slice(-4); } } exports.ApiKey = ApiKey; //# sourceMappingURL=api-key.value-object.js.map