@salespark/toolkit 2.0.1 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +783 -572
- package/dist/index.cjs +1159 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +185 -1
- package/dist/index.d.ts +185 -1
- package/dist/index.js +1145 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -181,6 +181,24 @@ declare function flattenDepth<T = unknown>(array: readonly unknown[], depth?: nu
|
|
|
181
181
|
isStrict?: boolean;
|
|
182
182
|
}): T[];
|
|
183
183
|
|
|
184
|
+
/****************************************************
|
|
185
|
+
* ##: Boolean Parser
|
|
186
|
+
* Converts a value to boolean, supporting common string/number representations
|
|
187
|
+
*
|
|
188
|
+
* Notes:
|
|
189
|
+
* - Accepts "true", "yes", "1", "false", "no", "0" (case/whitespace-insensitive)
|
|
190
|
+
* - Returns default value if not recognized or on error
|
|
191
|
+
* @param {unknown} value - Input value (string | number | boolean | null | undefined)
|
|
192
|
+
* @param {Boolean} def - Default value if input cannot be parsed (default: false)
|
|
193
|
+
* History:
|
|
194
|
+
* 21-08-2025: Created
|
|
195
|
+
****************************************************/
|
|
196
|
+
declare const toBool: (value: unknown, def?: boolean) => boolean;
|
|
197
|
+
/**
|
|
198
|
+
* @deprecated Use `toBool` instead.
|
|
199
|
+
*/
|
|
200
|
+
declare const parseToBool: (value: unknown, def?: boolean) => boolean;
|
|
201
|
+
|
|
184
202
|
/**
|
|
185
203
|
****************************************************
|
|
186
204
|
* ##: Object Property Picker
|
|
@@ -488,13 +506,179 @@ declare const getStringSimilarity: (s1: string, s2: string) => number;
|
|
|
488
506
|
* 21-08-2025: Created
|
|
489
507
|
****************************************************/
|
|
490
508
|
declare const addThousandsSpace: (value: number | string) => string;
|
|
509
|
+
/******************************************************
|
|
510
|
+
* ##: Delay Function
|
|
511
|
+
* Creates a promise that resolves after the specified number of milliseconds
|
|
512
|
+
* @param {Number} ms - Delay in milliseconds (negative values are treated as 0)
|
|
513
|
+
* @returns {Promise<void>} Promise that resolves after the delay
|
|
514
|
+
* History:
|
|
515
|
+
* 25-09-2025: Created
|
|
516
|
+
****************************************************/
|
|
517
|
+
declare const delay: (ms: number) => Promise<void>;
|
|
518
|
+
/******************************************************
|
|
519
|
+
* ##: Enforced Nil/Empty/Textual Null Check
|
|
520
|
+
* Checks if value is null/undefined/empty string or the text values "null" / "undefined" (case-insensitive)
|
|
521
|
+
* @param {unknown} value - Value to check
|
|
522
|
+
* @returns {Boolean} true if value is considered empty-like
|
|
523
|
+
* History:
|
|
524
|
+
* 25-09-2025: Created
|
|
525
|
+
****************************************************/
|
|
526
|
+
declare const isNilTextOrEmpty: (value: unknown) => boolean;
|
|
527
|
+
/******************************************************
|
|
528
|
+
* ##: Modern Currency Formatter (Intl.NumberFormat)
|
|
529
|
+
* Formats currency values using modern Intl.NumberFormat API with configurable locale and currency.
|
|
530
|
+
*
|
|
531
|
+
* Provides flexible currency formatting with optional symbol display,
|
|
532
|
+
* proper decimal handling, and graceful fallback for errors.
|
|
533
|
+
* @param {number|string|null|undefined} value Currency value to format
|
|
534
|
+
* @param {boolean} withoutCurrencySymbol Hide currency symbol (show as decimal)
|
|
535
|
+
* @param {string} currency Currency code (ISO 4217, e.g., "EUR", "USD")
|
|
536
|
+
* @param {string} locale Locale string (e.g., "pt-PT", "en-US")
|
|
537
|
+
* @returns {string} Formatted currency string (e.g., "1.234,56 €" or "1.234,56")
|
|
538
|
+
* History:
|
|
539
|
+
* 25-09-2025: Created
|
|
540
|
+
****************************************************/
|
|
541
|
+
declare const formatCurrency: (value: number | string | null | undefined, withoutCurrencySymbol?: boolean, currency?: string, locale?: string) => string;
|
|
542
|
+
/******************************************************
|
|
543
|
+
* ##: Parse Name into First and Last Components
|
|
544
|
+
* Extracts first and last name from a full name string.
|
|
545
|
+
*
|
|
546
|
+
* Handles edge cases like single names, empty inputs, and multi-word names.
|
|
547
|
+
* Returns first word as firstName and last word as lastName.
|
|
548
|
+
* @param {string|null|undefined} name Full name string to parse
|
|
549
|
+
* @returns {{firstName: string, lastName: string}} Object with firstName and lastName properties
|
|
550
|
+
* History:
|
|
551
|
+
* 25-09-2025: Created
|
|
552
|
+
****************************************************/
|
|
553
|
+
declare const parseName: (name: string | null | undefined) => {
|
|
554
|
+
firstName: string;
|
|
555
|
+
lastName: string;
|
|
556
|
+
};
|
|
557
|
+
/******************************************************
|
|
558
|
+
* ##: Currency Symbol to ISO Code Converter
|
|
559
|
+
* Converts currency symbols (€, £, $) to ISO 4217 currency codes.
|
|
560
|
+
*
|
|
561
|
+
* Maps common currency symbols to their corresponding three-letter codes.
|
|
562
|
+
* Returns "EUR" as fallback for unknown symbols.
|
|
563
|
+
* @param {string|null|undefined} symbol Currency symbol to convert (e.g., "€", "£", "$")
|
|
564
|
+
* @returns {string} ISO 4217 currency code (e.g., "EUR", "GBP", "USD")
|
|
565
|
+
* History:
|
|
566
|
+
* 25-09-2025: Created
|
|
567
|
+
****************************************************/
|
|
568
|
+
declare const symbolToCurrency: (symbol: string | null | undefined) => string;
|
|
569
|
+
/******************************************************
|
|
570
|
+
* ##: ISO Currency Code to Symbol Converter
|
|
571
|
+
* Converts ISO 4217 currency codes to their corresponding symbols.
|
|
572
|
+
*
|
|
573
|
+
* Maps three-letter currency codes to common currency symbols.
|
|
574
|
+
* Returns "€" as fallback for unknown currencies.
|
|
575
|
+
* @param {string|null|undefined} currency ISO 4217 currency code (e.g., "EUR", "GBP", "USD")
|
|
576
|
+
* @returns {string} Currency symbol (e.g., "€", "£", "$")
|
|
577
|
+
* History:
|
|
578
|
+
* 25-09-2025: Created
|
|
579
|
+
****************************************************/
|
|
580
|
+
declare const currencyToSymbol: (currency: string | null | undefined) => string;
|
|
581
|
+
/**
|
|
582
|
+
* @deprecated Use `isNilTextOrEmpty` instead.
|
|
583
|
+
*/
|
|
584
|
+
declare const isNullUndefinedOrEmptyEnforced: (value: unknown) => boolean;
|
|
491
585
|
/**
|
|
492
586
|
* @deprecated Use `addThousandsSpace` instead.
|
|
493
587
|
*/
|
|
494
588
|
declare const addSpaceBetweenNumbers: (value: number | string) => string;
|
|
495
589
|
|
|
590
|
+
/******************************************************
|
|
591
|
+
* ##: Portuguese Tax ID (NIF) Validator
|
|
592
|
+
* Validates a Portuguese tax identification number ("NIF").
|
|
593
|
+
*
|
|
594
|
+
* Rules / Notes:
|
|
595
|
+
* - Exactly 9 digits.
|
|
596
|
+
* - Check digit (last digit) via Mod11 weights 9..2 over first 8 digits.
|
|
597
|
+
* sum = Σ(d[i]*w[i]); mod = sum % 11; check = (mod < 2 ? 0 : 11 - mod).
|
|
598
|
+
* - Allowed leading digits: 1,2,3,5,6,8,9.
|
|
599
|
+
* - Strips non-digit characters.
|
|
600
|
+
* - Rejects repeated digit sequences (e.g., 000000000).
|
|
601
|
+
* @param value Raw input to validate (string or number)
|
|
602
|
+
* @returns true if valid, otherwise false.
|
|
603
|
+
* History:
|
|
604
|
+
* 25-09-2025: Created as isValidPTTaxId
|
|
605
|
+
****************************************************/
|
|
606
|
+
declare function isPTTaxId(value: string | number): boolean;
|
|
607
|
+
/**
|
|
608
|
+
* @deprecated Use isPTTaxId instead.
|
|
609
|
+
*/
|
|
610
|
+
declare const isValidPTTaxId: typeof isPTTaxId;
|
|
611
|
+
|
|
612
|
+
/******************************************************
|
|
613
|
+
* ##: IBAN (International Bank Account Number) Validator
|
|
614
|
+
* Validates International Bank Account Numbers according to ISO 13616.
|
|
615
|
+
*
|
|
616
|
+
* Rules / Notes:
|
|
617
|
+
* - Country-specific format and length validation
|
|
618
|
+
* - MOD-97 checksum validation
|
|
619
|
+
* - BBAN (Basic Bank Account Number) format validation
|
|
620
|
+
* - Supports all IBAN registry countries
|
|
621
|
+
* - Strips spaces and formatting automatically
|
|
622
|
+
* @param value Raw IBAN input to validate (string)
|
|
623
|
+
* @returns true if valid IBAN, otherwise false.
|
|
624
|
+
* History:
|
|
625
|
+
* 25-09-2025: Adapted from ibantools library for SalesPark toolkit
|
|
626
|
+
****************************************************/
|
|
627
|
+
declare function isValidIBAN(value: string): boolean;
|
|
628
|
+
|
|
629
|
+
/******************************************************
|
|
630
|
+
* ##: Markdown Security Checker
|
|
631
|
+
* Analyzes markdown text for potential security risks and XSS vulnerabilities.
|
|
632
|
+
*
|
|
633
|
+
* Detects dangerous HTML tags, JavaScript injection attempts, suspicious protocols,
|
|
634
|
+
* and other security threats. Provides sanitized output with detailed risk assessment.
|
|
635
|
+
* @param {string|null|undefined} markdownText Markdown content to analyze
|
|
636
|
+
* @returns {{isValid: boolean, text: string, risks: Array}} Security analysis result
|
|
637
|
+
* History:
|
|
638
|
+
* 25-09-2025: Created
|
|
639
|
+
****************************************************/
|
|
640
|
+
interface SecurityRisk {
|
|
641
|
+
type: string;
|
|
642
|
+
description: string;
|
|
643
|
+
severity?: 'low' | 'medium' | 'high' | 'critical';
|
|
644
|
+
}
|
|
645
|
+
interface SecurityCheckResult {
|
|
646
|
+
isValid: boolean;
|
|
647
|
+
text: string;
|
|
648
|
+
risks: SecurityRisk[];
|
|
649
|
+
sanitized: boolean;
|
|
650
|
+
}
|
|
651
|
+
declare const checkMarkdownSecurity: (markdownText: string | null | undefined) => SecurityCheckResult;
|
|
652
|
+
/******************************************************
|
|
653
|
+
* ##: HTML/Markdown Sanitizer
|
|
654
|
+
* Removes potentially dangerous HTML elements and attributes from text.
|
|
655
|
+
*
|
|
656
|
+
* More aggressive sanitization for when security is paramount.
|
|
657
|
+
* Strips all HTML tags and suspicious content.
|
|
658
|
+
* @param {string|null|undefined} text Text to sanitize
|
|
659
|
+
* @returns {string} Sanitized text with dangerous content removed
|
|
660
|
+
* History:
|
|
661
|
+
* 25-09-2025: Created
|
|
662
|
+
****************************************************/
|
|
663
|
+
declare const sanitizeMarkdown: (text: string | null | undefined) => string;
|
|
664
|
+
/******************************************************
|
|
665
|
+
* ##: Security Risk Assessment
|
|
666
|
+
* Provides a security risk score and recommendations based on detected risks.
|
|
667
|
+
*
|
|
668
|
+
* Calculates risk score and provides actionable security recommendations.
|
|
669
|
+
* @param {SecurityRisk[]} risks Array of detected security risks
|
|
670
|
+
* @returns {{score: number, level: string, recommendations: string[]}} Risk assessment
|
|
671
|
+
* History:
|
|
672
|
+
* 25-09-2025: Created
|
|
673
|
+
****************************************************/
|
|
674
|
+
declare const assessSecurityRisks: (risks: SecurityRisk[]) => {
|
|
675
|
+
score: number;
|
|
676
|
+
level: "safe" | "low" | "medium" | "high" | "critical";
|
|
677
|
+
recommendations: string[];
|
|
678
|
+
};
|
|
679
|
+
|
|
496
680
|
/** Environment helpers (runtime-agnostic checks) */
|
|
497
681
|
declare const isBrowser: boolean;
|
|
498
682
|
declare const isNode: boolean;
|
|
499
683
|
|
|
500
|
-
export { addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, basicSanitize, chunk, clamp, cleanObject, compact, debounce, deburr, difference, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrZeroLen, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilText, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrZero, objectToString, omit, otp, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeParseInt, sanitize, shuffle, slugify, sortBy, stringSimilarity, throttle, toInteger, toNumber, uniq, uniqBy };
|
|
684
|
+
export { type SecurityCheckResult, type SecurityRisk, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, delay, difference, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrZeroLen, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeParseInt, sanitize, sanitizeMarkdown, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
|
package/dist/index.d.ts
CHANGED
|
@@ -181,6 +181,24 @@ declare function flattenDepth<T = unknown>(array: readonly unknown[], depth?: nu
|
|
|
181
181
|
isStrict?: boolean;
|
|
182
182
|
}): T[];
|
|
183
183
|
|
|
184
|
+
/****************************************************
|
|
185
|
+
* ##: Boolean Parser
|
|
186
|
+
* Converts a value to boolean, supporting common string/number representations
|
|
187
|
+
*
|
|
188
|
+
* Notes:
|
|
189
|
+
* - Accepts "true", "yes", "1", "false", "no", "0" (case/whitespace-insensitive)
|
|
190
|
+
* - Returns default value if not recognized or on error
|
|
191
|
+
* @param {unknown} value - Input value (string | number | boolean | null | undefined)
|
|
192
|
+
* @param {Boolean} def - Default value if input cannot be parsed (default: false)
|
|
193
|
+
* History:
|
|
194
|
+
* 21-08-2025: Created
|
|
195
|
+
****************************************************/
|
|
196
|
+
declare const toBool: (value: unknown, def?: boolean) => boolean;
|
|
197
|
+
/**
|
|
198
|
+
* @deprecated Use `toBool` instead.
|
|
199
|
+
*/
|
|
200
|
+
declare const parseToBool: (value: unknown, def?: boolean) => boolean;
|
|
201
|
+
|
|
184
202
|
/**
|
|
185
203
|
****************************************************
|
|
186
204
|
* ##: Object Property Picker
|
|
@@ -488,13 +506,179 @@ declare const getStringSimilarity: (s1: string, s2: string) => number;
|
|
|
488
506
|
* 21-08-2025: Created
|
|
489
507
|
****************************************************/
|
|
490
508
|
declare const addThousandsSpace: (value: number | string) => string;
|
|
509
|
+
/******************************************************
|
|
510
|
+
* ##: Delay Function
|
|
511
|
+
* Creates a promise that resolves after the specified number of milliseconds
|
|
512
|
+
* @param {Number} ms - Delay in milliseconds (negative values are treated as 0)
|
|
513
|
+
* @returns {Promise<void>} Promise that resolves after the delay
|
|
514
|
+
* History:
|
|
515
|
+
* 25-09-2025: Created
|
|
516
|
+
****************************************************/
|
|
517
|
+
declare const delay: (ms: number) => Promise<void>;
|
|
518
|
+
/******************************************************
|
|
519
|
+
* ##: Enforced Nil/Empty/Textual Null Check
|
|
520
|
+
* Checks if value is null/undefined/empty string or the text values "null" / "undefined" (case-insensitive)
|
|
521
|
+
* @param {unknown} value - Value to check
|
|
522
|
+
* @returns {Boolean} true if value is considered empty-like
|
|
523
|
+
* History:
|
|
524
|
+
* 25-09-2025: Created
|
|
525
|
+
****************************************************/
|
|
526
|
+
declare const isNilTextOrEmpty: (value: unknown) => boolean;
|
|
527
|
+
/******************************************************
|
|
528
|
+
* ##: Modern Currency Formatter (Intl.NumberFormat)
|
|
529
|
+
* Formats currency values using modern Intl.NumberFormat API with configurable locale and currency.
|
|
530
|
+
*
|
|
531
|
+
* Provides flexible currency formatting with optional symbol display,
|
|
532
|
+
* proper decimal handling, and graceful fallback for errors.
|
|
533
|
+
* @param {number|string|null|undefined} value Currency value to format
|
|
534
|
+
* @param {boolean} withoutCurrencySymbol Hide currency symbol (show as decimal)
|
|
535
|
+
* @param {string} currency Currency code (ISO 4217, e.g., "EUR", "USD")
|
|
536
|
+
* @param {string} locale Locale string (e.g., "pt-PT", "en-US")
|
|
537
|
+
* @returns {string} Formatted currency string (e.g., "1.234,56 €" or "1.234,56")
|
|
538
|
+
* History:
|
|
539
|
+
* 25-09-2025: Created
|
|
540
|
+
****************************************************/
|
|
541
|
+
declare const formatCurrency: (value: number | string | null | undefined, withoutCurrencySymbol?: boolean, currency?: string, locale?: string) => string;
|
|
542
|
+
/******************************************************
|
|
543
|
+
* ##: Parse Name into First and Last Components
|
|
544
|
+
* Extracts first and last name from a full name string.
|
|
545
|
+
*
|
|
546
|
+
* Handles edge cases like single names, empty inputs, and multi-word names.
|
|
547
|
+
* Returns first word as firstName and last word as lastName.
|
|
548
|
+
* @param {string|null|undefined} name Full name string to parse
|
|
549
|
+
* @returns {{firstName: string, lastName: string}} Object with firstName and lastName properties
|
|
550
|
+
* History:
|
|
551
|
+
* 25-09-2025: Created
|
|
552
|
+
****************************************************/
|
|
553
|
+
declare const parseName: (name: string | null | undefined) => {
|
|
554
|
+
firstName: string;
|
|
555
|
+
lastName: string;
|
|
556
|
+
};
|
|
557
|
+
/******************************************************
|
|
558
|
+
* ##: Currency Symbol to ISO Code Converter
|
|
559
|
+
* Converts currency symbols (€, £, $) to ISO 4217 currency codes.
|
|
560
|
+
*
|
|
561
|
+
* Maps common currency symbols to their corresponding three-letter codes.
|
|
562
|
+
* Returns "EUR" as fallback for unknown symbols.
|
|
563
|
+
* @param {string|null|undefined} symbol Currency symbol to convert (e.g., "€", "£", "$")
|
|
564
|
+
* @returns {string} ISO 4217 currency code (e.g., "EUR", "GBP", "USD")
|
|
565
|
+
* History:
|
|
566
|
+
* 25-09-2025: Created
|
|
567
|
+
****************************************************/
|
|
568
|
+
declare const symbolToCurrency: (symbol: string | null | undefined) => string;
|
|
569
|
+
/******************************************************
|
|
570
|
+
* ##: ISO Currency Code to Symbol Converter
|
|
571
|
+
* Converts ISO 4217 currency codes to their corresponding symbols.
|
|
572
|
+
*
|
|
573
|
+
* Maps three-letter currency codes to common currency symbols.
|
|
574
|
+
* Returns "€" as fallback for unknown currencies.
|
|
575
|
+
* @param {string|null|undefined} currency ISO 4217 currency code (e.g., "EUR", "GBP", "USD")
|
|
576
|
+
* @returns {string} Currency symbol (e.g., "€", "£", "$")
|
|
577
|
+
* History:
|
|
578
|
+
* 25-09-2025: Created
|
|
579
|
+
****************************************************/
|
|
580
|
+
declare const currencyToSymbol: (currency: string | null | undefined) => string;
|
|
581
|
+
/**
|
|
582
|
+
* @deprecated Use `isNilTextOrEmpty` instead.
|
|
583
|
+
*/
|
|
584
|
+
declare const isNullUndefinedOrEmptyEnforced: (value: unknown) => boolean;
|
|
491
585
|
/**
|
|
492
586
|
* @deprecated Use `addThousandsSpace` instead.
|
|
493
587
|
*/
|
|
494
588
|
declare const addSpaceBetweenNumbers: (value: number | string) => string;
|
|
495
589
|
|
|
590
|
+
/******************************************************
|
|
591
|
+
* ##: Portuguese Tax ID (NIF) Validator
|
|
592
|
+
* Validates a Portuguese tax identification number ("NIF").
|
|
593
|
+
*
|
|
594
|
+
* Rules / Notes:
|
|
595
|
+
* - Exactly 9 digits.
|
|
596
|
+
* - Check digit (last digit) via Mod11 weights 9..2 over first 8 digits.
|
|
597
|
+
* sum = Σ(d[i]*w[i]); mod = sum % 11; check = (mod < 2 ? 0 : 11 - mod).
|
|
598
|
+
* - Allowed leading digits: 1,2,3,5,6,8,9.
|
|
599
|
+
* - Strips non-digit characters.
|
|
600
|
+
* - Rejects repeated digit sequences (e.g., 000000000).
|
|
601
|
+
* @param value Raw input to validate (string or number)
|
|
602
|
+
* @returns true if valid, otherwise false.
|
|
603
|
+
* History:
|
|
604
|
+
* 25-09-2025: Created as isValidPTTaxId
|
|
605
|
+
****************************************************/
|
|
606
|
+
declare function isPTTaxId(value: string | number): boolean;
|
|
607
|
+
/**
|
|
608
|
+
* @deprecated Use isPTTaxId instead.
|
|
609
|
+
*/
|
|
610
|
+
declare const isValidPTTaxId: typeof isPTTaxId;
|
|
611
|
+
|
|
612
|
+
/******************************************************
|
|
613
|
+
* ##: IBAN (International Bank Account Number) Validator
|
|
614
|
+
* Validates International Bank Account Numbers according to ISO 13616.
|
|
615
|
+
*
|
|
616
|
+
* Rules / Notes:
|
|
617
|
+
* - Country-specific format and length validation
|
|
618
|
+
* - MOD-97 checksum validation
|
|
619
|
+
* - BBAN (Basic Bank Account Number) format validation
|
|
620
|
+
* - Supports all IBAN registry countries
|
|
621
|
+
* - Strips spaces and formatting automatically
|
|
622
|
+
* @param value Raw IBAN input to validate (string)
|
|
623
|
+
* @returns true if valid IBAN, otherwise false.
|
|
624
|
+
* History:
|
|
625
|
+
* 25-09-2025: Adapted from ibantools library for SalesPark toolkit
|
|
626
|
+
****************************************************/
|
|
627
|
+
declare function isValidIBAN(value: string): boolean;
|
|
628
|
+
|
|
629
|
+
/******************************************************
|
|
630
|
+
* ##: Markdown Security Checker
|
|
631
|
+
* Analyzes markdown text for potential security risks and XSS vulnerabilities.
|
|
632
|
+
*
|
|
633
|
+
* Detects dangerous HTML tags, JavaScript injection attempts, suspicious protocols,
|
|
634
|
+
* and other security threats. Provides sanitized output with detailed risk assessment.
|
|
635
|
+
* @param {string|null|undefined} markdownText Markdown content to analyze
|
|
636
|
+
* @returns {{isValid: boolean, text: string, risks: Array}} Security analysis result
|
|
637
|
+
* History:
|
|
638
|
+
* 25-09-2025: Created
|
|
639
|
+
****************************************************/
|
|
640
|
+
interface SecurityRisk {
|
|
641
|
+
type: string;
|
|
642
|
+
description: string;
|
|
643
|
+
severity?: 'low' | 'medium' | 'high' | 'critical';
|
|
644
|
+
}
|
|
645
|
+
interface SecurityCheckResult {
|
|
646
|
+
isValid: boolean;
|
|
647
|
+
text: string;
|
|
648
|
+
risks: SecurityRisk[];
|
|
649
|
+
sanitized: boolean;
|
|
650
|
+
}
|
|
651
|
+
declare const checkMarkdownSecurity: (markdownText: string | null | undefined) => SecurityCheckResult;
|
|
652
|
+
/******************************************************
|
|
653
|
+
* ##: HTML/Markdown Sanitizer
|
|
654
|
+
* Removes potentially dangerous HTML elements and attributes from text.
|
|
655
|
+
*
|
|
656
|
+
* More aggressive sanitization for when security is paramount.
|
|
657
|
+
* Strips all HTML tags and suspicious content.
|
|
658
|
+
* @param {string|null|undefined} text Text to sanitize
|
|
659
|
+
* @returns {string} Sanitized text with dangerous content removed
|
|
660
|
+
* History:
|
|
661
|
+
* 25-09-2025: Created
|
|
662
|
+
****************************************************/
|
|
663
|
+
declare const sanitizeMarkdown: (text: string | null | undefined) => string;
|
|
664
|
+
/******************************************************
|
|
665
|
+
* ##: Security Risk Assessment
|
|
666
|
+
* Provides a security risk score and recommendations based on detected risks.
|
|
667
|
+
*
|
|
668
|
+
* Calculates risk score and provides actionable security recommendations.
|
|
669
|
+
* @param {SecurityRisk[]} risks Array of detected security risks
|
|
670
|
+
* @returns {{score: number, level: string, recommendations: string[]}} Risk assessment
|
|
671
|
+
* History:
|
|
672
|
+
* 25-09-2025: Created
|
|
673
|
+
****************************************************/
|
|
674
|
+
declare const assessSecurityRisks: (risks: SecurityRisk[]) => {
|
|
675
|
+
score: number;
|
|
676
|
+
level: "safe" | "low" | "medium" | "high" | "critical";
|
|
677
|
+
recommendations: string[];
|
|
678
|
+
};
|
|
679
|
+
|
|
496
680
|
/** Environment helpers (runtime-agnostic checks) */
|
|
497
681
|
declare const isBrowser: boolean;
|
|
498
682
|
declare const isNode: boolean;
|
|
499
683
|
|
|
500
|
-
export { addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, basicSanitize, chunk, clamp, cleanObject, compact, debounce, deburr, difference, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrZeroLen, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilText, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrZero, objectToString, omit, otp, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeParseInt, sanitize, shuffle, slugify, sortBy, stringSimilarity, throttle, toInteger, toNumber, uniq, uniqBy };
|
|
684
|
+
export { type SecurityCheckResult, type SecurityRisk, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, delay, difference, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrZeroLen, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeParseInt, sanitize, sanitizeMarkdown, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
|