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.
@biproxi/react-text-mask
Advanced tools
First, install it.
npm i react-text-mask --save
Then, require it and use it.
import React from 'react'
import MaskedInput from 'react-text-mask'
export default () => (
<div>
<MaskedInput
mask={['(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/]}
/>
</div>
)
<MaskedInput/>
is fully compatible with <input/>
element. So, you can
pass it CSS classes, a placeholder attribute, or even an onBlur
handler.
For example, the following works:
<MaskedInput
mask={['(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/]}
className="form-control"
placeholder="Enter a phone number"
guide={false}
id="my-input-id"
onBlur={() => {}}
onChange={() => {}}
/>
For more information about the props
that you can pass to the component, see
the documentation here.
To see an example of the code running, follow these steps:
git clone git@github.com:text-mask/text-mask.git
cd text-mask
npm install
npm run react:dev
The code of the example is in react/example
.
<input>
ComponentFor advanced uses, you can customize the rendering of the resultant <input>
via a render prop.
This is entirely optional, if no render
prop is passed, a normal <input>
is rendered.
For example, to use with styled-components, which requires an innerRef:
<MaskedInput
mask={['(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/]}
placeholder="Enter a phone number"
id="my-input-id"
render={(ref, props) => (
<MyStyledInput innerRef={ref} {...props} />
)}
/>
const MyStyledInput = styled.input`
background: papayawhip;
`;
We would love some contributions! Check out this document to get started.
FAQs
React input component that accepts mask pattern
The npm package @biproxi/react-text-mask receives a total of 517 weekly downloads. As such, @biproxi/react-text-mask popularity was classified as not popular.
We found that @biproxi/react-text-mask demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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.