UNPKG

securesharkinputs

Version:

Advanced enterprise validation library with multi-layer security protection for SecureShark

297 lines (225 loc) โ€ข 8.8 kB
# SecureSharkInputs ๐Ÿ›ก๏ธ **Super Simple React Form Validation with Built-in Security** A lightweight TypeScript library that makes form validation incredibly easy while providing enterprise-grade security protection. Just drop in a component and you're protected! ## ๐ŸŽฏ What Does It Do? SecureSharkInputs protects your forms from: - ๐Ÿšซ **XSS Attacks** - Cross-site scripting attempts - ๐Ÿšซ **SQL Injection** - Malicious database queries - ๐Ÿšซ **Data Theft** - Attempts to access sensitive client-side data - ๐Ÿšซ **Inappropriate Content** - Profanity and harmful language - ๐Ÿšซ **Unicode Evasion** - Characters used to bypass filters - ๐Ÿšซ **DOM Manipulation** - Malicious script injection ## ๐Ÿ“ฆ Installation ```bash npm install securesharkinputs ``` **โœจ Templates will be automatically installed!** When you install the package, it will automatically: - โœ… Create a working React form template - โœ… Set up the correct file structure - โœ… Include a setup guide - โœ… Show you exactly how to use it ## ๐Ÿš€ Quick Start ### ๐ŸŽฏ **Super Simple Usage** **Just one component does everything:** ```jsx import ValidationShark from 'securesharkinputs'; // โœ… SUPER SIMPLE - Everything included! <ValidationShark name="email" type="email" label="Email" placeholder="Enter your email" required={true} /> ``` **That's it!** The component automatically: - โœ… Creates the input with proper styling - โœ… Adds the label with required indicator - โœ… Integrates with react-hook-form - โœ… Validates security threats in real-time - โœ… Shows error messages - โœ… Blocks form submission if threats detected ### ๐Ÿ“ **Complete Example** ```jsx "use client"; import React from 'react'; import { useForm } from 'react-hook-form'; import ValidationShark from 'securesharkinputs'; const MyForm = () => { const { handleSubmit } = useForm(); const onSubmit = (data) => { console.log('Form submitted:', data); }; return ( <form onSubmit={handleSubmit(onSubmit)}> <ValidationShark name="name" type="text" label="Name" placeholder="Enter your name" required={true} /> <ValidationShark name="email" type="email" label="Email" placeholder="Enter your email" required={true} /> <button type="submit">Submit</button> </form> ); }; ``` ## ๐ŸŽจ **Template System** When you install the package, you get a complete working template: ```bash npm install securesharkinputs # Template automatically installed to: src/components/SecureSharkForm.tsx ``` **Features of the template:** - โœ… Complete form with all field types - โœ… Console logging for validation events - โœ… Security testing examples - โœ… Ready to use immediately ## ๐Ÿ”ง **Component Props** | Prop | Type | Required | Description | |------|------|----------|-------------| | `name` | string | โœ… | Field name for react-hook-form | | `type` | string | โŒ | Input type (text, email, password, etc.) | | `label` | string | โŒ | Label text | | `placeholder` | string | โŒ | Placeholder text | | `required` | boolean | โŒ | Whether field is required | | `className` | string | โŒ | Additional CSS classes | | `onValid` | function | โŒ | Callback when input is valid | | `onInvalid` | function | โŒ | Callback when threat detected | ### ๐ŸŽฏ **Required Field Validation Example** ```jsx // โœ… Simple required field <ValidationShark name="name" type="text" label="Name" required={true} // โ† This adds automatic validation /> // โœ… The component automatically: // - Shows asterisk (*) in label // - Prevents form submission if empty // - Shows error message // - Integrates with react-hook-form validation ``` ## ๐Ÿ›ก๏ธ **Security Features** ### **Automatic Protection** - **Real-time validation** - Checks every keystroke - **Form blocking** - Prevents submission if threats detected - **Visual feedback** - Shows warnings immediately - **Console logging** - Track validation events ### **Threat Detection** - **XSS Protection**: `<script>alert('xss')</script>` - **SQL Injection**: `'; DROP TABLE users; --` - **Data Theft**: `document.cookie` - **Inappropriate Content**: Profanity and harmful language - **Unicode Evasion**: Special characters used to bypass filters ## ๐Ÿ“š **Documentation** - ๐Ÿ“– [Complete Guide](COMPLETE_GUIDE.md) - Detailed usage examples - ๐Ÿ”— [Connection Verification](CONNECTION_VERIFICATION.md) - Test your implementation ## ๐Ÿงช **Testing** ### **Quick Tests (No Setup Required)** Test your implementation immediately: ```bash # Test basic functionality node node_modules/securesharkinputs/scripts/test-client.js # Test integration node node_modules/securesharkinputs/scripts/test-integration.js # Test connection in your project node node_modules/securesharkinputs/scripts/test-connection.js ``` ### **Add to Your package.json (Recommended)** Add these scripts to your `package.json` for easy access: ```json { "scripts": { "test:shark": "node node_modules/securesharkinputs/scripts/test-client.js", "test:shark-integration": "node node_modules/securesharkinputs/scripts/test-integration.js", "test:shark-connection": "node node_modules/securesharkinputs/scripts/test-connection.js" } } ``` Then run: ```bash npm run test:shark npm run test:shark-integration npm run test:shark-connection ``` ### **What Each Test Does** | Test | Purpose | What It Checks | |------|---------|----------------| | **test-client** | Basic functionality | โœ… Library installation<br>โœ… Component availability<br>โœ… Basic validation | | **test-integration** | Complete integration | โœ… All features working<br>โœ… Template installation<br>โœ… Security validation | | **test-connection** | Real protection | โœ… Input protection in your code<br>โœ… Threat detection<br>โœ… Form blocking | ### **Example Test Output** ```bash # Running test-client.js โœ… Library installed correctly โœ… ValidationShark component available โœ… Security validation working โœ… Template files present # Running test-connection.js ๐Ÿ” Analyzing your project... โœ… Found 3 protected inputs โœ… Security validation active ๐Ÿ“Š Protection coverage: 100% ``` ### **Troubleshooting** If tests fail: 1. **Check installation**: `npm list securesharkinputs` 2. **Verify template**: Look for `src/components/SecureSharkForm.tsx` 3. **Check console**: Open browser console (F12) for validation logs ## ๐ŸŽฏ **Why Choose SecureSharkInputs?** ### **Super Simple** - One component does everything - No complex configuration - Automatic react-hook-form integration ### **Enterprise Security** - Multi-layer threat detection - Real-time validation - Form submission blocking ### **Developer Friendly** - TypeScript support - Automatic template installation - Comprehensive documentation - Built-in testing tools ### **Production Ready** - Lightweight (131.11 KB library code) - Includes all dependencies (react-hook-form, react, typescript, yup) - Battle-tested security algorithms ## ๐Ÿ“ฆ **Package Info** - **Library Size**: 131.11 KB (compiled code only) - **Package Size**: 61.5 KB (compressed for npm) - **Unpacked Size**: 269.3 KB (includes dependencies) - **Dependencies**: react-hook-form, react, typescript, yup (included) - **TypeScript**: Full support - **React**: 18+ compatible - **Files**: 42 total files - **Testing Tools**: 3 built-in test scripts ### **Size Breakdown:** - **useSchema.js**: 40.02 KB (validation engine) - **secureSharkBackend.js**: 11.02 KB (backend protection) - **enterpriseValidator.js**: 9.41 KB (enterprise services) - **ValidationShark.js**: 6.96 KB (React component) - **index.js**: 2.01 KB (entry point) ## ๐Ÿ“š **Documentation** ### **Complete Guides** - **[Complete Guide](COMPLETE_GUIDE.md)** - Step-by-step tutorial for everything - **[Connection Verification](CONNECTION_VERIFICATION.md)** - Verify your inputs are protected ### **Quick References** - **Installation**: `npm install securesharkinputs` - **Basic Usage**: `<ValidationShark name="email" type="email" label="Email" />` - **Testing**: `node node_modules/securesharkinputs/scripts/test-client.js` ## ๐Ÿค **Contributing** We welcome contributions! Please see our [GitHub repository](https://github.com/AzzADesigns/SecureSharkInputs) for details. ## ๐Ÿ“„ **License** MIT License - see [LICENSE](LICENSE) file for details. --- **Made with โค๏ธ by [Azariel Moreno](https://azzadesignsweb.vercel.app/)**