Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
spemailhandler
Advanced tools
A script to handle the interaction between a Bootstrap-based contact form and the server, handling form submission and feedback.
SPEmailHandler is a simple contact form handler that uses Bootstrap's modal for success feedback and manages form validation and submissions via JavaScript.
To use this script, you’ll need:
Install SPEmailHandler from npm:
npm install spemailhandler
Then, in your JavaScript:
import { ContactForm } from "spemailhandler";
const formHandler = new ContactForm("/path/to/your-server-script.php");
The following HTML structure is required for SPEmailHandler to function correctly. Be sure to use the correct id and class attributes as the script depends on these identifiers.
Name Input:
<input type="text" id="name" placeholder="Your Name">
Email Input:
<input type="email" id="email" placeholder="Your Email">
Message Input:
<textarea id="message" placeholder="Your Message"></textarea>
Submit Button:
<button id="sendmessage">Send Message</button>
Cancel Button (for modal)
<button id="contactCancel" data-bs-dismiss="modal">Cancel</button>
Alert for Displaying Errors
<div id="message-alert" style="display: none;"></div>
Success Modal
<div class="modal fade" id="success" tabindex="-1" aria-labelledby="successLabel" aria-hidden="true">
Success Message
</div>
After including the necessary HTML elements and Bootstrap modal, initialize ContactForm by passing the URL of your server-side script that handles form submissions.
const formHandler = new ContactForm("/path/to/your-server-script.php");
The server script should return a JSON response in the following format:
{
"status": "success", // or "error"
"message": "Optional error message"
}
<form id="contact-form">
<input type="text" id="name" placeholder="Your Name">
<input type="email" id="email" placeholder="Your Email">
<textarea id="message" placeholder="Your Message"></textarea>
<div id="message-alert" style="display: none;"></div>
<button id="sendmessage">Send Message</button>
</form>
<div class="modal fade" id="success" tabindex="-1" aria-labelledby="successLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="successLabel">Success</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
Your message has been sent successfully!
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
FAQs
A script to handle the interaction between a Bootstrap-based contact form and the server, handling form submission and feedback.
The npm package spemailhandler receives a total of 123 weekly downloads. As such, spemailhandler popularity was classified as not popular.
We found that spemailhandler demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.