
Research
Supply Chain Attack on Axios Pulls Malicious Dependency from npm
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.
react-input-mask-hook
Advanced tools
React hook for connecting to the input of a strict/non-strict mask.
React hook for connecting to the input of a strict/non-strict mask.
npm i react-input-mask-hook
Passes an object with properties as input:
| Name | Required | Type | Description | ||
|---|---|---|---|---|---|
| inputRef | + | RefObject | Ref connected to the input element. | ||
| mask | + | string | Mask with which the user interacts. | ||
| replace | + |
Object
| Key - regular expression. Which characters in the mask the user can edit. Value - regular expression. Those values that you can change the key to. | ||
| strict | - | boolean | Determines whether the mask is strict or not. | ||
| pattern | - | string | To check if a mask matches a regular expression input.pattern. |
Hook returns an object with the following properties:
| Name | Type | Description |
|---|---|---|
| value | string | Value from input. |
| error | string | Error text from input.validationMessage |
| isValid | boolean | Indicates whether the mask matches the pattern. |
| onChange | function | onChange handler. |
const inputRef = useRef<HTMLInputElement>(null);
const { value, onChange } = useMask({
inputRef: inputRef,
mask: "+7 (123) 123-12-13",
replace: {
key: /\d/,
value: /\d/,
},
strict: true,
});
return (
<label>
<input
type="text"
value={value}
onChange={onChange}
ref={inputRef}
/>
</label>
);
In this example, it makes sense to add a pattern for validation, since some characters may be equal to "_".
const inputRef = useRef<HTMLInputElement>(null);
const { value, onChange, error, isValid } = useMask({
inputRef: inputRef,
mask: "+7 (___) ___-__-__",
replace: {
key: /_/,
value: /\d/,
},
strict: true,
pattern: '\\+\\d\\s\\([\\d]{3}\\)\\s[\\d]{3}-\\d\\d-\\d\\d',
});
return (
<label>
<input
type="text"
value={value}
onChange={onChange}
ref={inputRef}
/>
<span>{error}</span>
</label>
);
const inputRef = React.useRef<HTMLInputElement>(null);
const { value, onChange, error, isValid } = useMask({
inputRef: inputRef,
mask: 'pochta@gmail.com',
replace: {
key: /[a-z]/i,
value: /[a-z]/i,
},
pattern: '[a-z]+@[a-z]+\\.(ru|com)'
});
return (
<label>
<input
type="text"
value={value}
onChange={onChange}
ref={inputRef}
/>
<span>{error}</span>
</label>
);
const inputRef = React.useRef<HTMLInputElement>(null);
const { value, onChange, error, isValid } = useMask({
inputRef: inputRef,
mask: 'http://*.com',
replace: {
key: /\*/,
value: /[a-z]/,
},
pattern: 'http:\\/\\/[a-z]+\\.com'
});
return (
<label>
<input
type="text"
value={value}
onChange={onChange}
ref={inputRef}
/>
<span>{error}</span>
</label>
);
FAQs
React hook for connecting to the input of a strict/non-strict mask.
We found that react-input-mask-hook demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.